DGL
https://delphigl.com/forum/

Texture and squares,lines etc
https://delphigl.com/forum/viewtopic.php?f=19&t=6620
Seite 1 von 1

Autor:  washburn_it [ Sa Mai 26, 2007 09:47 ]
Betreff des Beitrags:  Texture and squares,lines etc

Hi,

first I want to say that I consider myself a beginner with OpenGL even though I already developed some OpenGL application for the flight simulation world.
To be specific I developed the replica of several onboard instruments (called glass cockpit, that you can see in my web site) using bitmap textures 256x256 in size (also bitmap font textures) to draw the "appearance" of the instruments.
Now I want to rework the instruments getting rid of most of the textures that seems to slow down the execution of the programs.
To draw, for example, the artificial horizon I want to use lines, rectangles, circles etc continuing to use bitmap font textures.
The problem seems to be in the intialization of OpenGL:
if I use

Code:
  1.  
  2.   glShadeModel(GL_SMOOTH);
  3.   glClearColor(0.0, 0.0, 0.0, 0.5);
  4.   glClearDepth(1.0);
  5.   glEnable(GL_DEPTH_TEST);
  6.   glDepthFunc(GL_LEQUAL);
  7.   glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
  8.  
  9.   glEnable(GL_BLEND);
  10.   glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
  11.   glEnable(GL_POINT_SMOOTH);
  12.   glEnable(GL_LINE_SMOOTH);
  13.   glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
  14.   glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
  15.  


then I can't see the font textures anymore, I just see a coloured rectangle in the place of the texture.
If I use

Code:
  1.  
  2.   glShadeModel(GL_SMOOTH);
  3.   glClearColor(0.0, 0.0, 0.0, 0.5);
  4.   glClearDepth(1.0);
  5.   glEnable(GL_DEPTH_TEST);
  6.   glDepthFunc(GL_LEQUAL);
  7.   glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
  8.  
  9.   glEnable(GL_TEXTURE_2D);
  10.   glEnable(GL_BLEND);
  11.   glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
  12.   glEnable(GL_POINT_SMOOTH);
  13.   glEnable(GL_LINE_SMOOTH);
  14.   glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
  15.   glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
  16.  


(I added the glEnable(GL_TEXTURE_2D) ) then I can see the font textures but not lines, rectangles etc.
Which is the correct initialization to make both things appearing?
Thank you, regards.

Roberto

Autor:  Lossy eX [ Sa Mai 26, 2007 11:05 ]
Betreff des Beitrags: 

There is no perfect initialisation that works for the whole running time of you programm. OpenGL is an state machine. If you enabled textures the will used for everywhere. Including lines etc. It draws the pixel of the last texturecoordinate over all.

So you must call glEnable(GL_TEXTURE_2D); if you want to use textures and glDisable(GL_TEXTURE_2D); if you want to draw something without textures.

PS: The same to all other settings. Like blending. If you draw many polygons without any alphavalues its not necesarry to have GL_BLEND enabled all the time. Modern graphiccards dont care about but its not necesarry. And perhaps if you have really much polygons they have any effect on the speed.

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