pspgl test code not working

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
asphodeli
Posts: 20
Joined: Sun Jun 29, 2008 2:44 pm
Location: Singapore

pspgl test code not working

Post by asphodeli »

Hi,
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" &#123;
//#include "glchk.h"
#include <GLES/egl.h>
#include <GLES/gl.h>
&#125;

//extern unsigned char logo_start&#91;&#93;;

//PSP module info
PSP_MODULE_INFO&#40;"test", 0, 1, 1&#41;;
//Cause 640k ought to be enough for everybody?
PSP_HEAP_SIZE_KB&#40;-640&#41;;
//Set thread attribute to user-land and enable VFPU
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER|PSP_THREAD_ATTR_VFPU&#41;;

struct Vertex
&#123;
	float u, v;
	unsigned int color;
	float x,y,z;
&#125;;


static const
struct Vertex __attribute__&#40;&#40;aligned&#40;16&#41;&#41;&#41; vertices &#91;12*3&#93; =
&#123;
	&#123; 0, 0, 0xff7f0000,-1,-1, 1 &#125;, // 0
	&#123; 1, 0, 0xff7f0000,-1, 1, 1 &#125;, // 4
	&#123; 1, 1, 0xff7f0000, 1, 1, 1 &#125;, // 5

	&#123; 0, 0, 0xff7f0000,-1,-1, 1 &#125;, // 0
	&#123; 1, 1, 0xff7f0000, 1, 1, 1 &#125;, // 5
	&#123; 0, 1, 0xff7f0000, 1,-1, 1 &#125;, // 1

	&#123; 0, 0, 0xff7f0000,-1,-1,-1 &#125;, // 3
	&#123; 1, 0, 0xff7f0000, 1,-1,-1 &#125;, // 2
	&#123; 1, 1, 0xff7f0000, 1, 1,-1 &#125;, // 6

	&#123; 0, 0, 0xff7f0000,-1,-1,-1 &#125;, // 3
	&#123; 1, 1, 0xff7f0000, 1, 1,-1 &#125;, // 6
	&#123; 0, 1, 0xff7f0000,-1, 1,-1 &#125;, // 7

	&#123; 0, 0, 0xff007f00, 1,-1,-1 &#125;, // 0
	&#123; 1, 0, 0xff007f00, 1,-1, 1 &#125;, // 3
	&#123; 1, 1, 0xff007f00, 1, 1, 1 &#125;, // 7

	&#123; 0, 0, 0xff007f00, 1,-1,-1 &#125;, // 0
	&#123; 1, 1, 0xff007f00, 1, 1, 1 &#125;, // 7
	&#123; 0, 1, 0xff007f00, 1, 1,-1 &#125;, // 4

	&#123; 0, 0, 0xff007f00,-1,-1,-1 &#125;, // 0
	&#123; 1, 0, 0xff007f00,-1, 1,-1 &#125;, // 3
	&#123; 1, 1, 0xff007f00,-1, 1, 1 &#125;, // 7

	&#123; 0, 0, 0xff007f00,-1,-1,-1 &#125;, // 0
	&#123; 1, 1, 0xff007f00,-1, 1, 1 &#125;, // 7
	&#123; 0, 1, 0xff007f00,-1,-1, 1 &#125;, // 4

	&#123; 0, 0, 0xff00007f,-1, 1,-1 &#125;, // 0
	&#123; 1, 0, 0xff00007f, 1, 1,-1 &#125;, // 1
	&#123; 1, 1, 0xff00007f, 1, 1, 1 &#125;, // 2

	&#123; 0, 0, 0xff00007f,-1, 1,-1 &#125;, // 0
	&#123; 1, 1, 0xff00007f, 1, 1, 1 &#125;, // 2
	&#123; 0, 1, 0xff00007f,-1, 1, 1 &#125;, // 3

	&#123; 0, 0, 0xff00007f,-1,-1,-1 &#125;, // 4
	&#123; 1, 0, 0xff00007f,-1,-1, 1 &#125;, // 7
	&#123; 1, 1, 0xff00007f, 1,-1, 1 &#125;, // 6

	&#123; 0, 0, 0xff00007f,-1,-1,-1 &#125;, // 4
	&#123; 1, 1, 0xff00007f, 1,-1, 1 &#125;, // 6
	&#123; 0, 1, 0xff00007f, 1,-1,-1 &#125;, // 5
&#125;;


int done = 0;

static const EGLint attrib_list &#91;&#93; = &#123;
	EGL_RED_SIZE, 1,
	EGL_GREEN_SIZE, 1,
	EGL_BLUE_SIZE, 1,
	EGL_ALPHA_SIZE, 0,
	EGL_DEPTH_SIZE, 0,
	EGL_NONE
&#125;;

int main&#40;int argc, char* argv&#91;&#93;&#41;
&#123;
	setupPSP&#40;&#41;;

	EGLDisplay dpy;
	EGLConfig config;
	EGLint num_configs;
	EGLContext ctx;
	EGLSurface surface;
	GLfloat angle = 0.0f;
	SceCtrlData pad;

	//psp_log&#40;"startup\n"&#41;;

	sceCtrlSetSamplingCycle&#40;0&#41;;
	sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_ANALOG&#41;;

	/* pass NativeDisplay=0, we only have one screen... */
	dpy = eglGetDisplay&#40;0&#41;;
	eglInitialize&#40;dpy, NULL, NULL&#41;;

//	psp_log&#40;"EGL vendor \"%s\"\n", eglQueryString&#40;dpy, EGL_VENDOR&#41;&#41;;
//	psp_log&#40;"EGL version \"%s\"\n", eglQueryString&#40;dpy, EGL_VERSION&#41;&#41;;
//	psp_log&#40;"EGL extensions \"%s\"\n", eglQueryString&#40;dpy, EGL_EXTENSIONS&#41;&#41;;

	eglChooseConfig&#40;dpy, attrib_list, &config, 1, &num_configs&#41;;

	if &#40;num_configs == 0&#41; &#123;
//		__pspgl_log&#40;"eglChooseConfig returned 0 configurations"&#41;;
		return 0;
	&#125;

//	psp_log&#40;"eglChooseConfige&#40;&#41; returned config 0x%04x\n", &#40;unsigned int&#41; config&#41;;

	ctx = eglCreateContext&#40;dpy, config, NULL, NULL&#41;;
	surface = eglCreateWindowSurface&#40;dpy, config, 0, NULL&#41;;
	eglMakeCurrent&#40;dpy, surface, surface, ctx&#41;;

	glDisable&#40;GL_STENCIL_TEST&#41;;
	glDisable&#40;GL_ALPHA_TEST&#41;;
	glDisable&#40;GL_SCISSOR_TEST&#41;;

	glDepthFunc&#40;GL_LEQUAL&#41;;
	glEnable&#40;GL_DEPTH_TEST&#41;;

	glFrontFace&#40;GL_CW&#41;;
	glShadeModel&#40;GL_SMOOTH&#41;;
	glEnable&#40;GL_CULL_FACE&#41;;

	glEnable&#40;GL_TEXTURE_2D&#41;;

	glViewport&#40;0, 0, 480, 272&#41;;
	glScissor&#40;0, 0, 480, 272&#41;;
	glDepthRangef&#40;0.0f, 1.0f&#41;;

	while &#40;!done&#41; &#123;
		sceCtrlReadBufferPositive&#40;&pad, 1&#41;; 

		if &#40;pad.Buttons & PSP_CTRL_CROSS&#41;
			done = 1;

		if &#40;!&#40;pad.Buttons & PSP_CTRL_CIRCLE&#41;&#41;
			angle += 1.0f;

		glClearColor&#40;pad.Lx * 1.0f/255, pad.Ly * 1.0f/255, 1.0f, 1.0f&#41;;
		glClearDepthf&#40;1.0f&#41;;
		glClear&#40;GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT&#41;;

		glMatrixMode&#40;GL_PROJECTION&#41;;
		glLoadIdentity&#40;&#41;;
		gluPerspectivef&#40;75.0f, 16.0f/9.0f, 0.5f, 1000.0f&#41;;

		glMatrixMode&#40;GL_MODELVIEW&#41;;
		glLoadIdentity&#40;&#41;;
		gluLookAtf&#40;0.0f, 0.0f, 2.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f&#41;;
		glRotatef&#40;angle * 0.79f, 1.0f, 0.0f, 0.0f&#41;;
		glRotatef&#40;angle * 0.98f, 0.0f, 1.0f, 0.0f&#41;;
		glRotatef&#40;angle * 1.32f, 0.0f, 0.0f, 1.0f&#41;;

		/* setup texture */
		glTexEnvi&#40;GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE&#41;;
		glTexParameteri&#40;GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR&#41;;
		glTexParameteri&#40;GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR&#41;;
		//glTexImage2D&#40;GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, logo_start&#41;&#41;;

		/* draw cube */
		glInterleavedArrays&#40;GL_T2F_C4UB_V3F, 0, &#40;void *&#41; vertices&#41;;
		glDrawArrays&#40;GL_TRIANGLES, 0, 12*3&#41;;

		eglSwapBuffers&#40;dpy, surface&#41;;
	&#125;

	eglTerminate&#40;dpy&#41;;
	return 0;
&#125;
Makefile:

Code: Select all

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;

TARGET = eglcube
OBJS = eglcube.o

CC = psp-g++
INCDIR = -I ../../include/ #/usr/local/pspdev/psp/include/SDL
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

PSPBIN = $&#40;PSPSDK&#41;/../bin
#CFLAGS += $&#40;shell $&#40;PSPBIN&#41;/sdl-config --cflags | sed s/-Dmain=SDL_main//&#41;
#LIBS += $&#40;shell $&#40;PSPBIN&#41;/sdl-config --libs | sed s/-lSDLmain//&#41;

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 $&#40;PSPSDK&#41;/lib/build.mak
Last edited by asphodeli on Wed Nov 19, 2008 12:19 pm, edited 1 time in total.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

First I don't think you can wrap entire includes like this:

Code: Select all

extern "C" &#123;
//#include "glchk.h"
#include <GLES/egl.h>
#include <GLES/gl.h>
&#125; 
Second, the gl/egl includes already have the extern "C" {} junk at the appropriate places, so they didn't need wrapping in the first place. Try it again after getting rid of your extern "C" {}.
asphodeli
Posts: 20
Joined: Sun Jun 29, 2008 2:44 pm
Location: Singapore

Post by asphodeli »

J.F. wrote:First I don't think you can wrap entire includes like this:

Code: Select all

extern "C" &#123;
//#include "glchk.h"
#include <GLES/egl.h>
#include <GLES/gl.h>
&#125; 
Second, the gl/egl includes already have the extern "C" {} junk at the appropriate places, so they didn't need wrapping in the first place. Try it again after getting rid of your extern "C" {}.
Have uncommented the code,changed to .c file and uncommented CC in the makefile, and it still displays an enlarged scanline psplink text and then turns off after a while
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

You're clearly not posting everything... there's no setupPSP() which is in your main file. You should also not be setting CC yourself. Just rely on the build.mak to handle all that.

If you want a version of eglcube that works with the current toolchain and libs, get my update to pspgl for TV... that has altered the demos to work.
asphodeli
Posts: 20
Joined: Sun Jun 29, 2008 2:44 pm
Location: Singapore

Post by asphodeli »

J.F. wrote:You're clearly not posting everything... there's no setupPSP() which is in your main file. You should also not be setting CC yourself. Just rely on the build.mak to handle all that.

If you want a version of eglcube that works with the current toolchain and libs, get my update to pspgl for TV... that has altered the demos to work.
Have tried out your update to pspgl with rev 2446, still no go. I'm not sure if I'm doing this right, but I have added pspDveManager.o to the OBJS and the corresponding pspDveManager.S from moonlight's TV sample code in order to resolve the error:

Code: Select all

/usr/local/pspdev/lib/gcc/psp/4.3.0/../../../../psp/lib/libGL.a&#40;eglGetDisplay.o&#41;&#58; In function `eglGetDisplay'&#58;
/root/psplibraries/build/pspgl/eglGetDisplay.c&#58;25&#58; undefined reference to `pspDveMgrCheckVideoOut'
/usr/local/pspdev/lib/gcc/psp/4.3.0/../../../../psp/lib/libGL.a&#40;eglInitialize.o&#41;&#58; In function `eglInitialize'&#58;
/root/psplibraries/build/pspgl/eglInitialize.c&#58;27&#58; undefined reference to `pspDveMgrSetVideoOut'
/root/psplibraries/build/pspgl/eglInitialize.c&#58;30&#58; undefined reference to `pspDveMgrSetVideoOut'
Additonally, here's my (somewhat trivial) setupPSP() in common.h:

Code: Select all


#include <pspkernel.h>
#ifdef PSP_BOOST_CPU
#include <psppower.h>
#endif

#ifdef PSP_ENABLE_DEBUG
#include <pspdebug.h>
#define printf pspDebugScreenPrintf
#endif


int exitCallback&#40;int arg1, int arg2, void *common&#41;
&#123;

	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;

int callbackThread&#40;SceSize args, void *argp&#41;
&#123;
	int cbid;

	cbid = sceKernelCreateCallback&#40;"Exit Callback", exitCallback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;

	sceKernelSleepThreadCB&#40;&#41;;

	return 0;
&#125;

int setupCallbacks&#40;void&#41;
&#123;
	int thid = 0;

	thid = sceKernelCreateThread&#40;"update_thread", callbackThread, 0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41;
	&#123;
		sceKernelStartThread&#40;thid, 0, 0&#41;;
	&#125;

	return thid;
&#125;

int setupPSP&#40;void&#41;
&#123;
  
   #ifdef PSP_BOOST_CPU
    scePowerSetClockFrequency&#40;333, 333, 166&#41;;
   #endif

   // setup callbacks
   setupCallbacks&#40;&#41;;

   #ifdef PSP_ENABLE_DEBUG
    pspDebugScreenInit&#40;&#41;;
   #endif
   
   return 0;
&#125;
[/code]
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Well, the setPSP looks okay. You know, you don't need to do that for testing. If in doubt, you could just not call setupPSP to see what happens.

All of my tests (and most apps) start with

Code: Select all

   pspDebugScreenInit&#40;&#41;;
   pspDebugScreenSetBackColor&#40;0xFF000000&#41;;
   pspDebugScreenSetTextColor&#40;0xFFFFFFFF&#41;;
With lots of pspDebugScreenPrintf()s scattered around.

The SDL/PSPGL with TV support requires the dve manager code from D_A's example for TV coding. There's a pspDveManager.S file that needs to be included with the project to compile. That's why Heimdall is making two separate dev packages for SDL/PSPGL on his Win32 dev package thingy.
asphodeli
Posts: 20
Joined: Sun Jun 29, 2008 2:44 pm
Location: Singapore

Post by asphodeli »

J.F. wrote:Well, the setPSP looks okay. You know, you don't need to do that for testing. If in doubt, you could just not call setupPSP to see what happens.

All of my tests (and most apps) start with

Code: Select all

   pspDebugScreenInit&#40;&#41;;
   pspDebugScreenSetBackColor&#40;0xFF000000&#41;;
   pspDebugScreenSetTextColor&#40;0xFFFFFFFF&#41;;
With lots of pspDebugScreenPrintf()s scattered around.

The SDL/PSPGL with TV support requires the dve manager code from D_A's example for TV coding. There's a pspDveManager.S file that needs to be included with the project to compile. That's why Heimdall is making two separate dev packages for SDL/PSPGL on his Win32 dev package thingy.
I'm using pspDveManager.S from dve_sample.zip provided by D_A and included it in the Makefile, and I'm still getting auto-shutdown (pressing the PSP_CTRL_CROSS button doesn't exit the app gracefully as well) on my PSP even when I comment out everything in main(). I'm really mystified as to why it doesn't work normally.

EDIT: Finally the code works, seems to be a problem with the functions glTexEnvi and glTexParameteri, probably because there are no textures loaded.

Code: Select all

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include "common.h"
//#include "glchk.h"
#include <GLES/egl.h>
#include <GLES/gl.h>

//PSP module info
PSP_MODULE_INFO&#40;"eglcube", 0, 1, 1&#41;;
//Cause 640k ought to be enough for everybody?
PSP_HEAP_SIZE_KB&#40;-640&#41;;
//Set thread attribute to user-land and enable VFPU
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER|PSP_THREAD_ATTR_VFPU&#41;;

struct Vertex
&#123;
	float u, v;
	unsigned int color;
	float x,y,z;
&#125;;

static const
struct Vertex __attribute__&#40;&#40;aligned&#40;16&#41;&#41;&#41; vertices &#91;12*3&#93; =
&#123;
	&#123; 0, 0, 0xff7f0000,-1,-1, 1 &#125;, // 0
	&#123; 1, 0, 0xff7f0000,-1, 1, 1 &#125;, // 4
	&#123; 1, 1, 0xff7f0000, 1, 1, 1 &#125;, // 5

	&#123; 0, 0, 0xff7f0000,-1,-1, 1 &#125;, // 0
	&#123; 1, 1, 0xff7f0000, 1, 1, 1 &#125;, // 5
	&#123; 0, 1, 0xff7f0000, 1,-1, 1 &#125;, // 1

	&#123; 0, 0, 0xff7f0000,-1,-1,-1 &#125;, // 3
	&#123; 1, 0, 0xff7f0000, 1,-1,-1 &#125;, // 2
	&#123; 1, 1, 0xff7f0000, 1, 1,-1 &#125;, // 6

	&#123; 0, 0, 0xff7f0000,-1,-1,-1 &#125;, // 3
	&#123; 1, 1, 0xff7f0000, 1, 1,-1 &#125;, // 6
	&#123; 0, 1, 0xff7f0000,-1, 1,-1 &#125;, // 7

	&#123; 0, 0, 0xff007f00, 1,-1,-1 &#125;, // 0
	&#123; 1, 0, 0xff007f00, 1,-1, 1 &#125;, // 3
	&#123; 1, 1, 0xff007f00, 1, 1, 1 &#125;, // 7

	&#123; 0, 0, 0xff007f00, 1,-1,-1 &#125;, // 0
	&#123; 1, 1, 0xff007f00, 1, 1, 1 &#125;, // 7
	&#123; 0, 1, 0xff007f00, 1, 1,-1 &#125;, // 4

	&#123; 0, 0, 0xff007f00,-1,-1,-1 &#125;, // 0
	&#123; 1, 0, 0xff007f00,-1, 1,-1 &#125;, // 3
	&#123; 1, 1, 0xff007f00,-1, 1, 1 &#125;, // 7

	&#123; 0, 0, 0xff007f00,-1,-1,-1 &#125;, // 0
	&#123; 1, 1, 0xff007f00,-1, 1, 1 &#125;, // 7
	&#123; 0, 1, 0xff007f00,-1,-1, 1 &#125;, // 4

	&#123; 0, 0, 0xff00007f,-1, 1,-1 &#125;, // 0
	&#123; 1, 0, 0xff00007f, 1, 1,-1 &#125;, // 1
	&#123; 1, 1, 0xff00007f, 1, 1, 1 &#125;, // 2

	&#123; 0, 0, 0xff00007f,-1, 1,-1 &#125;, // 0
	&#123; 1, 1, 0xff00007f, 1, 1, 1 &#125;, // 2
	&#123; 0, 1, 0xff00007f,-1, 1, 1 &#125;, // 3

	&#123; 0, 0, 0xff00007f,-1,-1,-1 &#125;, // 4
	&#123; 1, 0, 0xff00007f,-1,-1, 1 &#125;, // 7
	&#123; 1, 1, 0xff00007f, 1,-1, 1 &#125;, // 6

	&#123; 0, 0, 0xff00007f,-1,-1,-1 &#125;, // 4
	&#123; 1, 1, 0xff00007f, 1,-1, 1 &#125;, // 6
	&#123; 0, 1, 0xff00007f, 1,-1,-1 &#125;, // 5
&#125;;


int done = 0;

static const EGLint attrib_list &#91;&#93; = &#123;
	EGL_RED_SIZE, 1,
	EGL_GREEN_SIZE, 1,
	EGL_BLUE_SIZE, 1,
	EGL_ALPHA_SIZE, 0,
	EGL_DEPTH_SIZE, 0,
	EGL_NONE
&#125;;

int main&#40;int argc, char* argv&#91;&#93;&#41;
&#123;
	setupPSP&#40;&#41;;
	//pspDebugScreenInit&#40;&#41;;
	//pspDebugScreenSetBackColor&#40;0xFFFFFFFF&#41;;
	//pspDebugScreenSetTextColor&#40;0x00000000&#41;;
	EGLDisplay dpy;
	EGLConfig config;
	EGLint num_configs;
	EGLContext ctx;
	EGLSurface surface;
	GLfloat angle = 0.0f;
	SceCtrlData pad;

	sceCtrlSetSamplingCycle&#40;0&#41;;
	sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_ANALOG&#41;;

	/* pass NativeDisplay=0, we only have one screen... */
	dpy = eglGetDisplay&#40;0&#41;;
	eglInitialize&#40;dpy, NULL, NULL&#41;;

//	eglChooseConfig&#40;dpy, attrib_list, &config, 1, &num_configs&#41;;

	ctx = eglCreateContext&#40;dpy, config, NULL, NULL&#41;;
	surface = eglCreateWindowSurface&#40;dpy, config, 0, NULL&#41;;
	eglMakeCurrent&#40;dpy, surface, surface, ctx&#41;;

	glDisable&#40;GL_STENCIL_TEST&#41;;
	glDisable&#40;GL_ALPHA_TEST&#41;;
	glDisable&#40;GL_SCISSOR_TEST&#41;;

	glDepthFunc&#40;GL_LEQUAL&#41;;
	glEnable&#40;GL_DEPTH_TEST&#41;;

	glFrontFace&#40;GL_CW&#41;;
	glShadeModel&#40;GL_SMOOTH&#41;;
	glEnable&#40;GL_CULL_FACE&#41;;

	glEnable&#40;GL_TEXTURE_2D&#41;;

	glViewport&#40;0, 0, 480, 272&#41;;
	glScissor&#40;0, 0, 480, 272&#41;;
	glDepthRangef&#40;0.0f, 1.0f&#41;;

	while &#40;!done&#41; &#123;
		sceCtrlReadBufferPositive&#40;&pad, 1&#41;;

		//printf&#40;"Analog X = %d ", pad.Lx&#41;;
		//printf&#40;"Analog Y = %d \n", pad.Ly&#41;;

		if &#40;pad.Buttons != 0&#41;&#123;
			if &#40;pad.Buttons & PSP_CTRL_SQUARE&#41;&#123;
				//printf&#40;"Square pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_TRIANGLE&#41;&#123;
				//printf&#40;"Triangle pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_CIRCLE&#41;&#123;
                angle += 1.0f;
				//printf&#40;"Cicle pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_CROSS&#41;&#123;
			    done = 1;
				//printf&#40;"Cross pressed \n"&#41;;
			&#125;

			if &#40;pad.Buttons & PSP_CTRL_UP&#41;&#123;
				//printf&#40;"Up pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_DOWN&#41;&#123;
				//printf&#40;"Down pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_LEFT&#41;&#123;
				//printf&#40;"Left pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_RIGHT&#41;&#123;
				//printf&#40;"Right pressed \n"&#41;;
			&#125;

			if &#40;pad.Buttons & PSP_CTRL_START&#41;&#123;
				//printf&#40;"Start pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_SELECT&#41;&#123;
				//printf&#40;"Select pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_LTRIGGER&#41;&#123;
				//printf&#40;"L-trigger pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_RTRIGGER&#41;&#123;
				//printf&#40;"R-trigger pressed \n"&#41;;
			&#125;
		&#125;

		glClearColor&#40;pad.Lx * 1.0f/255, pad.Ly * 1.0f/255, 1.0f, 1.0f&#41;;
		glClearDepthf&#40;1.0f&#41;;
		glClear&#40;GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT&#41;;

		glMatrixMode&#40;GL_PROJECTION&#41;;
		glLoadIdentity&#40;&#41;;
		gluPerspectivef&#40;75.0f, 16.0f/9.0f, 0.5f, 1000.0f&#41;;

		glMatrixMode&#40;GL_MODELVIEW&#41;;
		glLoadIdentity&#40;&#41;;
		gluLookAtf&#40;0.0f, 0.0f, 2.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f&#41;;
		glRotatef&#40;angle * 0.79f, 1.0f, 0.0f, 0.0f&#41;;
		glRotatef&#40;angle * 0.98f, 0.0f, 1.0f, 0.0f&#41;;
		glRotatef&#40;angle * 1.32f, 0.0f, 0.0f, 1.0f&#41;;

		/* setup texture */
//		glTexEnvi&#40;GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE&#41;;
//		glTexParameteri&#40;GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR&#41;;
//		glTexParameteri&#40;GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR&#41;;
		//glTexImage2D&#40;GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, logo_start&#41;&#41;;

		/* draw cube */
		glInterleavedArrays&#40;GL_T2F_C4UB_V3F, 0, &#40;void *&#41; vertices&#41;;
		glDrawArrays&#40;GL_TRIANGLES, 0, 12*3&#41;;

		eglSwapBuffers&#40;dpy, surface&#41;;
	&#125;
	eglTerminate&#40;dpy&#41;;
    sceKernelExitGame&#40;&#41;;
	return 0;
&#125;
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Stick some debug prints in the code and find where it's failing. It's called debugging - something you'll have to pick up on your own.

Comment in those debug init lines and stick a debug print right at the start (followed by sceKernelDelayThread(3*1000*1000); so you can read it). If it doesn't show, you probably have problems with your toolchain.

If it shows, move it down the lines and find where it goes boom.
Post Reply