NeheGL basecode # 2 prob...

Started by
7 comments, last by dirkduck 22 years, 6 months ago
Well, i just got the nehegl 2 basecode, and im ahving a problem. I cant get it to draw to the screen, other then the text. For example, if i add glTranslatef(0.0,0.0,-5.0); cube(); where cube is a function i have to daw a simple cube, it wont draw it. I have put the code in the ''draw ()'' function of the basecode, and i cant figure out whats wrong. Thanks for any help. PS: I can post some code if you want me too...you can get it all from NeHe''s site - the neheGL2 basecode i believe its called. thanks! McDougal...DUCK McDougal
http://www.labino.net
Advertisement
I''ve never had a problem with any of Jeff Moloffe''s tutorials / basecode, but may i suggest using glut? If you are not extremely concerened with it being windows-speedy (if that exists ), then I reccoment it. I have not actually noticed a difference in performance, unless you are looking at using the few features that are not implemented under the win32 version. besides, this would also give you the added benefit of simplifying the window creation, etc. and making the program platform independant.
Heres how it should look( I dont know if this is how Nehe''s base code is, but heres how youll need it)


void Cube()
{
glBegin(GL_TRIANGLES);
glVertex3f(0.0f,1.0f, 0.5f);
glVertex(you get the picture);
glVertex3f(................);
glEnd();
}

void Render()
{
glTranslatef(0.0f,0.0f,-0.5);
Cube();
}

And in the else statement in WinMain, you call render:

Render();
------------------------------Put THAT in your smoke and pipe it
yeah, thats about exactly what i have.

McDougal...DUCK McDougal
http://www.labino.net
In your render code, try having something like:

glPushMatrix
glTranslate..
DrawCube
glPopMatrix


Also, are you sure your player is ''looking'' in the direction of those co-ordinates specified?
After compilation, the executable of Base Code 2 goes to fullscreen only. I use Dev-C++ & must define the following code:

#ifndef CDS_FULLSCREEN
#define CDS_FULLSCREEN 4
#endif

Is there a proper place that this needs to be keyed, or has the value of the constant changed?
thanks for teh replys, but nothing seems to work. Heres a little example of what i have. (the first bit is the draw function, then the second is in the main loop)


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


glPushMatrix();
glTranslatef(0.0f,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 Triangle


glPopMatrix();

glFlush (); // Flush The GL Rendering Pipeline
}



...
and the main loop....



else // If Window Is Visible
{
// Process Application Loop
tickCount = GetTickCount (); // Get The Tick Count
Update (tickCount - window.lastTickCount); // Update The Counter
window.lastTickCount = tickCount; // Set Last Count To Current Count
Draw (); // Draw Our Scene

SwapBuffers (window.hDC); // Swap Buffers (Double Buffering)
}





so i cant figure out what is wrong. thanks for any help!

McDougal...DUCK McDougal
http://www.labino.net
oh yeah, it wont draw the triangle in there...in case you were wondering...the text shows up fine though.

McDougal...DUCK McDougal
http://www.labino.net
Try this:

Put a matrix push before drawing the text, then pop it after. Perhaps the text draw function is changing an opengl state that is preventing further visible drawing. Just a thought.

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"
Alex BroadwinA-Tronic Software & Design-----"if you fail in life, you were destined to fail. If you suceed in life, call me.""The answer is out there.""Please help, I'm using Windows!"

This topic is closed to new replies.

Advertisement