Jump to content
  • Advertisement
Sign in to follow this  
beebs1

OpenGL Issue

This topic is 2598 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

Hiya,

I'm having some trouble drawing in OpenGL. I have a skybox working correctly, and I'm trying to get a triangle to draw - for some reason it fails, and I just see a skybox with nothing in front.

The code I'm using is:

/* Clear the buffers. */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glLoadIdentity();

/* Draw the skybox if necessary. */
if(m_skyBox)
m_skyBox->draw();

gluLookAt(
0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 10.0f,
0.0f, 1.0f, 0.0f);

// static Mesh mesh("enemy.mesh");

// Zero the model/view matrix
glLoadIdentity();

// Translate the triangle to 0, 0, 10
glTranslatef(0.0f, 0.0f, 10.0f);

// Draw all white
glColor3f(1.0f, 1.0f, 1.0f);

// Draw the triangle vertices.
glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 1.0f, 0.0f, 0.0f);
glVertex3f( 0.0f, 0.0f, 0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glEnd();

SwapBuffers(m_windowContext);


I must be doing something wrong... Any help would be appreciated! :)

Share this post


Link to post
Share on other sites
Advertisement
A few things I see.

First of all make sure you disable z-buffering when you draw the skybox.

Also, it looks like you are doing the matrix operations out of order right after you draw the skybox.

Right now you do the lookat operation. Then loading and Identity. Loading an Identity clears any previous transformations so you probably want to switch those so you load the identity then do the gluLookAt

Share this post


Link to post
Share on other sites
glBegin/End and the matrix stack/fixed function pipeline were removed after v2.1. We are currently on version 4.2.

http://www.opengl.org/documentation/current_version/

Share this post


Link to post
Share on other sites
Well whaddaya know.

I've only used DirectX before, and this is for a university project. I'm definitely on a 'just make it work' deadline, so I'm just trying to learn what I can from tutorials as I go. I'll get a copy of the red book when this is finished, and take some time to look through it.

Anyways, thanks for the heads up. :)

Share this post


Link to post
Share on other sites

Well whaddaya know.

I've only used DirectX before, and this is for a university project. I'm definitely on a 'just make it work' deadline, so I'm just trying to learn what I can from tutorials as I go. I'll get a copy of the red book when this is finished, and take some time to look through it.

Anyways, thanks for the heads up. :)


No problem! The good/bad thing about OpenGL is that when you start looking online for tutorials and help, you find a lot of old material thanks to the massive popularity of NeHe's legacy tutorials (I am willing to bet those are the ones you have been looking at).

Since they seemed to be rehosted at GameDev, it might be worth it to maybe go back and add a legacy disclaimer to the tut pages?

Share this post


Link to post
Share on other sites
On an additional note, though, the "compatibility profiles" (ie, older GL versions) are still well supported by current drivers, and by upgrading to GL 4, you do run the risk of limiting your audience. I have a computer that is around 5 years old that only supports GL 2. I've also run into significant problems on newer computers with integrated Intel graphics having crappy GL 4 support. If your audience is going to be more of the "dedicated gamer" type, you can safely assume they have a fairly modern card of the ATI/NVidia variety with Vista/Win7 OS and GL 4 support. Outside of that rough demographic, it tends to be far more hit and miss. It'll sure be nice when you can count on GL 4 support, but that time is not right now.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!