![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Links: OSLib , PSProgramming , C/C++ Discussion Thread , PSP Dev Forum Rules Ok, i seriously think that PSPUpdates needs ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() ![]() ...in a dream...
|
Links: OSLib, PSProgramming, C/C++ Discussion Thread, PSP Dev Forum Rules
Ok, i seriously think that PSPUpdates needs a Help Thread for the old fashion programming, not just for LUA becasue there are some devrs out there that need help too and sometimes the people at ps2dev.org are ***es and dont even looka tyour post and such so if this doesnt get stickied i dont mind, i just think a temperary help forum will also do some good ok for my question (just so you guyz know, im a 5 day old programmer in c/c++) My code is complying perfectly with no errors or anything, and i was just wondering what the best ways to laod images are, an example would be Code:
blitAlphaImageToScreen(0, 0, height, width, Image*, posX, posY);
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) Last edited by Moose; 08-30-2008 at 08:06 AM.. |
|
|
|
|
|
#2 |
![]() ![]() Developer
|
|
|
|
|
|
|
#3 |
![]() |
I encountered something similar to your error and it was because I was loading my .png's in the main loop by accident...you want to set up a function or something to load all your png's first, so it's not doing it over and over, then launch your main loop...if that's not the problem check where you are calling flipscreen(); because blitimage is the function to be using for drawing most if not all basic 2D graphics...
__________________
PSN: Shatterdome |
|
|
|
|
|
#4 |
![]() ![]() ...in a dream...
|
ofcourse! i knew it, i did int main() { then while(1) {, ill test this out after s hool, thanks dude if this works (like it should) ill have a beta or alpha of kitty cannon about next friday or in a week basically, thanks again i know this will wokr! because it makes so much sense
loading te image in hte loop meaning it wiuld load the image like a abillion times the problem i have! ha anyway thanks again
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#5 |
|
I welcome your idea of putting a c/c++ help topic in this forum.
I will take profit and ask a question: I have pretty basic knowledge of c++ and I love programming. I would appreciate if any of you could give me a hand and tell me how can I begin using my time and little knowledge to create a game (or something that looks like one), some tutorials for example. Thanks for all. |
|
|
|
|
|
|
#7 |
![]() |
Why one thread.. post each question in a new thread like we've been doing, it's easier to find stuff later and it's easier to find the answers rather than having them spanned across multiple pages. (look how hard it is to find stuff in the PSP Programming Tutorials thread).
__________________
[url=http://www.barbdwyer.com/footer.php][img]http://www.barbdwyer.com/8Ball.jpg[/img][/url] [FONT=Verdana][SIZE=1] [b]PSP Developer Resource Site:[/b] [url=http://www.psp-programming.com]PSP-Programming.com[/url] [b]Other:[/b] [url=http://wake-boarding.org]Wakeboarding[/url], [url=http://water-skiing.org]Waterskiing[/url], [url=http://wake-surfing.org]Wake Surfing[/url], [url=http://www.guitarhero-4.com]Guitar Hero IV[/url][/SIZE][/FONT] |
|
|
|
|
|
#8 |
![]() |
If you want to write a program for the PSP using C/C++ that uses 2D graphics, listen closely. This is the best advice you will get, I gaurontee:
Use SDL to write your game. There is a working port in the SVN. Once setup, writing code for it probably rivals LUA in terms of ease of use and portability. And the best part you ask? SDL is fully documented. Yes, complete easy to use tutorials exist for adding graphics, sound, user controlls (among other things). And these tutorials can be applied to PSP programming. And finally, Rinco, the porter of SDL, is allways eager to help with any technical issues you may encounter. Garak |
|
|
|
|
|
#9 |
![]() ![]() ...in a dream...
|
ok thats cool ill try that, but when it ryed to install that, it messed up and wouldnt install something wiht the ogg libs or soemthing i dunno but im still gonna keep tryin to install SDL seeing as how you ca load .bmps in it
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#10 | |
![]() ![]() Developer
|
Quote:
|
|
|
|
|
|
|
#11 | |
![]() ![]() ...in a dream...
|
Quote:
Code:
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"
#define printf pspDebugScreenPrintf
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
PSP_MODULE_INFO("c/c++ kitty", 0, 1, 1);
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid , 0, 0);
}
return thid;
}
int main()//------------------------------------Start Main Loop
{
pspDebugScreenInit();
SetupCallbacks();
initGraphics();
char buffer[200];
Image* manBG;
sprintf(buffer, "data/menu/mainBG.png");
manBG = loadImage(buffer);
while(1) { //-------------------------------Start 1st INNER Loop
if (!manBG) {
printf("Image Failed to Load, Contact JordanSg57@gmail.com");
} else {
int x = 0;
int y = 0;
sceDisplayWaitVblankStart();
while (x < 480) {
while (y < 272) {
blitAlphaImageToScreen(0, 0, 480, 272, manBG, x, y);
y+= 272;
}
x+= 480;
y = 0;
}
flipScreen();
}
} //---------------------------------------------------------------End 1st INNER Loop
sceKernelExitGame();
return 0;
}//---------------------------------------------------------------//End Main Loop
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
|
#12 |
![]() |
I haven't gotten into imaging on the PSP yet, but just from code that I've looked at (Danzel's peldet, complicated!) wouldn't:
if (!manBG) { printf("Im... shouldn't that be: if (manBG != loadImage (buffer)) {... because doesn't ! mean just not, so it would be like 'not manBG', and it should be 'if manBG not equal to loadImage(buffer) which it should be equal to, right? Or am I just too much of a noob that I don't even fully understand the usage of the exclamation point :sad:
__________________
[URL="http://www.newlilwayne.com"]www.NewLilWayne.com[/URL] Last edited by soccerPMN; 05-06-2006 at 08:51 PM.. |
|
|
|
|
|
#13 |
![]() |
hmm, looks like you set x and y to 0 and if i'm reading it correct they just get set to there max right away and that those while loops will end, then the loop continues...and you only set y back to 0, not x...
x += 480 is the same as x = x + 480... I think you meant to put x += 1, which will increment it by one...but if you want it to tile your picture you will want to go x += picwidth and y += piclength.... hope that helps...
__________________
PSN: Shatterdome |
|
|
|
|
|
#14 | |
![]() |
Quote:
but you never know...as long as you know you have your image in the right directory, trying // the error checking out and see what happens...
__________________
PSN: Shatterdome |
|
|
|
|
|
|
#15 |
![]() ![]() ...in a dream...
|
nvm, fixed it
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) Last edited by SG57; 01-27-2006 at 09:12 PM.. |
|
|
|
|
|
#16 |
![]() ![]() ...in a dream...
|
ok i finally got it to work with no flashing or anything after like anhour of restarting and checking the makefile, etc. this is the code that works, can anyone tell me what was wrong with the one before and this one?
Code:
int main()//------------------------------------Start Main Loop
{
pspDebugScreenInit();
SetupCallbacks();
initGraphics();
char buffer[200];
Image* mainBG;
sprintf(buffer, "data/main.PNG");
mainBG = loadImage(buffer);
while(1) { //-------------------------------Start 1st INNER Loop
if (!mainBG) {
printf("Image Failed to Load, Contact JordanSg57@gmail.com");
} else {
int x = 0;
int y = 0;
sceDisplayWaitVblankStart();
blitAlphaImageToScreen(0, 0, 480, 272, mainBG, x, y);
flipScreen();
}
} //---------------------------------------------------------------End 1st INNER Loop
sceKernelExitGame();
return 0;
}//---------------------------------------------------------------//End Main Loop
EDIT: loading 2 images has got me half of the backround black blinking a little, and the entire cursor blitted perfectly, but when i use the analog (added a mouse/curosr movement with analog) , it shows hte trail of the mouse and it goes in its own direction like my psp is freezing once hte mouse goes off screen but i think i can fix it with making boundaries, so im guessing the screenfillrect function nis the answer seeing as how it refreshes the screen or soemthing like that, so what would it be called if i wnate dit to be black? Code:
ScreenFillRect(RGB(0, 0, 0))
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) Last edited by SG57; 01-27-2006 at 09:12 PM.. |
|
|
|
|
|
#17 |
![]() |
Yeah, i've yet to completely figure it out...mainly it's understanding how it draws to the screen I guess...I'm having a problem in doing my animation in a game, in that it always keeps the previous image in the same spot...it's like the drawbuffer I guess it's called, that you draw to before fliping the screen is never cleared ? unless you do it manually ? it'd be cool if someone could clarify that...or is it always a blank slate you have to draw to, then flip.....doesn't seem to be...
__________________
PSN: Shatterdome |
|
|
|
|
|
#18 |
![]() ![]() ...in a dream...
|
i know what you mean but in LUA when i was programming, all you had to do was screen:fillrect(0, 0, 0, 0, black) and it refreshes the screen black everytime soemthing moves or the vblank goes by it so if you blit an image over the black then it woudl fix it so im wondering how to call that function/line or even if it is called that in c/c++, guess we gotta wait for the more knowlegable devs to take a look in here...
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#19 |
![]() ![]() ...in a dream...
|
Shatter Dome i figured outhow to fix the trail thing, just blit the 2 images together and it wont do it, like for me, i have a backround and a cursor as my menu right, so i blitted my images seperatley in 2 different places in stead of just one here is an example
Code:
char buffer[200];
char buffer1[200];
Image* other;
Image* backround;
sprintf(buffer, "backround.PNG");
backround = loadImage(buffer);
sprintf(buffer1, "other.PNG");
other = loadImage(buffer1);
int main() {
while(1) {
if(!backround) {
printf("Image Load Failed");
} else {
int x = 0;
int y = 0;
sceDisplayWaitVblankStart();
blitAlphaImageToScreen(0, 0, 480, 272, backround, x, y);
flipScreen();
}
if(!other) {
printf("Image Load Failed dude);
} else {
int otherx = 240;
int othery = 136;
sceDisplayWaitVblankStart();
blitalphaImageToScreen(0, 0, 10, 16, other, otherx, othery);
flipScreen();
}
}
}
Code:
char buffer[200];
char buffer1[200];
Image* other;
Image* backround;
sprintf(buffer, "backround.PNG");
backround = loadImage(buffer);
sprintf(buffer1, "other.PNG");
other = loadImage(buffer1);
int main() {
while(1) {
if(!backround) {
printf("Image Load Failed");
} else {
int x = 0;
int y = 0;
int otherx = 240;
int othery = 136;
sceDisplayWaitVblankStart();
blitAlphaImageToScreen(0, 0, 480, 272, backround, x, y);
blitAlphaImageToScreen(0, 0, 10, 16, other, otherx, othery);
flipScreen();
}
}
}
now for my question, how do i load a LUA script from a C/C++ eboot? or is there a complier to compli a LUA script into a c/c++ source file of somesort? because i made these credits in LUA nad i dont want to re writethem in LUa so is htere some luaplayer elf booter that i could use to call dofile("credits.lua); or soemthing of the sort? thanks if you can help
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) Last edited by SG57; 01-28-2006 at 04:07 PM.. |
|
|
|
|
|
#20 |
![]() ![]() ...in a dream...
|
anyone know what the code snippet is to EXIT out of the game without actually clicking, home/yes?
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#21 |
![]() Mushroom Man
|
sceKernelExitGame(); I think.
__________________
[URL=http://www.othala.co.uk]Othala[/URL] [B]o[/B] [URL=http://www.entheogendefencefund.org.uk/]Save the shroom![/URL] [CENTER][URL=http://www.othala.co.uk/travellerBlog][IMG]http://www.othala.co.uk/graphics/travBanner.png[/IMG][/URL][/CENTER] |
|
|
|
|
|
#22 | |
![]() ![]() ...in a dream...
|
Quote:
Code:
if(pad.Buttons & PSP_CTRL_CROSS) {
sceKernelExitGame();
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
|
#24 |
![]() ![]() ...in a dream...
|
lol you are such a critic lol you are everywhere! i was in a hurry so i for got the end bracket geeze lol
o and by thte way, it worked lol
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#27 |
![]() |
oo aight thx but um still gettin a prob
im trying to compile the main.cpp in my file but when keep getting a: No rule to make target 'main.o', needed by 'hello.elf'. stop i made a main.cpp and removed the main.c and wat i put above is the error im gettin Last edited by chingwyn; 01-30-2006 at 03:42 PM.. |
|
|
|
|
|
#29 |
![]() |
TARGET = hello
OBJS = main.o graphics.o framebuffer.o CFLAGS = -O2 -G0 -Wall CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) LIBDIR = LIBS = -lpspgu -lpng -lz -lm LDFLAGS = EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = Image Example PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak |
|
|
|
|
|
#30 |
![]() ![]() ...in a dream...
|
tisk tisk...you dont need the file to be a .cpp for a simple image example program, it would have to consist of mainly all C/C++, or ellse you get that error, because when i was porting, they were in .c and i was getting that error and i cahgned them to there opposite (.cpp) and wallaa it wokred
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
![]() |
| Tags |
| c or c , c++ , c/c++ , code , coding , c_language , programming , psp , psp programming , thread |
| Thread Tools | |
|
|