I made a small code but did not work, the PSP crashes and restarts, or even the emulator (JPCSP) can run this example, the emulator reports the this error:
10234 [user_main] ERROR memory - write32 - Invalid memory address: 0x8AC PC = 089016C0
Below is my source:
main.cpp:
Code: Select all
/* Test SDL OpenGL support. */
#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
#define SCREEN_WIDTH 480
#define SCREEN_HEIGHT 272
static GLfloat delta = 1.0f;
static GLfloat angle;
extern "C" int main(int argc, char *argv[])
{
int done = 0;
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
{
return 1;
}
if (SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, SDL_OPENGL | SDL_FULLSCREEN) == NULL)
{
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;
}
Code: Select all
TARGET = main
PSPSDK = $(shell psp-config --pspsdk-path)
PSPPREFIX = $(shell psp-config --psp-prefix)
PSPBIN = $(PSPPREFIX)/bin
SDL_CONFIG = $(PSPBIN)/sdl-config
OBJS = $(TARGET).o
DEFAULT_CFLAGS = $(shell $(SDL_CONFIG) --cflags)
MORE_CFLAGS = -O2 -fsingle-precision-constant
CFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS)
CXXFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS) -fno-exceptions
LDFLAGS = -L$(PSPPREFIX)/lib
LIBS = -lGL -lGLU -lpspvfpu $(shell $(SDL_CONFIG) --libs) -lstdc++ -lm
EXTRA_TARGETS = EBOOT.PBP
include $(PSPSDK)/lib/build.mak