forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Update PSPGL?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Sun Mar 16, 2008 7:55 pm    Post subject: Update PSPGL? Reply with quote

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!
Back to top
View user's profile Send private message
hlide



Joined: 10 Sep 2006
Posts: 750

PostPosted: Sun Mar 16, 2008 10:33 pm    Post subject: Re: Update PSPGL? Reply with quote

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 :
Quote:
/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:
typedef unsigned uint32_t;

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

#if defined(__GNUC__) && (__GCCV < __GCC_VERSION(4,1,0))
typedef unsigned uint32_t;
#endif

I got a new error :
Quote:
pspgl_misc.h:23: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'lg2'

Code:
static inline uint32_t lg2(unsigned int x) __attribute__((const,always_inline));
static inline uint32_t lg2(unsigned int x)
{
   if (__builtin_constant_p(x))
      switch(x) {
      case 1:      return 0;
      case 2:      return 1;
      case 4:      return 2;
      case 8:      return 3;
      case 16:   return 4;
      case 32:   return 5;
      case 64:   return 6;
      case 128:   return 7;
      case 256:   return 8;
      case 512:   return 9;
      case 1024:   return 10;
      case 2048:   return 11;
      case 4096:   return 12;
      case 8192:   return 13;
      case 16384:   return 14;
      case 32768:   return 15;
      case 65536:   return 16;
      }

   return 31 - __builtin_clz(x);
}


but now If I change
Quote:
typedef unsigned uint32_t;

into
Quote:
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)
Back to top
View user's profile Send private message
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Mon Mar 17, 2008 4:29 am    Post subject: Reply with quote

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

Code:
#ifndef __pspgl_misc_h__
#define __pspgl_misc_h__

#include <sys/types.h>

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

#if defined(__GNUC__) && (__GCCV < __GCC_VERSION(4,1,0))
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(void *p, size_t size);

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

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

        return 31 - __builtin_clz(x);
}

And error:
Quote:
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!
Back to top
View user's profile Send private message
hlide



Joined: 10 Sep 2006
Posts: 750

PostPosted: Mon Mar 17, 2008 5:08 am    Post subject: Reply with quote

sorry, i wasn't clear.


replace

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

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


with

Code:
typedef unsigned long uint32_t;
Back to top
View user's profile Send private message
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Mon Mar 17, 2008 5:33 am    Post subject: Reply with quote

hlide wrote:
sorry, i wasn't clear.


replace

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

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


with

Code:
typedef unsigned long uint32_t;

Works like a charm,thanks! :D:D:D
_________________
My projects:
PSPSnake
Mandelbrot Fractal Generator
Shoot4Fun
BlowUp!
Back to top
View user's profile Send private message
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Mon Mar 17, 2008 6:48 am    Post subject: Reply with quote

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:
glFogf(GL_FOG_DENSITY, 0.35f);

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
Quote:
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!
Back to top
View user's profile Send private message
hlide



Joined: 10 Sep 2006
Posts: 750

PostPosted: Mon Mar 17, 2008 6:56 am    Post subject: Reply with quote

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:
glFogf(GL_FOG_DENSITY, 0.35f);

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
Quote:
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:

glFogf(GL_FOG_MODE, GL_LINEAR);
glFogf(GL_FOG_START, near_value);
glFogf(GL_FOG_END, far_value);

anything else returns GL_INVALID_ENUM as it is your case.
Back to top
View user's profile Send private message
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Mon Mar 17, 2008 6:58 am    Post subject: Reply with quote

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:
glFogf(GL_FOG_DENSITY, 0.35f);

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
Quote:
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:

glFogf(GL_FOG_MODE, GL_LINEAR);
glFogf(GL_FOG_START, near_value);
glFogf(GL_FOG_END, far_value);

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!
Back to top
View user's profile Send private message
hlide



Joined: 10 Sep 2006
Posts: 750

PostPosted: Mon Mar 17, 2008 7:00 am    Post subject: Reply with quote

no idea, i'm not a fog expert :) nor an opengl expert.
Back to top
View user's profile Send private message
jean



Joined: 05 Jan 2008
Posts: 489

PostPosted: Mon Mar 17, 2008 10:10 am    Post subject: Reply with quote

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:
Quote:
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
Back to top
View user's profile Send private message
hlide



Joined: 10 Sep 2006
Posts: 750

PostPosted: Mon Mar 17, 2008 10:48 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Tue Mar 18, 2008 3:03 am    Post subject: Reply with quote

Code from glFog.c:
Code:
void glFogf (GLenum pname, GLfloat param)
{
   float distance;
   GLenum error;

   error = GL_INVALID_VALUE;
   switch (pname) {
   case GL_FOG_MODE:
      if (param != GL_LINEAR)
         goto out_error;
      break;

   case GL_FOG_START:
      pspgl_curctx->fog.near = param;
      distance = pspgl_curctx->fog.far - pspgl_curctx->fog.near;
      if (unlikely(distance == 0))
         goto out_error;
      distance = 1.0f / distance;
      sendCommandf(CMD_FOG_NEAR, distance);
      break;

   case GL_FOG_END:
      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 (the fog is "inversed")
      distance = pspgl_curctx->fog.far - pspgl_curctx->fog.near;
      if (unlikely(distance == 0))
         goto out_error;
      distance = 1.0f / distance;
      sendCommandf(CMD_FOG_NEAR, distance);
      // @@@ end modif by Edorul
      sendCommandf(CMD_FOG_FAR, pspgl_curctx->fog.far);
      break;
   /**
   case XXXX:
      pspgl_curctx->fog.XXXXX = param;
      sendCommandf(248, ??fog type??);
      break;
    */
   default:
      error = GL_INVALID_ENUM;
      goto out_error;
   }

   return;

  out_error:
   GLERROR(error);
}
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!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group