PDA

View Full Version : OpenGL GLUT window not loading



thekilla1234
06-30-2009, 02:42 PM
I bought the OpenGL Superbible Fourth Edition and I have reached the 'Your First Program' section (Listing 2.1 for reference). I spent a while getting all the libraries setup and the program finally compiles with no warnings or errors, but when I run the program, the window doesn't load up, there is just a blank console window. I copied the code pretty much word for word (with the exception of a char* constant for the window title). Here is the code:


/********** OpenGL Includes ********/
#include <gl/gltools.h>
/***********************************/

/********** Constants **************/
const char* WINDOW_TITLE = "OpenGL Test Program";
/***********************************/

/********** Draws the Scene ********/
void RenderScene()
{
// Clear the window
glClear(GL_COLOR_BUFFER_BIT);

// Flush drawing commands
glFlush();
}
/***********************************/

/****** Setup Rendering State ******/
void SetupRC()
{
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
}
/***********************************/

int main(int argc, char* argv[])
{
glutInit(&amp;argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
glutCreateWindow(WINDOW_TITLE);
glutDisplayFunc(RenderScene);
SetupRC();

glutMainLoop();

return 0;
}

I am running on Vista using the Borland C++ compiler. As mentioned, the program complies fine using the command line:


bcc32 -DWIN32 ogl.cpp glut32.lib glu32.lib opengl32.lib

I have tried adding -L to each of the libraries and I get the same problem of the window not loading. I can't advance further into the book until this is sorted and I have searched high and low for someone with a similar problem and have found nobody, so I guess I'm a first. Does anyone understand why the window does not show?

Edit: I guess this should have gone in the OpenGL Toolkits section, my bad, I only just noticed that section just now.

MaxH
06-30-2009, 03:06 PM
Your code works fine on my system (Windows XP and VC++ 6.0).

thekilla1234
06-30-2009, 03:15 PM
Then it may have something to do with Vista or Borland. I would have guessed the code wasn't wrong. Could anyone with Vista and Borland (Or just Vista mind you, I can change compilers if Borland has problems) try compiling and running this?

Here is a screenshot of the file structure, path, compile and link command line and the blank console I get from the exe (if this helps in any way):

http://img19.imageshack.us/img19/5969/glut.jpg

thekilla1234
06-30-2009, 04:07 PM
I just tried with VC++ and it is working fine as you stated. I still have no idea why it didn't work for Borland, but I will just switch over to VC++. Thanks for the reply. If anyone could explain why it didn't work on Borland, that would be appreciated.