FBO initialisation causes segfault


I’m migrating from glCopySubTex() to FBO.

I am not using GLUT.

I’m using GLEW and GLFW but all the examples I’ve seen of FBO use GLUT so it could be initialising something I’m not.

My includes are:

#include <GL/glew.h>
#include <GL/glfw.h>

All compiles fine.

But it crashes on the attempt to generate the framebuffer object. Google tells me its because the FBO isn’t initialised properly, but I expected GLEW to do that for me. Why is it crashing?

static GLuint fbo[1];

glGenFramebuffers(1, fbo); // set-up fbo

Thanks for any help.


Make sure you’re extensions are properly loaded. If you print out glGenFramebuffers itself, you’ll probably see it’s zero instead of some position in memory you’d expect. It’s because glGenFramebuffers itself hasn’t been initialized.

Did you call glewInit and did it return any errors?

Yes, glGenFramebuffers returned zero.

In checking the glewInit it returned the error “Missing GL version”.

I found the problem, I moved the glewInit after the glfwOpenWindow call which then worked.

I was initialising GLEW too early.

Thanks for your help.