Why do I fail to create a window?

Started by
8 comments, last by Gooey 9 years, 11 months ago

Hello everyone,

can someone please tell me the problem, couse I tryed to find why but it looks like it have'nt happen to anyone alse then me... (so unlucky..)

Here is the code:


#include <stdio.h>
#include <stdlib.h>
#include <GL\glew.h>
#include <GLFW\glfw3.h>

int main(){

	if (glfwInit() == false)
	{
		fprintf(stderr, "Failed to initialize GLFW");
		return -1;
	}

	glfwWindowHint(GLFW_SAMPLES, 4);
	glfwWindowHint(GLFW_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_VERSION_MINOR, 3);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

	GLFWwindow* window;
	window = glfwCreateWindow(1024, 768, "yaniv's game", NULL, NULL);
	if (window == NULL)
	{
		fprintf(stderr, "Failed to create a GLFW window");
		glfwTerminate();
		return -1;
	}
Advertisement

Never used glfw, but try

window = new glfwCreateWindow(1024, 768, "yaniv's game", NULL, NULL);

Never used glfw, but try

window = new glfwCreateWindow(1024, 768, "yaniv's game", NULL, NULL);

Absolutely not.

Considering there's not a lot of code there, try commenting out all the window hints. Maybe you're asking for a profile version or antialiasing setting you can't get.

SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

I just deleted those 4 hints and it work.

Don't you have the major/minor version macros wrong?

This is what I use:


glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
Note the difference
If it dosn't work, run the GLEW example tool which finds your highest supported OpenGL and all possible extensions and use that as hint
As KaiserJohan said the version hints you used are from the last glfw you are using glfw 3 by the look of it which uses
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
Instead of the old way from 2.7.3 and below of
glfwWindowHint(GLFW_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_VERSION_MINOR, 3);
I haven't used GLFW myself, but a quick google indicates it has an error callback facility, which might help diagnose such issues.

Hey guys I done what u guys said about the glew_context_version but still I fail to create a window becouse:


glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

is making all the problem, when ever I delete this line of code I can create the window.

Check what version of open gl you can use maybe your card doesn't support 3.3
Sorry a quick check of glfw3's documentation says that
glfwWindowHint(GLFW_OPENGL_ANY_PROFILE, GLFW_OPENGL_CORE_PROFILE);
Is the new way you can check out the documentation at http://www.glfw.org/docs/latest/window.html

This topic is closed to new replies.

Advertisement