Stuff keeps crashing

I just can’t open windows. They keep crashing (sometimes my whole system) when I try to CreateWindow, no matter if I use GLUT or make my own Win32 Window. Can anybody please look if I mess something up in my code?
BTW, sometimes it happens that I have a working code, and when I add anything new ( vertice / line of code / function / anything… ) it crushes the next time I make a test run. Afterwards I can’t even fix it if I undo the changes.

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <gl/glut.h>

float AmbientC = { 0.2f, 0.2f, 0.2f, 1.0f };
Light0C = { 1.0f, 1.0f, 0.0f, 1.0f };
Light0P = { 7.0f, 0.0f, 0.0f, 0.0f };

float xRot = 0, yRot = 0; // to add rotation later

float vertices[3][3] = { {-1,0,0}, {1,0,0}, {0,1,0} }; // simple testing
float colors[3][3] = { {1,0,0}, {0,1,0}, {0,0,1} };

void InitGL ( )
{
glEnable ( GL_DEPTH_TEST );
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ); // standart?

glEnable ( GL_LIGHTING );
glLightModelfv ( GL_LIGHT_MODEL_AMBIENT, AmbientC );
glLightfv ( GL_LIGHT0, GL_DIFFUSE, Light0C );
glLightfv ( GL_LIGHT0, GL_POSITION, Light0P );
glEnable ( GL_LIGHT0 );

glEnable ( GL_COLOR_MATERIAL );
glColorMaterial ( GL_FRONT, GL_AMBIENT_AND_DIFFUSE );
}

void DrawScene ( )
{
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity ( );
glTranslatef ( 0.0f, 0.0f, -4.0f );
glRotatef ( xRot, 0.0f, 1.0f, 0.0f );
glRotatef ( yRot, 1.0f, 0.0f, 0.0f );
glPushMatrix ( );

  glVertexPointer ( 3, GL_FLOAT, 0, vertices );
 glColorPointer ( 3, GL_FLOAT, 0, colors );
 glDrawArrays ( GL_TRIANGLES, 0, 3 );

glPopMatrix ( );
glutSwapBuffers ( );
}

void reshape ( unsigned int w, unsigned int h )
{
glViewport ( 0, 0, w, h );
glMatrixMode ( GL_PROJECTION );
glLoadIdentity ( );
if ( h == 0 )
gluPerspective ( 80, ( float ) w, 1.0, 5000.0 );
else
gluPerspective ( 80, ( float ) w / ( float ) h , 1.0, 5000.0 );
glMatrixMode ( GL_MODELVIEW );
glLoadIdentity ( );
}

int main ( int &argc, char** argv )
{
FreeConsole ( );
glutInit ( &argc, argv );
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE );
glutInitWindowSize ( 640, 480 );
glutCreateWindow ( argv[0] );
glutSetWindowTitle ( “OpenGL Window” );
InitGL ( );
glutReshapeFunc ( reshape );
glutDisplayFunc ( DrawScene );
glutMainLoop ( );
return 0;
}

( I added the glut32 and the opengl32 libraries )

Tnx

[This message has been edited by Hermann (edited 02-04-2001).]

I do not know if it is the error but you can try to disable the call to FreeConsole. If that works can you try to enable it and move the call.