Hey,
I’m relatively new to OpenGL, I’m still experimenting with different techniques etc. I got a window up and running with GLFW and GLEW, soon I started rendering cubes, camera movement and shaders in OpenGL 3.0+. I used the GLEW binaries so far, but for some reason it just failed to work at some point. So I downloaded the source of GLEW, imported the visual studio project into Code::Blocks, and build the libglew_static.a. Of course I made sure I had the newest version of everything (glew 1.7 and glfw 2.7.5).
The window setup works all fine, no problem on GLFW’s part, but as soon as I call glewInit() it throws a GL_INVALID_ENUM error, and the function returns GLEW_ERROR_NO_GL_VERSION. If I don’t check for errors and just continue as if nothing happened, it seems to render fine on some machines, and on others it just shows a black screen.
Including gl headers:
// OpenGL
#define GLFW_NO_GLU
#define GLEW_STATIC
#include "GL/glew.h"
#include "GL/glfw.h"
Also I’m pretty sure I linked everything correctly. I build the ‘engine’ in a .dll, I linked libglew_static.a, libglfw.a, opengl32, kernel32, in that exact order. The actual test project which uses the engine only links to the engine .dll, and of course it searches in it’s include directory for header files. It doesn’t show any errors when compiling, it simply throws them when I run the program.
The actual setup:
//-----------------------------------------------------------------------
Console::Console() :
_open(false),
_frameCap(0),
_prevTime(0.0),
_frameTime(0.0),
_major(3),
_minor(0),
_width(800),
_height(600),
_visCursor(false),
_scene(0)
{
// Initialize GLFW
*this << "Initializing...
";
if(glfwInit())
{
int maj, min, rev;
glfwGetVersion(&maj, &min, &rev);
*this << "GLFW Version " << maj << "." << min << "." << rev << " loaded.
";
}
else *this << "Unable to load GLFW.
";
}
............
//-----------------------------------------------------------------------
bool Console::openWindow(const int &width, const int &height, const char *title, bool resizeable)
{
//-----------------------------------------------------------------------
// Already open
if(_open) return false;
// Set properties
glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, _major);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, _minor);
glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, !resizeable);
// Set resolution
_width = width > 0 ? width : _width;
_height = height > 0 ? height : _height;
// Open window and set title
if(!glfwOpenWindow(_width, _height, 0,0,0,0, 32,0, GLFW_WINDOW)) return false;
glfwSetWindowTitle(title);
// Resize
glfwSetWindowSizeCallback(Utils::resize);
//-----------------------------------------------------------------------
// Get OpenGL Version
int major = glfwGetWindowParam(GLFW_OPENGL_VERSION_MAJOR);
int minor = glfwGetWindowParam(GLFW_OPENGL_VERSION_MINOR);
if(major < 3)
{
// Cannot go below 3.0
*this << "OpenGL Version 3.0 is not supported.
";
closeWindow();
return false;
}
*this << "OpenGL Version " << major << "." << minor << " loaded.
";
// Initialize GLEW, Normally I check for glewInit() != GLEW_OK
if(glewInit() == GLEW_ERROR_NO_GL_VERSION);
{
*this << "Unable to load GLEW.
";
//closeWindow(); commented this for testing purposes
//return false;
}
*this << "GLEW Version " << glewGetString(GLEW_VERSION) << " loaded.
";
//-----------------------------------------------------------------------
// Initialize OpenGL
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// Culling
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);
glCullFace(GL_BACK);
// Depth
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LEQUAL);
glDepthRange(0.0f, 1.0f);
glClearDepth(1.0);
// Set Open Flag
return _open = true;
}
I ‘replaced’ std::cout << by overloading the << operator, so the console outputs:
Initializing...
GLFW Version 2.7.5 loaded.
OpenGL Version 3.0 loaded.
Unable to load GLEW.
GLEW Version 1.7.0 loaded. < shows that because I temporarily disabled the close-at-error thingy
Again, when I start rendering using this setup code it renders fine, on some machines, but of course thats not what I’d prefer I scouted the internet for solutions but none worked so far.
Edit: btw, I’m on windows 7 if that matters
Thanks for any help
-Ckef