Update PSPGL?

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

Moderators: cheriff, TyRaNiD

Post Reply
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Update PSPGL?

Post by gambiting »

Hi! Current version of PSPGL is very old,and it doesn't support lot of things from original OpenGL - but there is an updated version of pspgl,with(among other bugfixes) working fog. The problem is,that it won't compile under latest PSPSDK. It looks for gcc 4.0.2,and current version is 4.1.0. Could someone take a look at it and modify it to work on latest sdk? I don't have time,nor knowledge to do it. Thanks :D

http://edorul.free.fr/psp/pspgl_modified.rar
My projects:
PSPSnake
Mandelbrot Fractal Generator
Shoot4Fun
BlowUp!
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Re: Update PSPGL?

Post by hlide »

gambiting wrote:Hi! Current version of PSPGL is very old,and it doesn't support lot of things from original OpenGL - but there is an updated version of pspgl,with(among other bugfixes) working fog. The problem is,that it won't compile under latest PSPSDK. It looks for gcc 4.0.2,and current version is 4.1.0. Could someone take a look at it and modify it to work on latest sdk? I don't have time,nor knowledge to do it. Thanks :D

http://edorul.free.fr/psp/pspgl_modified.rar
ok, using cygwin psp-gcc 4.1.0 (oopo's pspsdk), it says :
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/stdint.h:84: error: conflicting types for 'uint32_t'
pspgl_misc.h:10: error: previous declaration of 'uint32_t' was here
if I add a test for gcc version to typedef or not uint32_t by changing

Code: Select all

typedef unsigned uint32_t;
into

Code: Select all

#define __GCC_VERSION(major,minor,patchlevel)  (((major)*10000)+(minor*100)+(patchlevel))
#define __GCCV __GCC_VERSION(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__)

#if defined&#40;__GNUC__&#41; && &#40;__GCCV < __GCC_VERSION&#40;4,1,0&#41;&#41;
typedef unsigned uint32_t;
#endif
I got a new error :
pspgl_misc.h:23: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'lg2'

Code: Select all

static inline uint32_t lg2&#40;unsigned int x&#41; __attribute__&#40;&#40;const,always_inline&#41;&#41;;
static inline uint32_t lg2&#40;unsigned int x&#41;
&#123;
	if &#40;__builtin_constant_p&#40;x&#41;&#41;
		switch&#40;x&#41; &#123;
		case 1&#58;		return 0;
		case 2&#58;		return 1;
		case 4&#58;		return 2;
		case 8&#58;		return 3;
		case 16&#58;	return 4;
		case 32&#58;	return 5;
		case 64&#58;	return 6;
		case 128&#58;	return 7;
		case 256&#58;	return 8;
		case 512&#58;	return 9;
		case 1024&#58;	return 10;
		case 2048&#58;	return 11;
		case 4096&#58;	return 12;
		case 8192&#58;	return 13;
		case 16384&#58;	return 14;
		case 32768&#58;	return 15;
		case 65536&#58;	return 16;
		&#125;

	return 31 - __builtin_clz&#40;x&#41;;
&#125;
but now If I change
typedef unsigned uint32_t;
into
typedef unsigned long uint32_t;
I'm totally able to build all the libs (I didn't ever try to test them after the build process)
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

I did everyting as you told me,but I still have the same error. First lines of my pspgl_misc.h file:

Code: Select all

#ifndef __pspgl_misc_h__
#define __pspgl_misc_h__

#include <sys/types.h>

#define __GCC_VERSION&#40;major,minor,patchlevel&#41;  &#40;&#40;&#40;major&#41;*10000&#41;+&#40;minor*100&#41;+&#40;patchlevel&#41;&#41;
#define __GCCV __GCC_VERSION&#40;__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__&#41;

#if defined&#40;__GNUC__&#41; && &#40;__GCCV < __GCC_VERSION&#40;4,1,0&#41;&#41;
typedef unsigned long uint32_t;
#endif


/* Return a pointer to uncached address space.  The pointer and size
   must both be a multiple CACHELINE_SIZE.  */
#define CACHELINE_SIZE  64
void *__pspgl_uncached&#40;void *p, size_t size&#41;;

/* Round up to a particular power of 2.  "a" evaluated multiple
   times. */
#define ROUNDUP&#40;x, a&#41;  &#40;&#40;&#40;x&#41;+&#40;&#40;a&#41;-1&#41;&#41; & ~&#40;&#40;a&#41;-1&#41;&#41;

/* log-base-2 function. */
static inline uint32_t lg2&#40;uint32_t x&#41; __attribute__&#40;&#40;const,always_inline&#41;&#41;;
static inline uint32_t lg2&#40;uint32_t x&#41;
&#123;
        if &#40;__builtin_constant_p&#40;x&#41;&#41;
                switch&#40;x&#41; &#123;
                case 1&#58;         return 0;
                case 2&#58;         return 1;
                case 4&#58;         return 2;
                case 8&#58;         return 3;
                case 16&#58;        return 4;
                case 32&#58;        return 5;
                case 64&#58;        return 6;
                case 128&#58;       return 7;
                case 256&#58;       return 8;
                case 512&#58;       return 9;
                case 1024&#58;      return 10;
                case 2048&#58;      return 11;
                case 4096&#58;      return 12;
                case 8192&#58;      return 13;
                case 16384&#58;     return 14;
                case 32768&#58;     return 15;
                case 65536&#58;     return 16;
                &#125;

        return 31 - __builtin_clz&#40;x&#41;;
&#125;
And error:
gambiting@gambiting-desktop:~/psp/pspgl_modified_v0.2$ make
psp-gcc -std=gnu99 -g -Wall -Wmissing-prototypes -Os -G0 -fsingle-precision-constant -I. -I /usr/local/pspdev/psp/include -I /usr/local/pspdev/psp/sdk/include -funit-at-a-time -MD -MF .deps/eglBindTexImage.d -c eglBindTexImage.c
In file included from pspgl_internal.h:14,
from eglBindTexImage.c:1:
pspgl_misc.h:24: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘lg2’
pspgl_misc.h:25: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘lg2’
pspgl_misc.h:52: error: expected ‘)’ before ‘x’
pspgl_misc.h:53: error: expected ‘)’ before ‘x’
pspgl_misc.h:59: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pow2’
pspgl_misc.h:60: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pow2’
pspgl_misc.h:104: error: expected specifier-qualifier-list before ‘uint32_t’
In file included from eglBindTexImage.c:1:
pspgl_internal.h:109: error: expected specifier-qualifier-list before ‘uint32_t’
pspgl_internal.h:148: error: expected specifier-qualifier-list before ‘uint32_t’
pspgl_internal.h:272: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__pspgl_context_register’
In file included from eglBindTexImage.c:1:
pspgl_internal.h: In function ‘getReg’:
pspgl_internal.h:418: error: ‘struct hwstate’ has no member named ‘ge_reg’
make: *** [eglBindTexImage.o] Error 1
gambiting@gambiting-desktop:~/psp/pspgl_modified_v0.2$
In your case adding long helped,but for me it doesn't work - any other ideas?
My projects:
PSPSnake
Mandelbrot Fractal Generator
Shoot4Fun
BlowUp!
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

sorry, i wasn't clear.


replace

Code: Select all

#define __GCC_VERSION&#40;major,minor,patchlevel&#41;  &#40;&#40;&#40;major&#41;*10000&#41;+&#40;minor*100&#41;+&#40;patchlevel&#41;&#41;
#define __GCCV __GCC_VERSION&#40;__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__&#41;

#if defined&#40;__GNUC__&#41; && &#40;__GCCV < __GCC_VERSION&#40;4,1,0&#41;&#41;
typedef unsigned long uint32_t;
#endif
with

Code: Select all

typedef unsigned long uint32_t;
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

hlide wrote:sorry, i wasn't clear.


replace

Code: Select all

#define __GCC_VERSION&#40;major,minor,patchlevel&#41;  &#40;&#40;&#40;major&#41;*10000&#41;+&#40;minor*100&#41;+&#40;patchlevel&#41;&#41;
#define __GCCV __GCC_VERSION&#40;__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__&#41;

#if defined&#40;__GNUC__&#41; && &#40;__GCCV < __GCC_VERSION&#40;4,1,0&#41;&#41;
typedef unsigned long uint32_t;
#endif
with

Code: Select all

typedef unsigned long uint32_t;
Works like a charm,thanks! :D:D:D
My projects:
PSPSnake
Mandelbrot Fractal Generator
Shoot4Fun
BlowUp!
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

I still have some problems with glFog,it's working only partialy - I can set color to it,set start and end,but I can't set density.Calling

Code: Select all

glFogf&#40;GL_FOG_DENSITY, 0.35f&#41;;
Gives me GL_INVALID_ENUM error which basically means floating point exception. Any ideas why it happens?

Edit:
here's a quote from official docs
GL_INVALID_ENUM is generated if pname is not an accepted value, or if pname is GL_FOG_MODE and params is not an accepted value.
pname is the first argument,while params is the second one.Please tell me HOW(?) could 0.35f NOT be a valid argument if a float is requested?I also tried 1.0f,0.1f,0.5f,nothing works.
My projects:
PSPSnake
Mandelbrot Fractal Generator
Shoot4Fun
BlowUp!
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

gambiting wrote:I still have some problems with glFog,it's working only partialy - I can set color to it,set start and end,but I can't set density.Calling

Code: Select all

glFogf&#40;GL_FOG_DENSITY, 0.35f&#41;;
Gives me GL_INVALID_ENUM error which basically means floating point exception. Any ideas why it happens?

Edit:
here's a quote from official docs
GL_INVALID_ENUM is generated if pname is not an accepted value, or if pname is GL_FOG_MODE and params is not an accepted value.
pname is the first argument,while params is the second one.Please tell me HOW(?) could 0.35f NOT be a valid argument if a float is requested?I also tried 1.0f,0.1f,0.5f,nothing works.
here is what glFogf can do :

Code: Select all

glFogf&#40;GL_FOG_MODE, GL_LINEAR&#41;;
glFogf&#40;GL_FOG_START, near_value&#41;;
glFogf&#40;GL_FOG_END, far_value&#41;;
anything else returns GL_INVALID_ENUM as it is your case.
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

hlide wrote:
gambiting wrote:I still have some problems with glFog,it's working only partialy - I can set color to it,set start and end,but I can't set density.Calling

Code: Select all

glFogf&#40;GL_FOG_DENSITY, 0.35f&#41;;
Gives me GL_INVALID_ENUM error which basically means floating point exception. Any ideas why it happens?

Edit:
here's a quote from official docs
GL_INVALID_ENUM is generated if pname is not an accepted value, or if pname is GL_FOG_MODE and params is not an accepted value.
pname is the first argument,while params is the second one.Please tell me HOW(?) could 0.35f NOT be a valid argument if a float is requested?I also tried 1.0f,0.1f,0.5f,nothing works.
here is what glFogf can do :

Code: Select all

glFogf&#40;GL_FOG_MODE, GL_LINEAR&#41;;
glFogf&#40;GL_FOG_START, near_value&#41;;
glFogf&#40;GL_FOG_END, far_value&#41;;
anything else returns GL_INVALID_ENUM as it is your case.
Ok,so how can I set fog density?By default it's set to 100%(1.0f) so I can't see anything only fog ;-(
My projects:
PSPSnake
Mandelbrot Fractal Generator
Shoot4Fun
BlowUp!
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

no idea, i'm not a fog expert :) nor an opengl expert.
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

Don't really know how things do work on PSP, but in "plain" openGL glFogf(GL_FOG_DENSITY, someFloatValue); should work...if it is not i begin to wonder it's not supported by pspGl "port", yet. Be sure not to mess with the second parameter; according to the first page i found googling around:
GL_INVALID_VALUE is generated if pname is GL_FOG_DENSITY, and params is negative.
Are you sure you're not passing a pointer or something like it? you could try with glFogi version....but again, don't fully thrust me: while i'm pretty good in "real" openGL, i never tried the psp version

jean
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

I read the code for glFogf and it is pretty clear this GL_FOG_DENSITY is not supported. Only GL_FOG_MODE, GL_FOG_START and GL_FOG_END are supported.
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

Code from glFog.c:

Code: Select all

void glFogf &#40;GLenum pname, GLfloat param&#41;
&#123;
	float distance;
	GLenum error;

	error = GL_INVALID_VALUE;
	switch &#40;pname&#41; &#123;
	case GL_FOG_MODE&#58;
		if &#40;param != GL_LINEAR&#41;
			goto out_error;
		break;

	case GL_FOG_START&#58;
		pspgl_curctx->fog.near = param;
		distance = pspgl_curctx->fog.far - pspgl_curctx->fog.near;
		if &#40;unlikely&#40;distance == 0&#41;&#41;
			goto out_error;
		distance = 1.0f / distance;
		sendCommandf&#40;CMD_FOG_NEAR, distance&#41;;
		break;

	case GL_FOG_END&#58;
		pspgl_curctx->fog.far = param;
		// @@@ added by Edorul by this way we can declare GL_FOG_START before GL_FOG_END
		// @@@ else we have a strange result &#40;the fog is "inversed"&#41;
		distance = pspgl_curctx->fog.far - pspgl_curctx->fog.near;
		if &#40;unlikely&#40;distance == 0&#41;&#41;
			goto out_error;
		distance = 1.0f / distance;
		sendCommandf&#40;CMD_FOG_NEAR, distance&#41;;
		// @@@ end modif by Edorul
		sendCommandf&#40;CMD_FOG_FAR, pspgl_curctx->fog.far&#41;;
		break;
	/**
	case XXXX&#58;
		pspgl_curctx->fog.XXXXX = param;
		sendCommandf&#40;248, ??fog type??&#41;;
		break;
	 */
	default&#58;
		error = GL_INVALID_ENUM;
		goto out_error;
	&#125;

	return;

  out_error&#58;
	GLERROR&#40;error&#41;;
&#125;
As you can see,there is no case switch for GL_FOG_DENSITY,so it mean's it's not supported. It kinda sucks,because now this fog looks like a wall :P
My projects:
PSPSnake
Mandelbrot Fractal Generator
Shoot4Fun
BlowUp!
Post Reply