Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

dirkduck

NeheGL basecode # 2 prob...

This topic is 6086 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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();

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
oh yeah, it wont draw the triangle in there...in case you were wondering...the text shows up fine though.

McDougal...DUCK McDougal

Share this post


Link to post
Share on other sites
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!"

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!