Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Mi Mai 29, 2024 01:38

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 8 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: Disabling GL_COLOR_MATERIAL
BeitragVerfasst: Fr Dez 31, 2004 11:27 
Offline
DGL Member

Registriert: Fr Aug 13, 2004 17:43
Beiträge: 60
Wohnort: Belgien
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.  


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Fr Dez 31, 2004 13:31 
Offline
Guitar Hero
Benutzeravatar

Registriert: Do Sep 25, 2003 15:56
Beiträge: 7804
Wohnort: Sachsen - ERZ / C
Programmiersprache: Java (, Pascal)
:?: Ö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...)

_________________
Blog: kevin-fleischer.de und fbaingermany.com


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Fr Dez 31, 2004 15:16 
Offline
DGL Member

Registriert: Fr Aug 13, 2004 17:43
Beiträge: 60
Wohnort: Belgien
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
Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Fr Dez 31, 2004 19:14 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Aug 28, 2002 19:27
Beiträge: 568
Wohnort: Chemnitz / Sachsen
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*

_________________
Aktuelles Projekt :
www.PicPlace.de


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Jan 03, 2005 09:50 
Offline
DGL Member

Registriert: Fr Aug 13, 2004 17:43
Beiträge: 60
Wohnort: Belgien
When I try that, the yellow shine is gone, and the lighting too...


Dateianhänge:
screenshot4.png
screenshot4.png [ 240.02 KiB | 4687-mal betrachtet ]
Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Jan 03, 2005 10:34 
Offline
DGL Member
Benutzeravatar

Registriert: Mo Sep 23, 2002 19:27
Beiträge: 5812
Programmiersprache: C++
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.  

_________________
www.SaschaWillems.de | GitHub | Twitter | GPU Datenbanken (Vulkan, GL, GLES)


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Jan 03, 2005 11:54 
Offline
DGL Member

Registriert: Fr Aug 13, 2004 17:43
Beiträge: 60
Wohnort: Belgien
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 | 4671-mal betrachtet ]
Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Jan 04, 2005 13:53 
Offline
DGL Member

Registriert: Fr Aug 13, 2004 17:43
Beiträge: 60
Wohnort: Belgien
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.


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 8 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 11 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.038s | 19 Queries | GZIP : On ]