gav-kr wrote on Thursday, May 08, 2014:
Hello,
I have recently started working with OpenGL Shading Language but the most simple of the program is not running properly. I am working with the following versions of the extensions.
Windows 8.1 64 bit
GLFW: glfw-3.0.4
GLEW: glew-1.0.9
GLM: 0.9.5.2
Below is the main function where the program is throwing a run-time exception after I create the GLFW window using glfwCreateWindow eventually saying “Cannot initialize window.”
Can someone please identify the issue which is causing this.
// initialise GLFW
if(!glfwInit())
throw std::runtime_error("glfwInit failed");
// open a window with GLFW
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_VERSION_MINOR, 2);
//glfwWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE);
window = glfwCreateWindow((int)SCREEN_SIZE.x, (int)SCREEN_SIZE.y, "GLEW and GLFW Test Run",NULL, NULL);
if(!window)
{
std::cout << "Cannot initialize window" << std::endl;
throw std::runtime_error("glfwOpenWindow failed. Can your hardware handle OpenGL 3.2?");
}
// initialise GLEW
glewExperimental = GL_TRUE; //stops glew crashing on OSX :-/
if(glewInit() != GLEW_OK)
throw std::runtime_error("glewInit failed");
// print out some info about the graphics drivers
std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
std::cout << "GLSL version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
std::cout << "Vendor: " << glGetString(GL_VENDOR) << std::endl;
std::cout << "Renderer: " << glGetString(GL_RENDERER) << std::endl;
// make sure OpenGL version 3.2 API is available
if(!GLEW_VERSION_3_2)
throw std::runtime_error("OpenGL 3.2 API is not available.");
// load vertex and fragment shaders into opengl
LoadShaders();
// create buffer and fill it with the points of the triangle
LoadTriangle();
// run while the window is open
while(glfwGetWindowAttrib(window, GLFW_VISIBLE)){
// draw one frame
Render();
}
// clean up and exit
glfwTerminate();