I'm using Dev-C++ 4.9.9.2 (don't ask why) and SDL 1.2.8.
Next I've created new project: SDL&GL. This project contains already some code:
#include <SDL/SDL.h>
#include <gl/gl.h>
int main(int argc, char *argv[]){
SDL_Event event;
float theta = 0.0f;
SDL_Init(SDL_INIT_VIDEO);
SDL_SetVideoMode(600, 300, 0, SDL_OPENGL | SDL_HWSURFACE | SDL_NOFRAME);
glViewport(0, 0, 600, 300);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0);
glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glMatrixMode(GL_PROJECTION);
glMatrixMode(GL_MODELVIEW);
int done;
for(done = 0; !done;){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,0.0f);
glRotatef(theta, 0.0f, 0.0f, 1.0f);
glBegin(GL_TRIANGLES);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex2f(0.0f, 1.0f);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex2f(0.87f, -0.5f);
glColor3f(0.0f, 0.0f, 1.0f);
glVertex2f(-0.87f, -0.5f);
glEnd();
theta += .5f;
SDL_GL_SwapBuffers();
SDL_PollEvent(&event);
if(event.key.keysym.sym == SDLK_ESCAPE)
done = 1;
}
SDL_Quit();
return(0);
}
Next I compiled project and try to run it. After run the program shows for less than 1 second and immediately terminates. Debugger returns following error: "An Access Violation (Segmentation Fault) raised in your program".
I'm using Windows 2003 and Radeon x1950 PRO with latest drivers.
I've tested program on laptop with Windows XP and it works perfectly. Why this program doesn't work on my computer?