Jump to content
  • Advertisement
Sign in to follow this  
Ipito

Problem displaying model in OpenGL

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

I'm working my way through some OpenGL tutorials, and am having some problems getting the model to display. The following fragment works: void display() { // display callback, clear frame buffer and z buffer first glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // // Set up projection here // glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho( -2.0, 2.0, -2, 2.0, -100.0, 100.0 ); // // set modelview transform // glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glScalef(0.5, 0.5, 0.5); drawModel(); glFlush(); glutSwapBuffers(); } This code displays the desired model at 1/2 size. However, when I replace the glScalef with the code below: void display() { // display callback, clear frame buffer and z buffer first glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // // Set up projection here // glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho( -2.0, 2.0, -2, 2.0, -100.0, 100.0 ); // // set modelview transform // glMatrixMode(GL_MODELVIEW); glLoadIdentity(); float scalingMatrix[16]; memset(scalingMatrix, 0, sizeof(float) * 16); scalingMatrix[0] = 0.5; scalingMatrix[5] = 0.5; scalingMatrix[10] = 0.5; glLoadMatrixf(scalingMatrix); drawModel(); glFlush(); glutSwapBuffers(); } it doesn't display anything at all. I'm quite new to OpenGL, so I'm not sure if there is a basic step that I've missed or done wrong, any advice would be apprciated. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Try adding

scalingMatrix[15] = 1.0;

to your matrix setup. Currently your matrix zeroes your w coordinate, which could cause problems (I'm not sure, I don't have the spec with me 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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!