Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: glfwOpenWindow() is failing

  1. #1
    Junior Member Newbie
    Join Date
    May 2010
    Location
    California
    Posts
    6

    glfwOpenWindow() is failing

    I can't seem to open a glfw window. Can somebody help me out?

    Code :
    #include <stdio.h>
    #include <stdlib.h>
    #include <GL\glew.h>
    #include <GL\glfw.h>
    #include <glm\glm.hpp>
     
    int main() {
    	// Initialize GLFW
    	if(!glfwInit()) {
    		fprintf(stderr, "Failed to initialize GLFW!\n");
    		return 1;
    	}
     
    	// Create the OpenGL window
    	glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); // 4x AA
    	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
    	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 1);
    	glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
     
    	GLFWvidmode vm;
    	glfwGetDesktopMode(&amp;vm);
    	// Open a window and create the OpenGL context
    	if(!glfwOpenWindow(800, 600, vm.RedBits, vm.GreenBits, vm.BlueBits, 0, 0, 0, GLFW_WINDOW)) {
    		fprintf(stderr, "Failed to open GLFW window!\n");
    		glfwTerminate();
    		return 2;
    	}
     
    	// Initialize GLEW
    	if(glewInit() != GLEW_OK) {
    		fprintf(stderr, "Failed to initialize GLEW!\n");
    		return 3;
    	}
     
    	glfwSetWindowTitle("OpenGL Application");
     
    	// Navy blue background
    	glClearColor(0.0f, 0.1f, 0.3f, 1.0f);
     
    	glfwEnable(GLFW_STICKY_KEYS);
     
    	do {
    		// Swap the front and back buffers
    		glfwSwapBuffers();
    	} while (glfwGetKey(GLFW_KEY_ESC) != GLFW_PRESS 
    		&amp;&amp; glfwGetWindowParam(GLFW_OPENED));
     
    	return 0;
    }

    The program compiles and links properly in VC++ 2010 Express. I've tried using various arguments to glfwOpenWindow(), but it fails every time.
    ...It is by will alone I set my mind in motion.

  2. #2
    Junior Member Newbie
    Join Date
    May 2010
    Location
    California
    Posts
    6

    Re: glfwOpenWindow() is failing

    In appendix A.2 of the GLFW Reference manual it says:


    GLFW uses the GLX_ARB_create_context_profile extension to provide support for context profiles. Where this extension is unavailable, setting the GLFW_OPENGL_PROFILE hint to anything but zero will cause glfwOpenWindow to fail.


    So I set GLFW_OPENGL_PROFILE to 0 and it works. The reference also says that setting GLFW_OPENGL_PROFILE to 0 let's the system choose. Is this a good or a bad thing? I want to use just the features available in the core profile, so will this matter?
    ...It is by will alone I set my mind in motion.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2012
    Posts
    1

    Re: glfwOpenWindow() is failing

    I'm not sure but, is the core_profile compatible with opengl 3.1? You could try with 3.2 if your card is capable

  4. #4
    Junior Member Newbie
    Join Date
    May 2010
    Location
    California
    Posts
    6

    Re: glfwOpenWindow() is failing

    I got it working. You can't have GLFW_OPENGL_VERSION_MINOR set to anything less than 3 if you want to use just the core profile which makes perfect sense. I don't know why I didn't realize that sooner.
    ...It is by will alone I set my mind in motion.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •