Jump to content
  • Advertisement
Sign in to follow this  
LiziPizi

OpenGL Why do I fail to create a window?

This topic is 1673 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;
	}

Share this post


Link to post
Share on other sites
Advertisement

Never used glfw, but try

 

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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
Edited by KaiserJohan

Share this post


Link to post
Share on other sites
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);
Edited by Gooey

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!