Page 1 of 1

glewInit() Failing

PostPosted: Sun Feb 19, 2012 9:20 pm
by rengaj
So I am having an interesting error when I am initializing my window. When I run my program, the GL_CHECK call that I make after I call glewInit() gets triggered, causing the message "GLEW Init failed." to appear. I don't know what is going on, since I am (basically) using the code outlined in tex-cube.cpp's initialize() function. Below is my initialize() function, along with my GL_CHECK macro:

Code: Select all
int initialize()
{
   if (!glfwInit())
   {
      Debug::LogError("Failed to initialize GLFW");
      return -1;
   }

   glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
   glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 0);
   glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

   if (!glfwOpenWindow(600,600, 0,0,0,0, 16,0, GLFW_WINDOW))
   {
      Debug::LogError("Failed to open GLFW window");
      glfwTerminate();
      return -1;
   }

   glewExperimental = GL_TRUE;
   GLenum GlewInitResult = glewInit(); GL_CHECK("GLEW init failed.");

   if (GLEW_OK != GlewInitResult)
   {
      Debug::LogError("Failed to correctly initialize GLEW");
      return -1;
   }

   glClearColor(0.0f,0.0f,0.0f,0.0f); GL_CHECK("Clear Color Failed.");

   glEnable(GL_DEPTH_TEST); GL_CHECK("Depth Test Enable Failed.");
   glDepthFunc(GL_LESS);     GL_CHECK("Depth Function Failed.");
   glEnable(GL_CULL_FACE);  GL_CHECK("Cull Face Enable Failed.");
   glCullFace(GL_BACK);     GL_CHECK("Cull Face Back Failed.");
   glFrontFace(GL_CCW);     GL_CHECK("CCW Winding Failed.");
   ViewMatrix = glm::lookAt(glm::vec3(0.0f,0.0f,4.0f), glm::vec3(0.0,0.0,0.0),
                            glm::vec3(0.0,1.0,0.0));
   return 0;
}


The most interesting thing about this is that when I check the value of GlewInitResult, it turns out to be GLEW_OK, but I am still failing the glewInit() call. Maybe it has something to do with OpenGL? By the way, here is the GL_CHECK macro:

Code: Select all
#ifdef DEBUG
   #define GL_CHECK(M) if(glGetError() != GL_NO_ERROR) Debug::LogError(#M);
#else
   #define GL_CHECK(M)
#endif


Debug::LogError() simply prefaces the message with "ERROR: " to indicate that an error has occurred (saves the fingers a little bit).

Another odd thing is that when I run the program, the screen has a seizure for a couple of seconds, blinking on and off very rapidly. I don't know if this has anything to do with my computer, or if it is OpenGL/GLEW/GLFW related.

I am running Fedora 15 on the T61p, with the most up-to-date nVidia drivers I could find. Any help would be appreciated.

EDIT: So I think I seemed to fixed the seizure issue. I will have to do some more testing to determine the true root of the problem, but when I used the following parameters when I am binding my texture, it seemed to work properly. I had been using variables inside of a custom Texture2D object to determine S and T wrap, and min and mag filter parameters:

Code: Select all
   glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
   glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
   glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

When I updated my code to the above, the flickering stopped. Maybe this will help somebody, I don't really know. But it is here in case somebody runs into the same problem. I am still getting the glewInit() failure, though, but that's to be expected. I have not figured out how to solve that problem yet.

EDIT++: This seems to have fixed the seizure issue.