window closes immediately

so im trying to create a window using glfw, but it doesn’t stay open. any help is appreciated :slight_smile:

the code i have right now:


#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glfw.h>

int main(){
	//init glfw
	if(!glfwInit()){
		fprintf(stderr, "failed to init glfw
");
		return -1;
	}

	//creating the window...hopefully
	glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); //4x antialiasing
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); //olpengl version 3.3
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
	glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //excluding old openGL functionality

	if( glfwOpenWindow( 1024, 768, 8,8,8,8, 32,0, GLFW_WINDOW ) ){
		fprintf(stderr, "failed to open GLFW window
");
		glfwTerminate();
		return -1;
	}

	//init glew (GL extension wrangler)
	glewExperimental = true;
	if(!glewInit()){
		fprintf(stderr, "failed to init GLEW
");
		return -1;
	}
	glfwSetWindowTitle("test av glfw og openGL 3.3");

	glfwEnable( GLFW_STICKY_KEYS );
 
	do{
		// Draw nothing, see you in tutorial 2 !
 
		// Swap buffers
		glfwSwapBuffers();
 
	} // Check if the ESC key was pressed or the window was closed
	while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &&
	glfwGetWindowParam( GLFW_OPENED ) );

	return 0;

}

ok, i changed this code:

if(!glewInit()){
	fprintf(stderr, "failed to init GLEW
");
	return -1;
}

with this code:

if(glewInit() != GLEW_OK){
	fprintf(stderr, "failed to init GLEW
");
	return -1;
}

and it seems my problem is that glew does not initialize propperly, any ideas why?

it seems that glew is complaining about a “missing GL version”

how can i fix this? :frowning:

Hi,
Could u copy and paste the error reported on your console?

i have already posted the error message: “missing GL version”

i have been digging around and most of the people getting this error message seems to be caused by no opengl context, but i have already created a context, havent i?

this seems to be caused by me trying to use opengl version 3.3
do i have to install something to be able to develop using it?

May be your hardware does not support opengl 3.3 core profile. Which hardware are u running this on?

im not sure, but it looks like it supports 3.0, but not any “minor” versions (not sure how to explain it)

i can not use 3.3, bu i can use 3
i can not use 2.2, but i can use 2

have i done anything wrong with the VERSION_MINOR code? or does my hardware simply not support “minor version numbers”?

EDIT: how can i check if the hardware supports it?

[QUOTE=even821;1249672]im not sure, but it looks like it supports 3.0, but not any “minor” versions (not sure how to explain it)

i can not use 3.3, bu i can use 3
i can not use 2.2, but i can use 2

have i done anything wrong with the VERSION_MINOR code? or does my hardware simply not support “minor version numbers”?

EDIT: how can i check if the hardware supports it?[/QUOTE]
You can use OpenGL Extension Viewer which will list all of the supported versions of OpenGL on your hardware.

ye, it seems my pc dont support opengl versions past 3.0 :frowning: (it partly supports 3.1, but not fully)

oh well, i can still use shaders (glsl) and stuff in opengl 3.0, ye?

[QUOTE=even821;1249674]ye, it seems my pc dont support opengl versions past 3.0 :frowning: (it partly supports 3.1, but not fully)

oh well, i can still use shaders (glsl) and stuff in opengl 3.0, ye?[/QUOTE]
Yes you can however the shaders will not have recent features.

i can live with that. thanks for all you help! :smiley: