Reputation: 9
I'm learning how to use the openGL but I only find tutorials using SDL functions for manage windows and events.
This the code I made with this tutorial:
#include <GL/gl.h>
#include <GL/glu.h>
#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>
int main(int argc, char **argv)
{
SDL_Init(SDL_INIT_VIDEO);
SDL_WM_SetCaption("Mon premier programme OpenGL !",NULL);
SDL_SetVideoMode(640, 480, 32, SDL_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);
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_SwapBuffers();
}
SDL_Quit();
return 0;
}
I'm ok tu use the SDL functions to manage windoxs but I would use the openGL events handler.
Does someone know how to replace and how to use it ?
Thanks
Upvotes: 1
Views: 1644
Reputation: 162164
Does someone know how to replace and how to use it?
No. Because it doesn't exist.
OpenGL is focused on one thing: Drawing stuff to some framebuffer. In the case of a window framebuffer OpenGL has no capabilities in creating or managing it, and depends entirely on the operating system functions for this. SDL, GLUT, GLFW, Qt, … shrink-wrap the process of interacting with the OS in easy to use way, portable libraries with a cross-platform API.
Upvotes: 1
Reputation: 26559
OpenGL does not have an event handler. It focuses on drawing, not input.
To handle window events and input, you need to either use the OS facilities, or use a library like GLFW, GLUT, or SDL that helps/abstracts them.
Upvotes: 4