Jump to content
  • Advertisement
Sign in to follow this  
fab2

OpenGL No rendering when I specify GL version with glfwWindowHint

This topic is 1030 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

Hi,

 

I'm writing a simple game engine and I'm using glfw. I'm trying to make this work on both Mac and Windows. I'm a bit confused about what happens on Win. This is the way I initialize glfw:

if (!glfwInit())
	exit(-1);

//glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
//glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
        
window = glfwCreateWindow(width, height, appName, NULL, NULL);
if (!window) {	
	glfwTerminate();
	exit(-1);
}
glfwMakeContextCurrent(window);

With this initialization, everything works and I can render correctly a test quad on the screen. Just to give you an idea, this is the renderer and OpenGL version I get:

 

Renderer: Quadro NVS 295/PCIe/SSE2
OpenGL version supported 3.3.0

 

If however I uncomment the first three glfwWindowHint, everything works but I don't see anything on the screen (the same happens on the Mac). I still see that the OpenGL version supported is 3.3.0. Why the quad stops being rendered when I hint the GL version? For completeness, these are the shaders I'm using (very simple)

#version 330 core

layout(location=0) in vec3 g_position;
layout(location=2) in vec2 g_texcoord;

uniform mat4 g_mvMat;
uniform mat4 g_projMat;

out vec2 Tex;

void main ()
{
	Tex = g_texcoord;
	gl_Position = g_projMat * g_mvMat * vec4 ( g_position, 1.0 );
}

#version 330 core

in vec3 Position;
in vec2 Tex;

out vec4 fragColor;

uniform sampler2D Tex1;

void main()
{
	vec4 texColor = texture( Tex1, Tex );
    if (texColor.a < 0.5)
        discard;
	fragColor = texColor;

}

Thanks!

 

 

 

 

 

Share this post


Link to post
Share on other sites
Advertisement

For anyone who has the same problem, I found that the app didn't render anything because I was not using VAO, and in core profile they are mandatory!

Share this post


Link to post
Share on other sites


Why the quad stops being rendered when I hint the GL version?

Keep in mind that GL_QUADS is also removed from forward compatible contexts. I assume your quad is actually drawn with GL_TRIANGLES?

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!