PDA

View Full Version : Glut application flashes and disappears when run in release mode



Tork
09-02-2002, 09:38 PM
Hi gus,

This is my first post.

I am trying to clean up some of my older glut apps and I found that if I create a release mode and then try and run the exe separate from VC++, in windows explorer, the console and glut window just flash up and then disappear.

How can I prevent this from happening - if I can at all?

Thanks....any help appreciated!

tinak
09-03-2002, 03:36 AM
I just tried this with a win32 based glut application and a release version didn't have a problem nor did it when I converted it to a console based app.

Here's the code I used.. which is pretty basic. Hope this helps you figure out why yours is doing that.

Tina http://programming.swangen.co.uk/opengl/

=========================================
#include <gl\glut.h> //header file for GLUT

static void glut_render(void);
void glut_resize(int w, int h);

float xrot;

int main(int argc, char **argv)
{

// Initialise
glutInit(&argc,argv); //initializes the GLUT framework
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); //sets up the display mode
glutInitWindowSize(640,480);
glutCreateWindow("Glut Test"); //creates a window

// Functions
glutDisplayFunc(glut_render); //specifies our redraw function
glutReshapeFunc(glut_resize);
glutIdleFunc(glut_render);
glutMainLoop(); //the main loop of the GLUT framework
return 0;
}


void glut_resize(int w, int h)
{
glViewport(0,0, (GLsizei) w, (GLsizei) h); // added... new window size
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45,1.0,1.0,20.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}


void glut_render(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glTranslatef(0,0,-5);
glRotatef(xrot,1,0,0);
glBegin(GL_TRIANGLES);
glColor3f(1,0,0);glVertex3f(0,1,1);
glColor3f(0,1,0);glVertex3f(1,0,2);
glColor3f(0,0,1);glVertex3f(-1,0,2);
glColor3f(0,0,1);glVertex3f(-1,0,2);
glColor3f(0,1,0);glVertex3f(1,0,2);
glColor3f(1,0,1);glVertex3f(0,0,0);
glColor3f(1,0,0);glVertex3f(0,1,1);
glColor3f(0,0,1);glVertex3f(-1,0,2);
glColor3f(1,0,1);glVertex3f(0,0,0);
glColor3f(1,0,0);glVertex3f(0,1,1);
glColor3f(0,1,0);glVertex3f(1,0,2);
glColor3f(1,0,1);glVertex3f(0,0,0);
glEnd();
xrot++;
glFlush();
glutSwapBuffers();
}
===========================================