PDA

View Full Version : Must create window in same function as glutInit?



David Doria
08-31-2008, 07:24 AM
I was trying to get this big list of opengl setup out of my main(), so I thought I'd put it in a couple of functions.


int MainWindow(string WindowTitle)

{


glutCreateWindow(WindowTitle.c_str());

}


void OpenGLinit(int argc, char *argv[])

{

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);


glutInitWindowSize(1000, 1000);

glutInitWindowPosition(0,0);


//MainWindow(1000, 1000, "test");


zprInit();



}



If I call OpenGLinit() from main with the MainWindow() call uncommented, all is well.

However, if I call OpenGLinit() from main, and then MainWindow() from main, I just get a black window with none of my objects drawn!! Doesn't make any sense to me - does any one have an explanation?

Thanks,

Dave