I'm trying to get the first (2nd) of NeHe's OpenGL tutorials, to compile for PSP, using the PSPGL libs... Right now I will post my Code, Makefile, and compiling error. I have been unable to find a tutorial on this, so as of right now, I'm just winging it, and I hope to write some sort of documentation about this in the future so any help is much appreciated.
main.c
Code: Select all
/* An attempt at OpenGL on the PSP */
#include<pspkernel.h>
#include<pspdebug.h>
#include<pspdisplay.h>
#include<pspctrl.h>
#include<pspgu.h>
#include<stdio.h>
#include<GL/gl.h>
#include<GL/glu.h>
#include<GL/glut.h>
#include<GL/glext.h>
int i = 0;
int window;
PSP_MODULE_INFO("PSPGL Example",0,1,1);
#define printf pspDebugScreenPrintf
/* 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 ReSizeGLScene(GLsizei width, GLsizei height){
if(height == 0){
height=1;
}
glViewport(0, 0, width, height);//Reset the Current Viewport
glMatrixMode(GL_PROJECTION); //select the Projection Maxtrix
glLoadIdentity(); //Reset the Projection Matrix
// Calculate the Aspect Ratio of the Window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW); //Select the Modelview Matrix
//glLoadIdentity(); //Reset the Modelview Matrix
}
int InitGL(int Width, int Height){ //Setup for OpenGL goes here
glShadeModel(GL_SMOOTH); //enable smooth shading
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //Black Background
glClearDepth(1.0f); //depth bugger setup
glEnable(GL_DEPTH_TEST); //enables Depth Testing
glDepthFunc(GL_LEQUAL); //the type of depth test to do
//glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //really nice perspective calculations
glMatrixMode(GL_VIEW_PSP);
glLoadIdentity(); // Reset The Projection Matrix
gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f); // Calculate The Aspect Ratio Of The Window
glMatrixMode(GL_VIEW_PSP);
// return TRUE; //initialization went ok
}
int DrawGLScene(GLvoid){ //Here's where we do all the drawing
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen and the depth buffer
glLoadIdentity(); //reset the current modelview matrix
glTranslatef(-1.5f,0.0f,-6.0f); //move left 1.5 units and into the screen 6.0
glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 1.0f, 0.0f); //top
glVertex3f(-1.0f,-1.0f, 0.0f); //bottom left
glVertex3f( 1.0f,-1.0f, 0.0f); //bottom right
glEnd();
glTranslatef(3.0f,0.0f,0.0f); //move right 3 units
glBegin(GL_QUADS);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glEnd();
glutSwapBuffers();
//return TRUE; //Everything went ok
}
int main(int argc, char **argv){
pspDebugScreenInit();
SetupCallbacks();
glutInit(&argc, argv);
/* Select type of Display mode:
Double buffer
RGBA color
Alpha components supported
Depth buffer */
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);
/* get a 640 x 480 window */
glutInitWindowSize(480, 272);
/* the window starts at the upper left corner of the screen */
glutInitWindowPosition(0, 0);
/* Open a window */
window = glutCreateWindow("Jeff Molofee's GL Code Tutorial ... NeHe '99");
/* Register the function to do all our OpenGL drawing. */
glutDisplayFunc(&DrawGLScene);
/* Go fullscreen. This is as soon as possible. */
glutFullScreen();
/* Even if there are no events, redraw our gl scene. */
glutIdleFunc(&DrawGLScene);
/* Register the function called when our window is resized. */
glutReshapeFunc(&ReSizeGLScene);
/* Register the function called when the keyboard is pressed. */
/* Initialize our window. */
InitGL(480, 272);
/* Start Event Processing Engine */
glutMainLoop();
while(1){
pspDebugScreenClear();
for(i=0; i<5; i++) {
sceDisplayWaitVblankStart();
}
}
sceKernelSleepThread();
//destroy gl Window
glutDestroyWindow(window);
return 0;
}
Code: Select all
TARGET = pspgl
OBJS = main.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lpspgu -pspgl -lz -lm
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Image Example
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Code: Select all
linux:/home/jesusxp/development/psp/projects/gl_ex # make kxploit
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o main.o main.c
main.c: In function ‘main’:
main.c:128: warning: passing argument 1 of ‘glutDisplayFunc’ from incompatible pointer type
main.c:134: warning: passing argument 1 of ‘glutIdleFunc’ from incompatible pointer type
main.c: In function ‘InitGL’:
main.c:79: warning: control reaches end of non-void function
main.c: In function ‘DrawGLScene’:
main.c:103: warning: control reaches end of non-void function
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/pspdev/psp/sdk/lib main.o -lpspgu -pspgl -lz -lm -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o pspgl.elf
psp-gcc: unrecognized option '-pspgl'
main.o: In function `ReSizeGLScene':
main.c:(.text+0xf0): undefined reference to `glViewport'
main.c:(.text+0xf8): undefined reference to `glMatrixMode'
main.c:(.text+0x100): undefined reference to `glLoadIdentity'
main.c:(.text+0x144): undefined reference to `gluPerspective'
main.c:(.text+0x15c): undefined reference to `glMatrixMode'
main.c:(.text+0x178): undefined reference to `glViewport'
main.c:(.text+0x180): undefined reference to `glMatrixMode'
main.c:(.text+0x188): undefined reference to `glLoadIdentity'
main.c:(.text+0x1cc): undefined reference to `gluPerspective'
main.c:(.text+0x1e4): undefined reference to `glMatrixMode'
main.o: In function `InitGL':
main.c:(.text+0x208): undefined reference to `glShadeModel'
main.c:(.text+0x220): undefined reference to `glClearColor'
main.c:(.text+0x230): undefined reference to `glClearDepth'
main.c:(.text+0x238): undefined reference to `glEnable'
main.c:(.text+0x240): undefined reference to `glDepthFunc'
main.c:(.text+0x248): undefined reference to `glMatrixMode'
main.c:(.text+0x250): undefined reference to `glLoadIdentity'
main.c:(.text+0x290): undefined reference to `gluPerspective'
main.c:(.text+0x2ac): undefined reference to `glMatrixMode'
main.o: In function `DrawGLScene':
main.c:(.text+0x2c4): undefined reference to `glClear'
main.c:(.text+0x2cc): undefined reference to `glLoadIdentity'
main.c:(.text+0x2e4): undefined reference to `glTranslatef'
main.c:(.text+0x2ec): undefined reference to `glBegin'
main.c:(.text+0x304): undefined reference to `glVertex3f'
main.c:(.text+0x31c): undefined reference to `glVertex3f'
main.c:(.text+0x32c): undefined reference to `glVertex3f'
main.c:(.text+0x334): undefined reference to `glEnd'
main.c:(.text+0x348): undefined reference to `glTranslatef'
main.c:(.text+0x350): undefined reference to `glBegin'
main.c:(.text+0x360): undefined reference to `glVertex3f'
main.c:(.text+0x370): undefined reference to `glVertex3f'
main.c:(.text+0x380): undefined reference to `glVertex3f'
main.c:(.text+0x390): undefined reference to `glVertex3f'
main.c:(.text+0x398): undefined reference to `glEnd'
main.c:(.text+0x3ac): undefined reference to `glutSwapBuffers'
main.o: In function `main':
main.c:(.text+0x3d8): undefined reference to `glutInit'
main.c:(.text+0x3e0): undefined reference to `glutInitDisplayMode'
main.c:(.text+0x3ec): undefined reference to `glutInitWindowSize'
main.c:(.text+0x3f8): undefined reference to `glutInitWindowPosition'
main.c:(.text+0x40c): undefined reference to `glutCreateWindow'
main.c:(.text+0x41c): undefined reference to `glutDisplayFunc'
main.c:(.text+0x424): undefined reference to `glutFullScreen'
main.c:(.text+0x42c): undefined reference to `glutIdleFunc'
main.c:(.text+0x438): undefined reference to `glutReshapeFunc'
main.c:(.text+0x44c): undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status
make: *** [pspgl.elf] Error 1