   [solved]no screen shows up, program crashes
  so im making the foundations to a game i'm going to make but im stuck. it should (in my mind but not reality) create a window and display the clear color but instead it crashes after i call glClear(GL_COLOR_BUFFER_BIT);. im not even sure that a window was created, any will help will be appreciated :)#include <iostream>#include <string>#include <vector>#include <bitset>#include <map>#include <windows.h>#include <boost/timer.hpp>#define  GLUT_NO_LIB_PRAGMA#include <GL/gl.h>#include <GL/glu.h>#include <GL/glut.h>#include <SOIL.h>#include <irrKlang.h>using namespace irrklang;using namespace std;using namespace boost;class Sprite;class Texture;class Sound;class Event;class Game_State;class Event {private:    friend class Game_State;    bitset<256> KeyBuffer;   ///the whole of the key buffer    GLshort x,y;   ///the curser postion    bitset<3> MouseBuffer;   ///0:(Mouse1) 1:(Mouse3) 2:(Mouse2)    GLbyte z; ///scrol bar amount to go up or down    GLvoid UpdateBuffers() {   PBYTE Temp;   LPPOINT Cur;   GetKeyboardState(Temp);   for(unsigned short i=0;i<256;++i) {  KeyBuffer = Temp;   }   GetCursorPos(Cur);   x = Cur->x;   y = Cur->y;   SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &z, 0);   MouseBuffer[0] = GetKeyState(VK_LBUTTON);   MouseBuffer[1] = GetKeyState(VK_MBUTTON);   MouseBuffer[2] = GetKeyState(VK_RBUTTON);    }public:    Event() {   MouseBuffer[0] = 0;   MouseBuffer[1] = 0;   MouseBuffer[2] = 0;   for(short i=0;i<256;++i) KeyBuffer = 0;   x=0;   y=0;   z=0;    }};class Game_State {private:    friend class Sprite;    vector<Sprite*> SpriteBuffer;    Event EventManger;    timer Ticks;    GLubyte FPS;    GLvoid Display();    GLvoid Reshape(GLshort w, GLshort h);public:    GLvoid MainLoop();    Game_State(int& argc, char *argv[],GLshort glw, GLshort glh) {   GLshort SW, SH;   FPS = 60;   glutInit (&argc, argv);   glutInitDisplayMode (GLUT_DOUBLE|GLUT_RGBA);   glutInitWindowSize (SW,SH);   glutInitWindowPosition (glutGet(GLUT_SCREEN_WIDTH)/2-SW/2, glutGet(GLUT_SCREEN_HEIGHT)/2-SH/2);   glutCreateWindow("Jucie");   glClearColor( 0, 0, 0, 1 );   glEnable( GL_TEXTURE_2D );   glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);   glEnable(GL_BLEND);   glMatrixMode(GL_PROJECTION);   glLoadIdentity();   SW = glutGet(GLUT_SCREEN_WIDTH);   SH = glutGet(GLUT_SCREEN_HEIGHT);   if (glw>0) SW = glw;   if (glh>0) SH = glh;   gluOrtho2D(0, SW, 0, SH);   glScalef(SW, SH, 1);   glMatrixMode( GL_MODELVIEW );   glLoadIdentity();   Reshape(SW,SH);   if ( glGetError() != GL_NO_ERROR ) {  cerr<<"fatal error on line "<<__LINE__<<" in file @"<<__FILE__<<" : was unable to initlize Game State";  exit(__LINE__);   }    }    ~Game_State() {}};class Texture {private:    friend class Sprite;    GLuint Tex;public:    Texture(string FilePath) {   Tex = SOIL_load_OGL_texture(FilePath.c_str(),SOIL_LOAD_AUTO,SOIL_CREATE_NEW_ID,SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT);    }    ~Texture() {   glDeleteTextures(1,&Tex);    }};class Sprite {private:    friend class Game_State;    string CurentAnimation;    GLuint Index;    GLshort x,y,theta,h,w;    GLuint SpriteInfo;    GLvoid Display() {   glPushMatrix();   glTranslated(x,y,0);   glRotated(theta,0,0,1);   glCallList(SpriteInfo);   glPopMatrix();    }public:    Sprite(Game_State& GS, GLshort sh, GLshort sw) {   x=0;   y=0;   theta=0;   h=sh;   w=sw;   GS.SpriteBuffer.push_back(this);   Index = GS.SpriteBuffer.size()-1;    }    ~Sprite() {}    GLvoid BindTexture(Texture Tex) {   GLuint DispList = glGenLists(1);   glNewList(DispList,GL_COMPILE);   glBindTexture(GL_TEXTURE_2D,Tex.Tex);   glBegin(GL_QUADS);   glTexCoord2i(0,0);   glVertex2i(0,0);   glTexCoord2i(h,w);   glVertex2i(h,w);   glTexCoord2i(h,0);   glVertex2i(h,0);   glTexCoord2i(0,w);   glVertex2i(0,w);   glEnd();   SpriteInfo = DispList;    }    GLvoid Remove(Game_State& GS) {   GS.SpriteBuffer.erase(GS.SpriteBuffer.begin()+Index);    }    GLvoid Add(Game_State& GS) {   GS.SpriteBuffer.push_back(this);   Index = GS.SpriteBuffer.size()-1;    }};GLvoid Game_State::Display() {    size_t Size = SpriteBuffer.size();    for(unsigned short i=0;i<Size;++i) {   SpriteBuffer->Display();    }}GLvoid Game_State::Reshape(GLshort w, GLshort h) {    glViewport (0, 0, (GLsizei)w, (GLsizei)h);    glMatrixMode (GL_PROJECTION);    glLoadIdentity ();    gluPerspective (60, (GLfloat)w / (GLfloat)h, 0.1, 1000.0);    glMatrixMode (GL_MODELVIEW);}GLvoid Game_State::MainLoop() {    GLboolean end = 0;    Ticks.restart();    while(!end) {   EventManger.UpdateBuffers();   glClear (GL_COLOR_BUFFER_BIT);   Display();   glutSwapBuffers();   GLdouble elapsedtime = Ticks.elapsed();   if(elapsedtime<((GLdouble)1/(GLdouble)FPS)) {  GLshort SleepTime = (((GLdouble)1/(GLdouble)FPS) - elapsedtime)*1000;  Sleep(2000);   }    }}int main(int argc, char *argv[]) {    Game_State Test(argc,argv,800,600);    Test.MainLoop();} [Edited by - ishkabible on September 6, 2010 2:22:54 PM]
  Can you create a minimal example that demonstrates the problem?   ;  srry i figured it out, a number of things where going on, one glut requires it to use it's mainloop and function pointer BS, two if you look at the constuctor int my Game_Sate class you will see that i tried to create a window with hight and width of uninitialized variables, after i figured out that GLUT reqiured this i switched to using GLFW instead, much better library now that im using it.   