C/C++ Programming Help Thread
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; You put the forward declaration (sometimes called the prototype) in the header file, not the function, or else you'll get ...
-
07-09-2007, 12:30 PM #5401It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
You put the forward declaration (sometimes called the prototype) in the header file, not the function, or else you'll get a linker error.
Try something like this
funcs.cpp:
main.cpp:Code:int myFunc() { return doSomething(); }
funcs.hpp:Code:#include "funcs.hpp" int main() { return myFunc(); }
Code:int myFunc();
Geändert von Archaemic (07-09-2007 um 12:43 PM Uhr)
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
07-09-2007, 12:37 PM #5402QJ Gamer Green
- Registriert seit
- Jul 2007
- Beiträge
- 88
- Points
- 3.606
- Level
- 37
- Downloads
- 0
- Uploads
- 0
But how does this work?
Or are you expecting me that ive included the .h already?
-
07-09-2007, 12:43 PM #5403It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Oops, forgot that. Hold on, let me edit my post
Okay, there we go.pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
07-09-2007, 01:38 PM #5404QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
What MiG is trying to say is when he renders something in 3D model space, how do you get the screen space co-ordinates.
Zitat von Archaemic
The answer is via lots of matrix math. You need to get the x,y,z position of object in model space, multiple it with the view matrix and multiple that result with the perspective matrix. The x and y components of the end result should be the x and y position in screen space.
In reality, you don't do collision detection this way. You do it in 3D model space, not screen space.
FistPump nailed it in one.
Zitat von FistPump
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
07-09-2007, 03:49 PM #5405QJ Gamer Green
- Registriert seit
- Jul 2007
- Beiträge
- 88
- Points
- 3.606
- Level
- 37
- Downloads
- 0
- Uploads
- 0
Why doesnt this work?
It leaves me with a blank screen. Why doesnt it show: 0?Code:int counter = 0; SceCtrlData pad; int main() { printf("Counter: %i ", counter); pspDebugScreenInit(); SetupCallbacks(); sceKernelSleepThread(); // Wait for home return 0; }
Also for an player object, what would be better to use.
structures, or classes? (like a simple player)
Just a box, added with physics (collisions, moving, jumping, gravity, etc.)
-
07-09-2007, 04:14 PM #5406QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Go to PSP-Programming and follow their tutorials before you worry about making a game.
-
07-09-2007, 06:17 PM #5407QJ Gamer Green
- Registriert seit
- Jul 2007
- Beiträge
- 88
- Points
- 3.606
- Level
- 37
- Downloads
- 0
- Uploads
- 0
I waited all that time for that........
I did go to psp-programming.com, infact thats where I learnt that from.
-
07-09-2007, 06:39 PM #5408It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Fixed. pspDebugScreenPrintf needs to be after pspDebugScreenInit.Code:int counter = 0; int main() { SetupCallbacks(); pspDebugScreenInit(); pspDebugScreenPrintf("Counter: %i ", counter); return 0; sceKernelSleepThread(); // Wait for home }pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
07-09-2007, 07:24 PM #5409QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
No. No you didn't.
Zitat von Beat_Bob
-
07-09-2007, 07:32 PM #5410QJ Gamer Green
- Registriert seit
- Jul 2007
- Beiträge
- 88
- Points
- 3.606
- Level
- 37
- Downloads
- 0
- Uploads
- 0
Anyone know about this error?
[email protected] ~/PSProjects/imager
$ make
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -I. -I/usr/local/
spdev/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -fno-rtti -c -o main.o ma
n.cpp
main.cpp:8:39: error: graphics.h: No such file or directory
main.cpp: In function 'int main()':
main.cpp:49: error: 'initGraphics' was not declared in this scope
main.cpp:51: error: 'Image' was not declared in this scope
main.cpp:51: error: 'ourImage' was not declared in this scope
main.cpp:53: error: 'loadImage' was not declared in this scope
main.cpp:58: error: 'blitAlphaImageToScreen' was not declared in this scope
main.cpp:59: error: 'flipScreen' was not declared in this scope
make: *** [main.o] Error 1
I did the svn checkout, but it sais it cant find graphics.h
Huh?Geändert von Beat_Bob (07-09-2007 um 09:19 PM Uhr)
-
07-09-2007, 08:48 PM #5411QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Yes it did. If you are too stupid to follow those tutorials, get a book on C and get reading.
-
07-09-2007, 09:19 PM #5412QJ Gamer Green
- Registriert seit
- Jul 2007
- Beiträge
- 88
- Points
- 3.606
- Level
- 37
- Downloads
- 0
- Uploads
- 0
Could you answer my next question. (what a nice forum)
-
07-09-2007, 09:24 PM #5413QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Isn't it? Stop complaining.
Zitat von Beat_Bob
That or graphics.h doesn't exist at all.Code:extern "C" { #include "graphics.h" }
-
07-09-2007, 09:43 PM #5414QJ Gamer Green
- Registriert seit
- Jul 2007
- Beiträge
- 88
- Points
- 3.606
- Level
- 37
- Downloads
- 0
- Uploads
- 0
Now I have a two more errors, but the graphics.h one is gone:
My main.c:Code:$ make psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION= 150 -c -o main.o main.c main.c:8: error: expected identifier or '(' before string constant main.c:8: error: stray '#' in program main.c: In function 'main': main.c:49: warning: implicit declaration of function 'initGraphics' main.c:51: error: 'Image' undeclared (first use in this function) main.c:51: error: (Each undeclared identifier is reported only once main.c:51: error: for each function it appears in.) main.c:51: error: 'ourImage' undeclared (first use in this function) main.c:53: warning: implicit declaration of function 'loadImage' main.c:58: warning: implicit declaration of function 'blitAlphaImageToScreen' main.c:59: warning: implicit declaration of function 'flipScreen' make: *** [main.o] Error 1
Spoiler for Spoil:
I did the svn checkout, how could it not exist?
Or is graphics.h a seperate file and needs to be downloaded seperately? If so could
someone provide a link?
-
07-09-2007, 09:50 PM #5415QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Try,
As I said, as I believe it isn't parsing the '{#' correctly.Code:extern "C" { #include "graphics.h" }
-
07-09-2007, 09:52 PM #5416QJ Gamer Green
- Registriert seit
- Jul 2007
- Beiträge
- 88
- Points
- 3.606
- Level
- 37
- Downloads
- 0
- Uploads
- 0
Well I did that and now heres my error list:
Code:$ make psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION= 150 -c -o main.o main.c main.c:8: error: expected identifier or '(' before string constant main.c:9:23: error: graphics.h: No such file or directory main.c: In function 'main': main.c:51: warning: implicit declaration of function 'initGraphics' main.c:53: error: 'Image' undeclared (first use in this function) main.c:53: error: (Each undeclared identifier is reported only once main.c:53: error: for each function it appears in.) main.c:53: error: 'ourImage' undeclared (first use in this function) main.c:55: warning: implicit declaration of function 'loadImage' main.c:60: warning: implicit declaration of function 'blitAlphaImageToScreen' main.c:61: warning: implicit declaration of function 'flipScreen' make: *** [main.o] Error 1
-
07-09-2007, 09:58 PM #5417QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Argh! Lesson 4, PSP-Programming tutorials. I thought you went there first?
Zitat von Beat_Bob
-
07-09-2007, 10:19 PM #5418QJ Gamer Green
- Registriert seit
- Jul 2007
- Beiträge
- 88
- Points
- 3.606
- Level
- 37
- Downloads
- 0
- Uploads
- 0
I couldnt find the link anywhere.
I assumed it was put in the svn checkout download.
-
07-09-2007, 10:28 PM #5419QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
-
07-09-2007, 10:40 PM #5420QJ Gamer Green
- Registriert seit
- Jul 2007
- Beiträge
- 88
- Points
- 3.606
- Level
- 37
- Downloads
- 0
- Uploads
- 0
I made a folder on my user directory called graphics, put the files in there,
ran the batch and now heres what I got:
(my main.c is in my other post)Code:$ make psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION 150 -c -o main.o main.c main.c:8: error: expected identifier or '(' before string constant main.c:9:22: error: graphics.h: No such file or directory main.c: In function 'main': main.c:51: warning: implicit declaration of function 'initGraphics' main.c:53: error: 'Image' undeclared (first use in this function) main.c:53: error: (Each undeclared identifier is reported only once main.c:53: error: for each function it appears in.) main.c:53: error: 'ourImage' undeclared (first use in this function) main.c:55: warning: implicit declaration of function 'loadImage' main.c:60: warning: implicit declaration of function 'blitAlphaImageToScreen' main.c:61: warning: implicit declaration of function 'flipScreen' make: *** [main.o] Error 1
Also do I need to be worried about these warnings?
-
07-09-2007, 10:47 PM #5421QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
You should always be worried about warnings.
Put graphics.c/h and framebuffer.c/h into the project directory, then make sure to add 'graphics.o' and 'framebuffer.o' to the OBJS line in your makefile.
-
07-09-2007, 10:55 PM #5422QJ Gamer Green
- Registriert seit
- Jul 2007
- Beiträge
- 88
- Points
- 3.606
- Level
- 37
- Downloads
- 0
- Uploads
- 0
Nope, still didnt work.
I dont think it matters but my project directory name is PSProjects.
Also heres my makefile:
Errors:Code: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
Code:$ make psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION 150 -c -o main.o main.c main.c:9:22: error: graphics.h: No such file or directory main.c: In function 'main': main.c:50: error: 'Image' undeclared (first use in this function) main.c:50: error: (Each undeclared identifier is reported only once main.c:50: error: for each function it appears in.) main.c:50: error: 'ourImage' undeclared (first use in this function) main.c:53: warning: implicit declaration of function 'initGraphics' main.c:55: warning: implicit declaration of function 'loadImage' main.c:60: warning: implicit declaration of function 'blitAlphaImageToScreen' main.c:61: warning: implicit declaration of function 'flipScreen' make: *** [main.o] Error 1
-
07-09-2007, 10:57 PM #5423QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
The quotes in the #include line tell the compiler that the header file is in the same directory as the current file.
So, if you have you main.c in 'blah/PSProjects/myProject/', graphics.c/h and framebuffer.c/h need to be in that directory as well.
I'm going to bed, so you may have to wait for yaustar if you are still having problems.
-
07-09-2007, 11:01 PM #5424QJ Gamer Green
- Registriert seit
- Jul 2007
- Beiträge
- 88
- Points
- 3.606
- Level
- 37
- Downloads
- 0
- Uploads
- 0
Ah thanks.
Also the warnings do I really need to be worried about them?
What could happen? (depending on the warnings)
-
07-09-2007, 11:41 PM #5425QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 499
- Points
- 5.848
- Level
- 49
- Downloads
- 0
- Uploads
- 0
loads of things but your getting warnings because you have no idea what your doing, and missing a simple include.
Zitat von Beat_Bob
Sorry, it seems i'm being a bit harsh, but make sure your code is word for word that of the tutorial.
-
07-10-2007, 01:58 AM #5426QJ Gamer Green
- Registriert seit
- Apr 2006
- Ort
- England ~¦¦¦|+|¦¦¦~
- Beiträge
- 1.112
- Points
- 9.165
- Level
- 64
- My Mood
-
- Downloads
- 0
- Uploads
- 0
isnt it bloody obvious? It cant find 'graphics.h'! check that its actually there and check that you included it correctly.main.c:9:22: error: graphics.h: No such file or directory...Just Returned To The Scene...
-
07-10-2007, 02:47 AM #5427QJ Gamer Green
- Registriert seit
- Sep 2006
- Ort
- Cape Town, South Africa
- Beiträge
- 714
- Points
- 5.795
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Does anyone know?
Zitat von coolguy5678
-
07-10-2007, 03:16 AM #5428I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Can someone point me in the direction of where I can find a tutorial or something on using sceIoAssign? I have some ideas I want to test out with it and flash... but needless to say, its flash and I want to make damn sure I can't mess up something!
Thanks.
-Aura
-
07-10-2007, 03:50 AM #5429QJ Gamer Bronze

- Registriert seit
- Jun 2006
- Beiträge
- 144
- Points
- 7.047
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Search on the PSP forum on http://forums.ps2dev.org . Don't post there or you'd get flamed instantly, though... :)
Adrahil - Software architect and specialist in Reverse Engineering.
Spoiler for Guilt of a Dev:
Spoiler for me:
-
07-10-2007, 06:56 AM #5430QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Yeah, adrahi's right. Regardless, ps2dev is the best. place. ever.
Zitat von adrahil


LinkBack URL
About LinkBacks
Mit Zitat antworten
You don't detect where they are based on the screen.



Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum