Hello,

First of all, sorry for this newbie thread, but I'm encountering problems to draw a simple triangle with SDL and OpenGL.

My IDE is Code::Blocks.
In debug mode, there is no Error/warning, the window is corretly open but nothing is showed inside.
Like no OpenGL commands are read...

Here is my little C++ program, Can you help me to figure out where is the problem ? thx

#include <SDL2/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>

int main(int argc, char ** argv) {
SDL_Window* mainWindow = SDL_CreateWindow(
"OpenGL Triangle",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
640,
480,
SDL_WINDOW_OPENGL
);

bool continuer = true;

SDL_Event event;

while (continuer) {
SDL_WaitEvent(&event);
switch(event.type) {
case SDL_QUIT:
continuer = false;
}

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

glBegin(GL_TRIANGLES);
glColor3ub(255,0,0);
glVertex2d(-0.75,-0.75);
glColor3ub(0,255,0);
glVertex2d(0,0.75);
glColor3ub(0,0,255);
glVertex2d(0.75,-0.75);
glEnd();

glFlush();

SDL_GL_SwapWindow(mainWindow);
}

SDL_Quit();

return 0;
}