Im trying to get PSPGL to run under SDL, so that I have SDL for timer, joystick etc and PSPGL for rendering.
After searching the forums I found a code snippet that seemed to do this except when I finally got it to compile it crashes my PSP in setting up the Viewport(?). The thread link is here. the post is near the bottom of the page by mrbrown.
Here's the code
Code: Select all
/* Test SDL OpenGL support. */
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
#include "SDL_opengl.h"
#define SCREEN_WIDTH 479
#define SCREEN_HEIGHT 271
static GLfloat delta = 1.0f;
static GLfloat angle;
extern "C" {
int SDL_main() {
int done = 0;
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
{
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
if (SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, SDL_OPENGL | SDL_FULLSCREEN) == NULL)
{
fprintf(stderr, "Unable to create OpenGL screen: %s\n", SDL_GetError());
SDL_Quit();
return 1;
}
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-2, 2, -2, 2, -2, 2);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
while (!done)
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
angle += delta;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(angle * 1.32f, 0.0f, 0.0f, 1.0f);
glShadeModel(GL_SMOOTH);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glColor3f(0.0f, 0.0f, 1.0f); glVertex3f(1.0f, 0.0f, 0.0f);
glColor3f(0.0f, 1.0f, 0.0f); glVertex3f(0.0f, 1.0f, 0.0f);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(0.0f, 0.0f, 1.0f);
glEnd();
glFinish();
SDL_GL_SwapBuffers();
}
return 0;
}
}//extern "C"
I have tried calling sceGuInit() as well, as the thread where I found this code stated it was needed to get this working, but still get the same error.$ psp-addr2line -e hello.elf - f -C 0x890168c 0x0 0x890038
glViewport
/cygdrive/h/Source/pspgl/glViewport.c:9
??
??:0
SDL_Main
??:0
Have I forgotten to do something I should have?