Jump to content
  • Advertisement
Sign in to follow this  
openglbros

OpenGL This code won't work. Why?

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

Dear Ladies and gentlemen, We are newbies at OpenGL. We have been studying OpenGL programming with Visual Studio .Net 2003 VC++. We found a piece of code in a book, and we tried to test this code with VC++. In the beginning, we create a console project with the Wizard, and then we typed in the following code: #include "stdafx.h" #include <windows.h> #include <GL/gl.h> #include <GL/glu.h> #include <GL/glaux.h> #using <mscorlib.dll> using namespace System; void CALLBACK display(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glLoadIdentity(); glTranslatef(0.0, 0.0, -0.5); glScalef(1.0, 2.0, 1.0); auxWireCube(1.0); glFlush(); } void myinit(void) { glShadeModel(GL_FLAT); } void CALLBACK myReshape(GLsizei w, GLsizei h) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 20.0); glMatrixMode(GL_MODELVIEW); glViewport(0, 0, w, h); } /* int _tmain() // This functioin created by the Wizard. { Console::WriteLine(S"Hello World"); return 0; }*/ void main(int argc, char **argv) { auxInitDisplayMode(AUX_SINGLE | AUX_RGBA); auxInitPosition(0, 0, 500, 500); auxInitWindow(argv[0]); myinit(); auxReshapeFunc(myReshape); auxMainLoop(display); } We compile the code successfully. But when we run this program, we only got a black window, it drew nothing on the window. Why doesn't the code works? Please help me. Thank you very much. Best regards. OpenGL Bros.

Share this post


Link to post
Share on other sites
Advertisement
Are the arguments to the glFrustum function and the glTranslate function correct? It would seem that the wire cube is not quite within the viewing frustrum. Perhaps changing to glTranslate(0, 0, -5).

Share this post


Link to post
Share on other sites
Hello Bob III,

Thank you for your help. You were right. The parameters of glTranslate() we passed were wrong.

Thank you very much!

Best regards.

OpenGL Bros.

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!