Problem drawing with NeHeGL2 Basecode
I haven''t used NeHe''s tutorials for a little while, so I''m not completely up on the new ones. I tried using the GL II Basecode, and it runs fairly well, but there seems to be a problem. The text shows up, but from what I understand of the code it seems there''s supposed to be a triangle and quad drawn as well. I can''t make these show up as much as I fiddle around with it. Can anyone tell me what I''m doing wrong?
To tell you the truth, I don''t think it is supposed to draw a triangle or a quad...here look at this function in Example.cpp
It seems to be only outputting text...
<- http://www.digitalexplosions.com ->
"Discipline is my sword, faith is my shield
do not dive into uncertainty, and you may live to reap the rewards" - (Unreal Championship)
void Draw (void){ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer glLoadIdentity(); // Reset The View glColor3f(0.0f,0.3f,1.0f); fNeHe.SetBase(32); // Adjust Base Start Pos (First Set of Fonts) fNeHe.Print(20,30,"NeHe Productions Presents:"); // Print GL Text To The Screen glColor3f(1.0f,1.0f,0.0f); fNeHe.SetBase(32 - 128); // Adjust Base Start Pos (Second Set of Fonts) fNeHe.Print(20,50,"NeHe Base Code Version 2.0"); // Print GL Text To The Screen glFlush (); // Flush The GL Rendering Pipeline}
It seems to be only outputting text...
<- http://www.digitalexplosions.com ->
"Discipline is my sword, faith is my shield
do not dive into uncertainty, and you may live to reap the rewards" - (Unreal Championship)
Try taking a look at the first tutorial, it doesn''t have the best explanation of how to use glTranslatef(); but it is still good.
Try this if you don''t want to look at the tutorial... (taken from the NeHe tutorial)
You should play around with translate to get used to it...
<- http://www.digitalexplosions.com ->
"Discipline is my sword, faith is my shield
do not dive into uncertainty, and you may live to reap the rewards" - (Unreal Championship)
Try this if you don''t want to look at the tutorial... (taken from the NeHe tutorial)
glTranslatef(-1.5f,0.0f,-6.0f);glBegin(GL_TRIANGLES); // Drawing Using Triangles glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glEnd(); // Finished Drawing The TriangleglTranslatef(3.0f,0.0f,0.0f); // Move Right 3 UnitsglBegin(GL_QUADS); // Draw A Quad glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glEnd(); // Done Drawing The Quad
You should play around with translate to get used to it...
<- http://www.digitalexplosions.com ->
"Discipline is my sword, faith is my shield
do not dive into uncertainty, and you may live to reap the rewards" - (Unreal Championship)
Actually, when I downloaded the basecode (a few days ago), it did include the Quad and Triangle code that is shown above. I checked the two and they''re exactly the same. The text shows up just fine, but the triangle and quad refuse to appear.
Could you show me the code where it draws the triangle and quad, because I cannot find it...
<- http://www.digitalexplosions.com ->
"Discipline is my sword, faith is my shield
do not dive into uncertainty, and you may live to reap the rewards" - (Unreal Championship)

<- http://www.digitalexplosions.com ->
"Discipline is my sword, faith is my shield
do not dive into uncertainty, and you may live to reap the rewards" - (Unreal Championship)
void Draw (void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The View
glColor3f(0.0f,0.3f,1.0f);
fNeHe.SetBase(32); // Adjust Base Start Pos (First Set of Fonts)
fNeHe.Print(20,30,"NeHe Productions Presents:"); // Print GL Text To The Screen
glColor3f(1.0f,1.0f,0.0f);
fNeHe.SetBase(32 - 128); // Adjust Base Start Pos (Second Set of Fonts)
fNeHe.Print(20,50,"NeHe Base Code Version 2.0"); // Print GL Text To The Screen
glLoadIdentity();
glTranslatef(-1.5f,0.0f,-4.0f); // Move Left 1.5 Units And Into The Screen 6.0
glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units
glBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad
glFlush (); // Flush The GL Rendering Pipeline
}
This is the Draw function in the Example.cpp file. It''s got text that shows up, and it''s got triangles and quads that do not.
Hey, I finally figured it out, in case anyone''s interested. After a lot of mucking about, I found that the Font function was binding the font texture and it never was unbound when the triangles were to be drawn to the screen. However, the triangle drawing code only included color coords, not texture coords, so the computer didn''t know how to map the font texture onto the triangle and left it blank. The triangles were always there, they were just being drawn with a texture instead of colors.
I fixed this for myself by including another texture and mapping that onto the triangles instead, but is there to just unbind whatever texture is in memory and draw with just color attributes?
I fixed this for myself by including another texture and mapping that onto the triangles instead, but is there to just unbind whatever texture is in memory and draw with just color attributes?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement