I've found what I was doing wrong !
I was using the tiff changeBuffer function...
Printable View
I've found what I was doing wrong !
I was using the tiff changeBuffer function...
You really should change that code. As it is, it is predestinated to be slow (even on PC) and cause problems.Zitat:
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();
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:
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.
Compiles fine. I either get a black screen :( 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].Code: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();
sprintf yields no result.
Please Help :Cry: ASAP,better.
I've already charged psp 2wice for this.
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:
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();
}
Thanx for reply, be here I'll post the result. PLEASE :oZitat:
Zitat von Waterbottle
Q: i don think DebugScreenPrintf, which needs debugscreeninit, works after initgraphics.
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 ?
Zitat:
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
I tried to resolve issues:Zitat:
Zitat von tommydanger
All I get is a BLACK screeen! :Argh:Code:int main(void)
{
int i;
SceCtrlData pad;
char* tempstr= "text here";
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
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();
}
}
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 :(
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 ;)
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:
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.
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...
I think Raphael meant 16x16 subdivisions with your 256x256 texture...
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. :)
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;
}
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??
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>
}
Use the text blitter from the devhook VSHEX.Zitat:
Zitat von mafia1ft
Google misleads !! :Argh: :Argh: :Argh:Zitat:
Zitat von Mr305
sprintf() 's the king.
I guess done with scoring system!
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);
}
how do you instal the psp-newlib
the normal
./bootstrap; ./configure; make; make install
isnt working:(
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:
Zitat von MaTiAz
just download the source and you will see
where can i download the source?
it is within the devhook SDK
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.
there isnt a main.c
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 :tup:
-= 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?
http://www.dcemu.co.uk/vbulletin/showthread.php?t=25564
Scroll down and click on the link in the PSP Libs part.
Also make sur to downlaod the graphics.h and framebuffer.h pack in the lesson, serched them for hours and they were in the lesson :p
lol, thanks, I actually dled the frambuffer.h and the graphics.h but i didn't use it till now, stupid me, so do i just put them in the same directory as the main.c right? Ill go get the libs now, thanks alot!
EDIT: do i need the framebuffer.c and Graphics.c that came with it? or are they just examples?
EDIT2: ok nvm, i found out I do need them :) afnd YAY, I handcoded my first C Program, no copy and paste job!
.c and .h files must be in the same directory as your project (or can be in another directory, is the makefile is well done, but that's another story)
--------
Now for my problems : ^^
I'm experiencing PSPGL. I've been compiling and testing all the examples, and I have been modifying the celshading example, wich learnt me things like ^= (if anyone can give me precisions about that following code is welcome :
unsigned int flags = PSP_CTRL_CIRCLE | PSP_CTRL_CROSS | PSP_CTRL_SQUARE | PSP_CTRL_TRIANGLE;
flags ^= pad.Buttons;
It seems that it's like an "on/off" switch trigerred when you press the button.)
Now for the main prob :
I want to change the torus' color.
So i've fired up Paint.Net (only thing i have here) and picked up some red (#FF0000). the problem is that it shows up as blue.
The psp pallete seems to be inverted compared to that one.
I'm sure that there's something different between #FF0000 and 0xFF0000 , but how can i convert #COLOR to 0xCOLOR ?
strange prob
part in colors.cCode:dumpMenu.o: In function `setBlueTextColor':
dumpMenu.c:(.text+0x0): multiple definition of `setBlueTextColor'
colors.o:colors.c:(.text+0x0): first defined here
Code:int setBlueTextColor()
{
return(0xFF5555);
}
use in dumpMenu.c
Code:printg(20,150," Dump flash1" ,setBlueTextColor() );
colors.h
Code:int setBlueTextColor();
i dont really understand this:(
When functions are called multiple time, it can think you are trying to define them when you have missed a ;
sometime i had that error with sceDisplayWaitvBlankStart :p
Just check your line ends , check all of your ;
BTW, you could change that with simply :
#define BlueTextColor 0xFF5555
printg(20,150," Dump flash1" ,BlueTextColor );
Don't know if that works, haven't tested it but there's no reason that it fails. I've already used that
Dream_Team - I use PSPGL as my main graphics API for hte PSP, and you are corerct, the Hex value coloring system is inverted, so instead of hte reknown RGBA, it's ABGR (32-bit on both).
Ex:
Red - 0x000000FF
Green - 0x0000FF00
Blue - 0x00FF0000
Black - 0x00000000
White - 0x00FFFFFF
Also, I dont think your talking about PSPGL, as there is no torus example (that i know of) but I do know there is a GU torus example.
-= Double Post =-
DreamTeam - That would work (however I think that function requires a 32-bit color), also, that method is more efficient as macros are simply names of the code following them, that are replaced by the code following them during preprocessing, compared to a function.
Beware of this 'trap'. Macros are not automatically faster as you can easily inline small functions and the compiler is most likely to do a better optimisation then you can by hand.Zitat:
Zitat von SG57
Always assume the compiler can optimise better then you can unless you can prove otherwise (ie use a profiler).
Instead of #defines for literal values, use constants. Much easier to debug.
In his case, that would be better seeing as how it's a value:
But what if it were a function ;) Macros seem best there:Code:const blue = 0x00FF0000L
Also, this is automatically inlined when using C++ right?:Code:#define sayHello pspDebugScreenPrintf("Hello")
inlining confuses me :( What is the advantages of it? I know that 'inline' anything (functions, lines of code) might make the code faster, might make it slower. They might make the EBOOT larger, they might make it smaller. They might cause crashing, they might prevent crashing. And they might be totally irrelevant to speed . So what's the big deal? I mean, if there are soo many pros and cons, Im sure for every pro, there's a con, making it poitnless to inline in the first place... ahhh my head hurts... I need a crash course on the 'inline' keyword :( When to use it, when it's effective, example of when it's effective, etc... yaustar, Raphael, Insomniac, etc. - your view and knowledge on the 'inline' keyword maybe? sorry for being real naieve on the matter, but googling doesnt give me a fully understandable definition :(Code:if ( blah == "blah" ) { blah = "no_blah"; } else if (blah == "no_blah") { blah = "blah"; }
Ive gone so far, but I know so little... embarassing :(
NEVER EVER #INCLUDE .C FILES!!!Zitat:
Zitat von hallo007
what you think the colors.h is for:p