 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
henamaral
Joined: 14 Sep 2005 Posts: 4 Location: Brazil, SP
|
Posted: Thu Sep 22, 2005 12:06 pm Post subject: HELP PSPGL |
|
|
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 |
|
| Back to top |
|
 |
Thanhda

Joined: 09 Apr 2005 Posts: 331 Location: Canada
|
Posted: Thu Sep 22, 2005 2:23 pm Post subject: |
|
|
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: |
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());
|
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... |
|
| Back to top |
|
 |
holger
Joined: 18 Aug 2005 Posts: 204
|
Posted: Thu Sep 22, 2005 5:17 pm Post subject: |
|
|
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? |
|
| Back to top |
|
 |
henamaral
Joined: 14 Sep 2005 Posts: 4 Location: Brazil, SP
|
Posted: Thu Sep 22, 2005 10:18 pm Post subject: |
|
|
| Thanks Thanhda, I will go try to do this. |
|
| Back to top |
|
 |
henamaral
Joined: 14 Sep 2005 Posts: 4 Location: Brazil, SP
|
Posted: Fri Sep 23, 2005 11:41 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Thanhda

Joined: 09 Apr 2005 Posts: 331 Location: Canada
|
Posted: Fri Sep 23, 2005 2:08 pm Post subject: |
|
|
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... |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|