DGL
https://delphigl.com/forum/

Disabling GL_COLOR_MATERIAL
https://delphigl.com/forum/viewtopic.php?f=19&t=3625
Seite 1 von 1

Autor:  BTierens [ Fr Dez 31, 2004 11:27 ]
Betreff des Beitrags:  Disabling GL_COLOR_MATERIAL

Hello,

Is this a good way to disable GL_COLOR_MATERIAL? Or is there a better way?

Code:
  1.  
  2.   glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
  3.   glEnable(GL_COLOR_MATERIAL);
  4.   //Draw coloured polygons here
  5.   glDisable(GL_COLOR_MATERIAL);
  6.   glColor3f(0.5,0.5,0.5);
  7.   glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
  8.   glEnable(GL_COLOR_MATERIAL);
  9.   glDisable(GL_COLOR_MATERIAL);
  10.   //Draw textured polygons here
  11.  


Doing the following doesn't works because when calling glEnable(GL_COLOR_MATERIAL), OpenGL affects the last know color to the last known material.

Code:
  1.  
  2.   glEnable(GL_COLOR_MATERIAL);
  3.   glDisable(GL_COLOR_MATERIAL);
  4.  

Autor:  Flash [ Fr Dez 31, 2004 13:31 ]
Betreff des Beitrags: 

:?: Öhm.....why do you disable then enable and immediately disable it? Just disable should work. What doesn't work?

(Maybe 2 little Screenshoots whould be fine...)

Autor:  BTierens [ Fr Dez 31, 2004 15:16 ]
Betreff des Beitrags: 

1:
Code:
  1.  
  2.   glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
  3.   glEnable(GL_COLOR_MATERIAL);
  4.   //Draw coloured polygons here
  5.   glDisable(GL_COLOR_MATERIAL);
  6.   glColor3f(0.5,0.5,0.5);
  7.   glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
  8.   glEnable(GL_COLOR_MATERIAL);
  9.   glDisable(GL_COLOR_MATERIAL);
  10.   //Draw textured polygons here
  11.  


The glColor3f(0.5,0.5,0.5); changes the color of the light on the textured polygons. I don't think this is a good solution.

2:
Code:
  1.  
  2.   glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
  3.   glEnable(GL_COLOR_MATERIAL);
  4.   //Draw coloured polygons here
  5.   glDisable(GL_COLOR_MATERIAL);
  6.  


Everything gets a yellow shine and some parts of the landscape aren't lighted (or how do you say that in English).

Dateianhänge:
screenshot.jpg [39.43 KiB]
72-mal heruntergeladen

Autor:  rswm [ Fr Dez 31, 2004 19:14 ]
Betreff des Beitrags: 

set an glcolor with 1,1,1 then there shouldn't be this yellow color in there ....

the lighting ... hmmm ... perhaps its works when you set that glcolor thing ... perhaps *g*

PS: please delete all these glenable(gl_color_material), gldisable(...)

and only write at the beginnging of your renderingprocedure (after glclear and so) gldisable(gl_color_material)

if ther is an error after doing this please send a new screenie *g*

Autor:  BTierens [ Mo Jan 03, 2005 09:50 ]
Betreff des Beitrags: 

When I try that, the yellow shine is gone, and the lighting too...

Dateianhänge:
screenshot4.png
screenshot4.png [ 240.02 KiB | 5785-mal betrachtet ]

Autor:  Sascha Willems [ Mo Jan 03, 2005 10:34 ]
Betreff des Beitrags: 

After using glColorMaterial you may have to reset the ambient and diffuse parts of the lighting, as they are influenced by GL_COLOR_MATERIAL (I guess they're both set to 1/1/1, which would explain why it seems there is no more lighing).

So this should work :
Code:
  1. const
  2.  LightAmbient : array[0..3] of Single = (0.3, 0.3, 0.3, 1);  // Change to what you need
  3.  LightDiffuse : array[0..3] of Single = (0.6, 0.6, 0.6, 1); // Change to what you need
  4. ...
  5. glLightfv(GL_LIGHTx, GL_AMBIENT, @LightAmbient[0]);
  6. glLightfv(GL_LIGHTx, GL_DIFFUSE, @LightDiffuse[0]);
  7.  

Autor:  BTierens [ Mo Jan 03, 2005 11:54 ]
Betreff des Beitrags: 

The lightAmbient and lightDiffuse were 1/1/1 by default:
Code:
  1.  
  2.   lightAmbient: Array[0..3] of GLfloat = (1.0, 1.0, 1.0, 1.0);
  3.   lightDiffuse: Array[0..3] of GLfloat = (1.0, 1.0, 1.0, 1.0);
  4.  


Now I'm using your ambient and diffuse parameters because they give a good lighting.

The yellow shine is gone, the landscape is lighted, but there is still a difference in lighting (but that's not that bad)

Thanks for your help.

Dateianhänge:
Dateikommentar: An image with a part that uses GL_COLOR_MATERIAL and an image without
screenshot.jpg
screenshot.jpg [ 6.97 KiB | 5769-mal betrachtet ]

Autor:  BTierens [ Di Jan 04, 2005 13:53 ]
Betreff des Beitrags: 

I've found another solution were there is no difference between using GL_COLOR_MATERIAL and not using GL_COLOR_MATERIAL. You should reset all material parameters with glMaterialfv to their default values or to your initial values.

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/