I've been trying to get a sample app from the pspgl library to compile to test if the library is working, but the PSP hangs and the screen displays an enlarged scanline psplink text and then turns off after a while
Code: Select all
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <pspctrl.h>
#include "common.h"
extern "C" {
//#include "glchk.h"
#include <GLES/egl.h>
#include <GLES/gl.h>
}
//extern unsigned char logo_start[];
//PSP module info
PSP_MODULE_INFO("test", 0, 1, 1);
//Cause 640k ought to be enough for everybody?
PSP_HEAP_SIZE_KB(-640);
//Set thread attribute to user-land and enable VFPU
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER|PSP_THREAD_ATTR_VFPU);
struct Vertex
{
float u, v;
unsigned int color;
float x,y,z;
};
static const
struct Vertex __attribute__((aligned(16))) vertices [12*3] =
{
{ 0, 0, 0xff7f0000,-1,-1, 1 }, // 0
{ 1, 0, 0xff7f0000,-1, 1, 1 }, // 4
{ 1, 1, 0xff7f0000, 1, 1, 1 }, // 5
{ 0, 0, 0xff7f0000,-1,-1, 1 }, // 0
{ 1, 1, 0xff7f0000, 1, 1, 1 }, // 5
{ 0, 1, 0xff7f0000, 1,-1, 1 }, // 1
{ 0, 0, 0xff7f0000,-1,-1,-1 }, // 3
{ 1, 0, 0xff7f0000, 1,-1,-1 }, // 2
{ 1, 1, 0xff7f0000, 1, 1,-1 }, // 6
{ 0, 0, 0xff7f0000,-1,-1,-1 }, // 3
{ 1, 1, 0xff7f0000, 1, 1,-1 }, // 6
{ 0, 1, 0xff7f0000,-1, 1,-1 }, // 7
{ 0, 0, 0xff007f00, 1,-1,-1 }, // 0
{ 1, 0, 0xff007f00, 1,-1, 1 }, // 3
{ 1, 1, 0xff007f00, 1, 1, 1 }, // 7
{ 0, 0, 0xff007f00, 1,-1,-1 }, // 0
{ 1, 1, 0xff007f00, 1, 1, 1 }, // 7
{ 0, 1, 0xff007f00, 1, 1,-1 }, // 4
{ 0, 0, 0xff007f00,-1,-1,-1 }, // 0
{ 1, 0, 0xff007f00,-1, 1,-1 }, // 3
{ 1, 1, 0xff007f00,-1, 1, 1 }, // 7
{ 0, 0, 0xff007f00,-1,-1,-1 }, // 0
{ 1, 1, 0xff007f00,-1, 1, 1 }, // 7
{ 0, 1, 0xff007f00,-1,-1, 1 }, // 4
{ 0, 0, 0xff00007f,-1, 1,-1 }, // 0
{ 1, 0, 0xff00007f, 1, 1,-1 }, // 1
{ 1, 1, 0xff00007f, 1, 1, 1 }, // 2
{ 0, 0, 0xff00007f,-1, 1,-1 }, // 0
{ 1, 1, 0xff00007f, 1, 1, 1 }, // 2
{ 0, 1, 0xff00007f,-1, 1, 1 }, // 3
{ 0, 0, 0xff00007f,-1,-1,-1 }, // 4
{ 1, 0, 0xff00007f,-1,-1, 1 }, // 7
{ 1, 1, 0xff00007f, 1,-1, 1 }, // 6
{ 0, 0, 0xff00007f,-1,-1,-1 }, // 4
{ 1, 1, 0xff00007f, 1,-1, 1 }, // 6
{ 0, 1, 0xff00007f, 1,-1,-1 }, // 5
};
int done = 0;
static const EGLint attrib_list [] = {
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
EGL_ALPHA_SIZE, 0,
EGL_DEPTH_SIZE, 0,
EGL_NONE
};
int main(int argc, char* argv[])
{
setupPSP();
EGLDisplay dpy;
EGLConfig config;
EGLint num_configs;
EGLContext ctx;
EGLSurface surface;
GLfloat angle = 0.0f;
SceCtrlData pad;
//psp_log("startup\n");
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
/* pass NativeDisplay=0, we only have one screen... */
dpy = eglGetDisplay(0);
eglInitialize(dpy, NULL, NULL);
// psp_log("EGL vendor \"%s\"\n", eglQueryString(dpy, EGL_VENDOR));
// psp_log("EGL version \"%s\"\n", eglQueryString(dpy, EGL_VERSION));
// psp_log("EGL extensions \"%s\"\n", eglQueryString(dpy, EGL_EXTENSIONS));
eglChooseConfig(dpy, attrib_list, &config, 1, &num_configs);
if (num_configs == 0) {
// __pspgl_log("eglChooseConfig returned 0 configurations");
return 0;
}
// psp_log("eglChooseConfige() returned config 0x%04x\n", (unsigned int) config);
ctx = eglCreateContext(dpy, config, NULL, NULL);
surface = eglCreateWindowSurface(dpy, config, 0, NULL);
eglMakeCurrent(dpy, surface, surface, ctx);
glDisable(GL_STENCIL_TEST);
glDisable(GL_ALPHA_TEST);
glDisable(GL_SCISSOR_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glFrontFace(GL_CW);
glShadeModel(GL_SMOOTH);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glViewport(0, 0, 480, 272);
glScissor(0, 0, 480, 272);
glDepthRangef(0.0f, 1.0f);
while (!done) {
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_CROSS)
done = 1;
if (!(pad.Buttons & PSP_CTRL_CIRCLE))
angle += 1.0f;
glClearColor(pad.Lx * 1.0f/255, pad.Ly * 1.0f/255, 1.0f, 1.0f);
glClearDepthf(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspectivef(75.0f, 16.0f/9.0f, 0.5f, 1000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAtf(0.0f, 0.0f, 2.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
glRotatef(angle * 0.79f, 1.0f, 0.0f, 0.0f);
glRotatef(angle * 0.98f, 0.0f, 1.0f, 0.0f);
glRotatef(angle * 1.32f, 0.0f, 0.0f, 1.0f);
/* setup texture */
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, logo_start));
/* draw cube */
glInterleavedArrays(GL_T2F_C4UB_V3F, 0, (void *) vertices);
glDrawArrays(GL_TRIANGLES, 0, 12*3);
eglSwapBuffers(dpy, surface);
}
eglTerminate(dpy);
return 0;
}
Code: Select all
PSPSDK=$(shell psp-config --pspsdk-path)
TARGET = eglcube
OBJS = eglcube.o
CC = psp-g++
INCDIR = -I ../../include/ #/usr/local/pspdev/psp/include/SDL
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
PSPBIN = $(PSPSDK)/../bin
#CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags | sed s/-Dmain=SDL_main//)
#LIBS += $(shell $(PSPBIN)/sdl-config --libs | sed s/-lSDLmain//)
LIBDIR = -L LIBDIR
LIBS= -lglut -lGLU -lGL -lpspgu -lstdc++ -lm -lc -lpsputility -lpspdebug -lpspge -lpspdisplay -lpspctrl -lpspsdk \
-lpspvfpu -lpspuser -lpspkernel -lpsprtc -lpsppower
#-lpsplibc
#-lGL -lpspgu -lstdc++ -lpng -lm -lc -lz -ljpeg -lpsputility -lpspvfpu -lpsprtc -lpspaudio -lpsphprm -lpspirkeyb
#-lpspsystemctrl_kernel
LDFLAGS =
PSP_FW_VERSION = 390
BUILD_PRX=1
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = eglcube
include $(PSPSDK)/lib/build.mak