HELP PSPGL

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
henamaral
Posts: 4
Joined: Wed Sep 14, 2005 11:57 pm
Location: Brazil, SP

HELP PSPGL

Post by henamaral »

I m trying to use this code below, But doesn't work. I don't what is wrong in the code.
Please Help me.

#include <GL/glut.h>
#include <GL/gl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

PSP_MODULE_INFO("OPEN",0,1,1);
#define printf pspDebugScreenPrintf;

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;
}



static void display(void) {

glClear (GL_COLOR_BUFFER_BIT);

glColor3f (1.0, 1.0, 1.0);

glBegin(GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();
glFlush ();
}

void init (void)
{

glClearColor (0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);

glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
int main(int argc, char* argv[]){

pspDebugScreenInit();
SetupCallbacks();
sceCtrlSetSamplingCycle(0);

glutInit(&argc,argv);
//glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutCreateWindow( __FILE__);
init ();
glutDisplayFunc(display);
glutMainLoop();

sceKernelSleepThread();

return 0;
}

Thanks
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

try putting your code in the [ code ]box.

anyway the reason it doesnt work is because. You have to through the function within the pspgl functions GLCHK(GL_CALL);

example:

Code: Select all

        GLCHK&#40;glViewport&#40;0, 0, w, h&#41;&#41;;
        GLCHK&#40;glMatrixMode&#40;GL_PROJECTION&#41;&#41;;
        GLCHK&#40;glLoadIdentity&#40;&#41;&#41;;
        GLCHK&#40;glOrtho&#40;-2, 2, -2, 2, -2, 2&#41;&#41;;
        GLCHK&#40;glMatrixMode&#40;GL_MODELVIEW&#41;&#41;;
        GLCHK&#40;glLoadIdentity&#40;&#41;&#41;;
check out the pspgl glut example. it should be all there.
There are 10 types of people in the world: Those who understand binary, and those who don't...
holger
Posts: 204
Joined: Thu Aug 18, 2005 10:57 am

Post by holger »

right now single-buffer displays are not supported, the flag is ignored. Call glutSwapBuffers().

btw: does anybody needs single-buffer displays? is there any need to implement it?
henamaral
Posts: 4
Joined: Wed Sep 14, 2005 11:57 pm
Location: Brazil, SP

Post by henamaral »

Thanks Thanhda, I will go try to do this.
henamaral
Posts: 4
Joined: Wed Sep 14, 2005 11:57 pm
Location: Brazil, SP

Post by henamaral »

I try to use this code, But Doesn't work too.


#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <GL/glut.h>


PSP_MODULE_INFO("Test", 0, 1, 1);

// printf is easier to type than pspDebugScreenPrintf
#define printf pspDebugScreenPrintf

extern void __psp_log (const char *fmt, ...);

/* enable GLerror logging to "ms0:/log.txt" */
#if 1
#define GLCHK(x) \
do { \
GLint errcode; \
x; \
errcode = glGetError(); \
if (errcode != GL_NO_ERROR) { \
__psp_log("%s (%d): GL error 0x%04x\n", \
__FUNCTION__, __LINE__, \
(unsigned int) errcode); \
} \
} while (0)
#else
#define GLCHK(x) x
#endif
/******* end of PSP specific debugging *************************************/
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;

cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);

sceKernelSleepThreadCB();

return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;

thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}

return thid;
}

void quad()
{
GLCHK(glBegin(GL_QUADS));
GLCHK(glColor3f( 1.0f, 0.0f, 0.0f ));
GLCHK(glVertex2f( 0.0f, 1.0f)); // Top Left
GLCHK(glVertex2f( 1.0f, 1.0f)); // Top Right
GLCHK(glVertex2f( 1.0f, 0.0f)); // Bottom Right
GLCHK(glVertex2f( 0.0f, 0.0f)); // Bottom Left
GLCHK(glEnd());
}

void draw()
{

GLCHK(glClearColor( 0, 0, 0, 0 ));
GLCHK(glClear ( GL_COLOR_BUFFER_BIT ));
GLCHK(glPushMatrix());
GLCHK(glColor3f( 0.0f, 0.0f, 1.0f ));
GLCHK(glTranslatef(-0.5, -0.5, 0.0));
GLCHK(quad());
GLCHK(glPopMatrix());
GLCHK(glutSwapBuffers());
}


int main(int argc, char* argv[]) {


pspDebugScreenInit();
SetupCallbacks();

sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);

glutInit(&argc, argv);
glutCreateWindow( __FILE__ );
glutDisplayFunc(draw);
glutMainLoop();



sceKernelSleepThread();

return 0;

}


What is wrong now?
Please
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

please use the code function to post your code. have you tried compiling the sample code. it should be located in pspdev/psp/sdk/trunk/pspgl/glut-test/ try compiling that. see if it works. if not then you did not install it correctly. use svn to get the lastest version of the pspsdk.
There are 10 types of people in the world: Those who understand binary, and those who don't...
Post Reply