PDA

View Full Version : GlewInit



OliverMD
05-07-2013, 12:46 PM
I've now got around to creating a simplistic rendering system with OpenGL, however while testing I'm encountering an access violation exception which occurs when I try to call glGenBuffers(1, &m_ElementBuffer);.

My Renderer::Init function has this in it:


if(!glfwInit())
{
fprintf(stderr, "GLFW failed to init, CRITICAL ERROR!\n");
return false;//Have to back out due to severity of error
}
glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

if(!glfwOpenWindow(int(m_Dimensions.x), int(m_Dimensions.y), 0,0,0,0, 32,0,GLFW_WINDOW))
{
fprintf(stderr, "GLFW Open Window failed, aborting...\n");
glfwTerminate();
return false;
}

glewExperimental = true;

if(glewInit() != GLEW_OK)
{
fprintf(stderr, "Glew failed to init \n");
return false;
}
glClearColor(0.0f,0.0f,0.4f,0.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glfwSetWindowTitle("Render");

I then go on to parse an xml file to further initialization.

The problem I'm getting is when I call a sceneNodes init function which then calls its renderObjects init function which creates the buffers and all OpenGL related 'stuff' for that object. I am fairly sure that I am calling this after glewInit and have double checked numerous times although I will check it when I come back to this after a break away from the computer. I figure that something has gone wrong with glewinit since in my watch list, when I debug, it says that glGenBuffers is undefined however it also says this about glClear() which executes fine.

I'm sure it's something obvious that I may pick up straight away when I come back to it, but for the moment I am stumped and would appreciate any suggestions.

Realized some extra information might be needed, I using an AMD Radeon HD7850 Core Edition for XFX, I have used this function successfully in another project without any issues and glGetString(GL_VERSION) returns "3.3.12002 Core Profile Context 9.12.0.0"

OliverMD
05-07-2013, 12:56 PM
Solved, turns out I was being really stupid and it was down to the shared_ptr not being initialized properly :/