GL_ARB_vertex_buffer_object extension : crash at runtime
Hi,
I can compile and link the following very simple code but it's crashing at runtime.
#include <GL/glew.h>
int main(int argc,char **argv) {
GLuint id;
glGenBuffers(1, &id);
}
Do you know what's wrong with this code ?
Here are my OpenGL features :
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: Quadro FX 3450/4000 SDI/PCI/SSE2
GL_VERSION: 1.5.3
GL_EXTENSIONS: ... GL_ARB_vertex_buffer_object ...
(glGenBuffers belongs to the GL_ARB_vertex_buffer_object that I h have)
And I have the NVIDIA forceware 72.13 which is not the last one (the last release is the 91.36).
Raphael
based on that code you never initalised the function pointer to point to the correct address, thus calling = calling a null (or even random) address, thus crash town..
Thanks for your help. So I initialized the function pointer and added the
glewInit() call but it was still crashing. I eventually added
a glutCreateWindow() call and then it runs normally. The
glewInit() call isn't necessary (here at least).
Here is the code :
//============================================================================
#include <GL/glew.h>
#include <GL/glut.h>
#include <windows.h>
int main(int argc,char **argv) {
GLuint id;
glutCreateWindow("title");
PFNGLGENBUFFERSPROC glGenBuffers = NULL;
PFNGLBINDBUFFERPROC glBindBuffer = NULL;
PFNGLBUFFERDATAPROC glBufferData = NULL;
glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers");
glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer");
glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData");
glGenBuffers(1, &id);
glBindBuffer(GL_ARRAY_BUFFER, id);
}
//============================================================================
glewInit() call but it was still crashing. I eventually added
a glutCreateWindow() call and then it runs normally. The
glewInit() call isn't necessary (here at least).
Here is the code :
//============================================================================
#include <GL/glew.h>
#include <GL/glut.h>
#include <windows.h>
int main(int argc,char **argv) {
GLuint id;
glutCreateWindow("title");
PFNGLGENBUFFERSPROC glGenBuffers = NULL;
PFNGLBINDBUFFERPROC glBindBuffer = NULL;
PFNGLBUFFERDATAPROC glBufferData = NULL;
glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers");
glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer");
glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData");
glGenBuffers(1, &id);
glBindBuffer(GL_ARRAY_BUFFER, id);
}
//============================================================================
I guess it was crashing because u were calling an opengl function before even creating a rendering context etc.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement