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; I've found what I was doing wrong ! I was using the tiff changeBuffer function......
-
02-13-2007, 07:17 PM #2761likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
I've found what I was doing wrong !
I was using the tiff changeBuffer function...
-
02-14-2007, 12:13 AM #2762QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Re: C/C++ Programming Help Thread
You really should change that code. As it is, it is predestinated to be slow (even on PC) and cause problems.
Zitat von SG57
Do the tesselation for each side of the skybox, so that you avoid all those texture swaps. They are very costly and should be avoided whereever possible!
Also I'm not sure about your tesselation algorithm, since I don't know what STEP is supposed to be as well as why you step i and j by 5. Also your coordinates seem off.
Say you want to subdivide a big QUAD into 4x4 parts with constant z (front or back of skybox):
You should be able to adopt that code to create side and top/bottom quads too and also change the subdivision depth. To optimize that for drawing speed, you could also use TRIANGLE_STRIP to create one row of the subdivision, but I'll leave that to you to figure out if you want.Code:glBindTexture(GL_TEXTURE_2D,mytex); glScalef( width, height, length ); glBegin(GL_QUADS); // dunno if multi-quads within one GL_QUADS block is possible on PSPGL for (i=0;i<4;i++) for (j=0;j<4;j++) { glTexture2f( j/4.0f, i/4.0f ); glVertex3f( j/4.0f, i/4.0f, 1.0f ); glTexture2f( (j+1)/4.0f, i/4.0f ); glVertex3f( (j+1)/4.0f, i/4.0f, 1.0f ); glTexture2f( (j+1)/4.0f, (i+1)/4.0f ); glVertex3f( (j+1)/4.0f, (i+1)/4.0f, 1.0f ); glTexture2f( j/4.0f, (i+1)/4.0f ); glVertex3f( j/4.0f, (i+1)/4.0f, 1.0f ); } glEnd();Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
02-14-2007, 07:39 AM #2763Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
I am trying to make my first prx , but i he isnt working , no errors or warnings
Spoiler for main:
Spoiler for exports:
Spoiler for makefile:
-
02-14-2007, 07:55 AM #2764words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
RAphael -
#define STEP (1.0f/256.0f)
My textures are 256x256, and I had 5 as an interval, because it was slow, and still is, and doesnt work. Ill use your code their and adopt it to fit my needswhen i get home from school. But honestly, shouldn't I just be able to make some minor number tweaks to that right there. For each side of the cube, id change values, but that right there is a base framework to use? Or should I change that to be exact andforget about scaling? My first skybox function did that... MAde huge quads, they culled very easily.
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
02-14-2007, 09:29 AM #2765
Need some help...stuck at splash screen!
Compiles fine. I either get a black screenCode:int i; char* tempstr; char number; tempstr= "Trial and error since 2 days"; initGraphics(); for(i=0;i<255;i++) { Color mycolor=RGB(i,i,i); printTextCentered(136,tempstr,mycolor); sprintf(number,"The value of I must be shown here but it doesn't %i",i); } flipScreen();
or Just the centered text in white colorNO CHANGE IN COLOR DURING LOOP happens! but what I want [Go from black to white using RGB. Doesn't happen].
sprintf yields no result.
Please Help :Cry: ASAP,better.
I've already charged psp 2wice for this.
-
02-14-2007, 09:44 AM #2766Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
The first argument of sprintf is char*, therefor you need to pass the address of number (&number). But you would get an overflow. You should use an array.
Zitat von Mr305
I believe it doesn't change color because you only flip the screen after drawing all of them, therefore only the last one drawn will be shown.
Also sprintf won't print anything to the screen, printf does that.
try
Code:int i; char* tempstr; tempstr= "Trial and error since 2 days"; initGraphics(); for(i=0;i<255;i++) { Color mycolor=RGB(i,i,i); printTextCentered(136,tempstr,mycolor); printf("The value of I must be shown here but it doesn't %i",i); flipScreen(); }
-
02-14-2007, 09:51 AM #2767
Thanx for reply, be here I'll post the result. PLEASE :o
Zitat von Waterbottle
Q: i don think DebugScreenPrintf, which needs debugscreeninit, works after initgraphics.
-
02-14-2007, 09:54 AM #2768
Ok, so here is my problem :
I've just began learning C++ for the PSP.
I've been playing around and having succesfull attempts (making the USB Mass Storage example as a prx as I still don't know anything concerning threads ^^)
But i've saw that the prx loader calls "void *getModuleInfo(void);" to import getModuleInfo from the loaded prx.
I need the prx to clear the screen.
But if i call pspDebugScreenClear(); withtout calling pspDebugScreenInit(); , the screen isn't cleared.
The problem if that if i call pspDebugScreenInit(); , the prx loader can't take back the control of the debug screen.
So I created a function in the prx_loader :
Spoiler for function:
and then, in the prx i add "void *clearDebugScreen(void);" and then in my main procedure, i call "clearDebugScreen()" somewhere. This is what the prx loader does. Ok ?
Now here's the problem, the prx_loader compiles fine, but the prx complains about : "main.c
.text+0x230): undefined reference to `clearDebugScreen'"
I tought this was due to the fact that I was trying to compile as a prx, but I tried changing the makefile so it can be an elf, but I get the same error
Any idea ?
-
02-14-2007, 09:56 AM #2769
Zitat von Mr305
1.)char* tempstr; is a pointer to a char, to output your tempstr you need to allocate memory for it, like:char tempstr[] = "Trial and error since 2 days";Code:int i; char tempstr[] = "Trial and error since 2 days"; char number[100]; Color mycolor; initGraphics(); for(i=0;i<255;i++) { color=RGB(i,i,i); printTextCentered(136,tempstr,mycolor); sprintf(number,"The value of I must be shown here but it doesn't %d",i); } flipScreen();
which is now a char _array_!
2.)char number; how is it supposed to store a string? you have to allocate memory for it to to store your string
3.) Do never declare variables inside a loop! never it's very bad programming behaviour, declare it before the loop
4.) to show an int, use %d
-
02-14-2007, 10:02 AM #2770
I tried to resolve issues:
Zitat von tommydanger
All I get is a BLACK screeen! :Argh:Code:int main(void) { int i; SceCtrlData pad; char* tempstr= "text here";int number; Color mycolor; initGraphics(); for(i=0;i<255;i++) { mycolor=RGB(i,i,i); printTextCentered(136,tempstr,mycolor); sprintf(number,"The number i is %d",i); } flipScreen(); } }Code:IF I TRY , char* tempstr[100 ]= "text here"; main.c:22: error: invalid initializer main.c:29: warning: passing argument 2 of 'printTextCentered' from incompatible pointer type main.c:30: warning: passing argument 1 of 'sprintf' makes pointer from integer without a cast
-
02-14-2007, 10:07 AM #2771
Ok, nevermind, I figured it out with lookking at the MyLib.s
I created a file MyLib2.s
Does having that line (STUB_START "MyLib",0x00090000,0x0001 0005) in both files can conflict (for the second I only changed "MyLib" to "MyLib2") ?
EDIT : Oh noes, it compile, but it doesn't run the function
-
02-14-2007, 10:08 AM #2772
well, how you are supposed to see the text "The number i is $anynumber" without printing to the screen? :P
hint: read the usage of sprintf again ;)
-
02-14-2007, 01:04 PM #2773QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Well, that would obviously be slow with 255x255 = 65k subdivisions, since you'd render 6x 65k = 360k+ quads = 700k triangles... too much for the PSP.
Zitat von SG57
Even with a step of 5 you have 51x51 = 250 divisions, meaning 250x6x2 = 3k triangles. Pretty much for just a skybox. Try something lower, like 16x16 and step up until the culling problems disappear. Just use the code as I gave you and make that 4's a #define to easily change the subdivision depth.
Then do that code snippet 6 times for each of the cube faces (apply the coordinates accordingly). It should work.Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
02-14-2007, 04:17 PM #2774words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
That's what i am planning to do. As for a skybox texture, I was wondering...
If I do use a 16x16 skybox texture, than rather than have a horribly pixelated and blurry 'sky', I should probably make it reptitivly place the texture upon the object, instead of scaling it. I know how to do it, change the properties of the texture from GL_LINEAR to something else, ill google it when i code later today...
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
02-14-2007, 04:55 PM #2775Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
I think Raphael meant 16x16 subdivisions with your 256x256 texture...

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
02-14-2007, 05:10 PM #2776
Hey guys. I have a question (first question at qj! please respond kindly!). Currently, i am on the 4th tutorial at psp-programming.com (very good site), and i wanted to know, is there an easier way for image processing? This is my code (with comments i added to help me); please respond by telling me which part is not necessary (besides the comments of course):
Spoiler for Spoiler for Simple Image Processing:
Edit: Never mind. I fixed it. Wasn't hard. Sorry. However, now i have a newer question. How do i use a background for a counter? What i mean is, how do i combine the 3rd and 4th tutorial to use a simple image while having a counter? Thanks, help is appreciated. :)Geändert von Xylem (02-14-2007 um 08:11 PM Uhr)
-
02-14-2007, 11:33 PM #2777words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Xylem - Either set the Debug console's framebuffer address to match that of the graphic's library, or just use the graphics library text porinting function:
An example:Code:printTextScreen( x,y, string, color);
Code:#define green 0x0000FF00L int main() { Image * background = Image.load("background.png"); int counter = 0; char counter_buffer[5]; for(;;) { // indefinate loop screen:blit(0,0,background); printTextScreen( 227,131,counter_buffer, green); sceDisplayWaitVblank(); // or w/e the function is called flipScreen(); if(counter>9999) { counter=0; } else { counter++; } // this prevents a buffer overflow, as well with the next line snprintf(counter_buffer,4,"%i",counter); } return 0; }
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
02-15-2007, 02:52 AM #2778QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- Australia - A.C.T.
- Beiträge
- 1.517
- Points
- 9.253
- Level
- 64
- Downloads
- 0
- Uploads
- 0
how do you get txt to print on the xmb, tryed the testprx but nothing seems to happen when loaded in the xmb. can any one help??
Spoiler for LOL:
-
02-15-2007, 07:53 AM #2779
How do I convert a int type to a char or char*?Code:#include <stdio.h> #include <stdlib.h> ----other code--- TRIED this buffer = itoa (rand,status,10); Tried this too itoa (rand,status,10); --other code that uses status---
I get these errors:
[CODE]
main.o: In function `main':
main.c
.text+0x168): undefined reference to `itoa'
main.c
.text+0x1c4): undefined reference to `itoa'
collect2: ld returned 1 exit status
[CODE]
I also tried
Please help!Code:extern "C" { #include <stdio.h> #include <stdlib.h> }
-
02-15-2007, 08:03 AM #2780QJ Gamer Silver
- Registriert seit
- Sep 2006
- Ort
- Finland
- Beiträge
- 752
- Points
- 7.385
- Level
- 57
- Downloads
- 0
- Uploads
- 0
Use the text blitter from the devhook VSHEX.
Zitat von mafia1ft
wheeee =:D
-
02-15-2007, 08:20 AM #2781
Google misleads !! :Argh: :Argh: :Argh:
Zitat von Mr305
sprintf() 's the king.
I guess done with scoring system!
-
02-15-2007, 08:53 AM #2782Developer

- Registriert seit
- Oct 2005
- Ort
- Dubuque
- Beiträge
- 423
- Points
- 12.154
- Level
- 72
- My Mood
-
- Downloads
- 1
- Uploads
- 0
itoa won't work in Linux/Cygwin because it's not ANSI C so their stdlib doesn't have it.
If you really need itoa though, like if you are working with non-base 10 numbers, you can just write your own and include it in your program.
Code:/** * Ansi C "itoa" based on Kernighan & Ritchie's "Ansi C" */ void strreverse(char* begin, char* end) { char aux; while(end>begin) aux=*end, *end--=*begin, *begin++=aux; } void itoa(int value, char* str, int base) { static char num[] = "0123456789abcdefghijklmnopqrstuvwxyz"; char* wstr=str; int sign; // Validate base if (base<2 || base>35){ *wstr='\0'; return; } // Take care of sign if ((sign=value) < 0) value = -value; // Conversion. Number is reversed. do *wstr++ = num[value%base]; while(value/=base); if(sign<0) *wstr++='-'; *wstr='\0'; // Reverse string strreverse(str,wstr-1); }Geändert von jsharrad (02-15-2007 um 09:45 AM Uhr)
-
02-15-2007, 10:44 AM #2783Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
how do you instal the psp-newlib
the normal
./bootstrap; ./configure; make; make install
isnt working
-
02-15-2007, 12:35 PM #2784QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- Australia - A.C.T.
- Beiträge
- 1.517
- Points
- 9.253
- Level
- 64
- Downloads
- 0
- Uploads
- 0
can some plz give me a hello world exemple, that would be great because i don't realy understand what you mean by use the text blitter from devhook.
Zitat von MaTiAz
Spoiler for LOL:
-
02-15-2007, 01:29 PM #2785Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
just download the source and you will see
-
02-15-2007, 01:30 PM #2786QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- Australia - A.C.T.
- Beiträge
- 1.517
- Points
- 9.253
- Level
- 64
- Downloads
- 0
- Uploads
- 0
where can i download the source?
Spoiler for LOL:
-
02-15-2007, 09:50 PM #2787Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
it is within the devhook SDK
-
02-15-2007, 10:22 PM #2788QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
hello, guys, I'm pretty new to C so please go easy on me (or not, what ever is cool) im trying to compile using Dev-CPP but when I do i get but one error
as you might see, im just trying to compile one of the examples in the SDK, it DOES compile from command line so I'm pretty sure my environment is set up right, any suggestions?Code:*** No rule to make target `main.o', needed by `irda.elf'. Stop.
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
02-15-2007, 10:32 PM #2789Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
there isnt a main.c
-
02-15-2007, 10:50 PM #2790QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
mmm, weird, maybe Cygwin cant see it from Dev-CPP or something... Thanks hallo007
EDIT sweet, got it to work, (stupid me, didn't have the project.dev in the same directory as the main.c and makefile. just draged and droped that in, made sure the that Dev-CPP could find the makefile again, hit the compile and boom, got an eboot (and others) thanks again Hallo007
-= Double Post =-
here I go again with another crazy n00b question...
im trying to follow this tut here...http://www.psp-programming.com/tutorials/c/lesson04.htm
and i need to download the zlib and libpng using cygwin and
svn checkout svn://svn.pspdev.org/psp/trunk/libpng
command but cygwin doesn't seem to reconize the svn command, is there any other place i can get these two libraries?Geändert von BlackShark (02-15-2007 um 11:45 PM Uhr) Grund: Automerged Doublepost
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:


LinkBack URL
About LinkBacks
Mit Zitat antworten


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