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
HELP PSPGL
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:
check out the pspgl glut example. it should be all there.
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(glViewport(0, 0, w, h));
GLCHK(glMatrixMode(GL_PROJECTION));
GLCHK(glLoadIdentity());
GLCHK(glOrtho(-2, 2, -2, 2, -2, 2));
GLCHK(glMatrixMode(GL_MODELVIEW));
GLCHK(glLoadIdentity());
There are 10 types of people in the world: Those who understand binary, and those who don't...
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
#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
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...