| View previous topic :: View next topic |
| Author |
Message |
GlennNZ
Joined: 13 Jan 2007 Posts: 25
|
Posted: Sat Mar 10, 2007 2:54 pm Post subject: Using lighting and colours with pspgl |
|
|
I'm not sure if pspgl supports it but I'm trying to use the following code to create all the light induced shades on my model.
| Code: |
glShadeModel(GL_SMOOTH);
//Set up lighting
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_NORMALIZE);
|
I'm expecting my model to be coloured according to what I set using glColor but instead I get lots of shades of gray. It works when I run it in Linux though.
Does pspgl support GL_COLOR_MATERIAL? If not, what should I use instead? No lighting is not nice.
Cheers
Glenn |
|
| Back to top |
|
 |
sg57
Joined: 14 Oct 2005 Posts: 154
|
Posted: Sun Mar 11, 2007 11:37 pm Post subject: |
|
|
| Im having the same problem. Im going to experiement around. Tell me if you get it working as well ;) |
|
| Back to top |
|
 |
adrahil
Joined: 16 Mar 2006 Posts: 277
|
Posted: Mon Mar 12, 2007 12:48 am Post subject: |
|
|
I do not do PSPGL, but just checking the sources out gives an answer:
| Code: | case GL_COLOR_MATERIAL:
case GL_RESCALE_NORMAL:
case GL_POLYGON_OFFSET_FILL:
case GL_VERTEX_ARRAY:
case GL_NORMAL_ARRAY:
case GL_COLOR_ARRAY:
case GL_TEXTURE_COORD_ARRAY:
case GL_MULTISAMPLE:
case GL_SAMPLE_ALPHA_TO_COVERAGE:
case GL_SAMPLE_ALPHA_TO_ONE:
case GL_SAMPLE_COVERAGE:
default:
GLERROR(GL_INVALID_ENUM);
return;
} |
GL_COLOR_MATERIAL is not supported :)
GL_NORMALIZE is not implemented either... Just a break into the abyss...
How to solve these problems? Use Gu/Gum :) |
|
| Back to top |
|
 |
danzel
Joined: 04 Nov 2005 Posts: 182
|
Posted: Mon Mar 12, 2007 6:36 am Post subject: |
|
|
Or fix PSPGL :)
On another note:
Are you in New Zealand GlennNZ?
I'm in Hamilton myself :) |
|
| Back to top |
|
 |
sg57
Joined: 14 Oct 2005 Posts: 154
|
Posted: Mon Mar 12, 2007 6:51 am Post subject: |
|
|
| Is there a way around it? Or would I have to disable lighting when drawing models with colors :-\ |
|
| Back to top |
|
 |
GlennNZ
Joined: 13 Jan 2007 Posts: 25
|
Posted: Mon Mar 12, 2007 11:18 am Post subject: |
|
|
| adrahil wrote: | I do not do PSPGL, but just checking the sources out gives an answer:
GL_COLOR_MATERIAL is not supported :)
GL_NORMALIZE is not implemented either... Just a break into the abyss...
How to solve these problems? Use Gu/Gum :) |
Yeah, I saw that but was hoping for a workaround. I'm starting to think that texture mapping is the only solution (I'm not geeky enough to add to pspgl). I was trying to stay away from GU and GUM so I could keep my code as cross platform as possible but it looks like I have little choice if I'm to make a decent app. I'm currently using SDL + OpenGL.
Is it possible to do SDL + GU/GUM?
to danzel: Yes, I'm in Auckland. Maybe your screen name should instead be daNZel |
|
| Back to top |
|
 |
sg57
Joined: 14 Oct 2005 Posts: 154
|
Posted: Tue Mar 13, 2007 10:28 am Post subject: |
|
|
So there is no wayaround it? :(
I made a 3d break out clone, and the ball emits light with a 0.2 attentuation. The walls are gray so they are affected by the balls light perfectly. But the bricks and paddel, both not being gray, dont change whatsoever when disabling lighting when rendierng them since color_material isnt implemented. It doesnt lookawful, but hte lighting looks great on windows opengl.
One thing im looking into is to use fog, have its origin be the ball, color be black or gray, and id judge the density and distance appropriatly, and this should replicate it...
What do you think? I rather not move to GU, mainly because i love the portability. I can develope a game on windows, port it to the PSP, as ive done here. |
|
| Back to top |
|
 |
adrahil
Joined: 16 Mar 2006 Posts: 277
|
Posted: Wed Mar 14, 2007 1:29 am Post subject: |
|
|
| Fog is working nicely in Gu, with VFPU optimisations :3 And, to someone knowledgeable porting from OpenGL to Gu shouldn't be a problem, as the logic is the same, only the syntax changes... |
|
| Back to top |
|
 |
GlennNZ
Joined: 13 Jan 2007 Posts: 25
|
Posted: Sun Dec 20, 2009 11:57 am Post subject: The solution. |
|
|
Yes, I'm guilty of pulling this thread out of the abyss, but I have an excuse.
There is a way to work with materials using pspgl and for some reason I never posted the solution here. After breaking my PSP build a few months ago after a refactor, I came to this thread thinking I'd posted that solution. Turns out I didn't so now that I've only just figured out the solution, I've come to post it.
In order to use materials you have to use something like
| Code: |
GLfloat materialColour[4] = {1.0f, 0.0f, 0.0f, 1.0f};
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, materialColour);
|
The catch is that you have to enable lighting and disable blending i.e.
| Code: |
glEnable(GL_LIGHTING);
glDisable(GL_BLEND);
|
If blending is enabled, the model ends up being totally transparent. If lighting is disabled, the model turns white.
While I'm at it, another quirk of PSPGL is that when you use blending (such as with a texture with transparency) you have to disable lighting.
Cheers. |
|
| Back to top |
|
 |
|