1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| #include <SDL/SDL.h>
#include <GL/glew.h>
#include <iostream>
/* dimensions de la fenetre */
#define W 300
#define H 200
int main(int argc, char **argv)
{
int loop = 1; /* booleen du 'main loop' */
SDL_Event ev; /* structure d'evenement(s) SDL */
GLuint *buf = new GLuint(); /* identifiant de notre objet tampon */
/* initialisation de la SDL en mode OpenGL */
SDL_Init(SDL_INIT_VIDEO);
SDL_SetVideoMode(W, H, 32, SDL_OPENGL);
/* nom de la fenetre */
SDL_WM_SetCaption("Vertex Buffer Objects GL", NULL);
/* initialisation de glew */
glewInit();
/* test que j'ai rajouté (renvoie bien ok) */
if(glewIsSupported("GL_ARB_vertex_buffer_object") == GL_TRUE)
std::cout << "ok"<< std::endl;
/* creation d'un objet tampon et recuperation de son identifiant */
glGenBuffers(1, buf); // ICI SEGMENTATION FAULT
/* boucle d'affichage principale */
while(loop)
{
/* recuperation d'un evenement */
SDL_WaitEvent(&ev);
/* analyse */
if(ev.type == SDL_QUIT)
loop = 0;
glClear(GL_COLOR_BUFFER_BIT);
/* rendu ... */
/* on flip les tampons */
glFlush();
SDL_GL_SwapBuffers();
}
return 0;
} |
Partager