PDA

View Full Version : window closes immediately



even821
04-07-2013, 12:31 PM
so im trying to create a window using glfw, but it doesn't stay open. any help is appreciated :)

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\n");
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\n");
glfwTerminate();
return -1;
}

//init glew (GL extension wrangler)
glewExperimental = true;
if(!glewInit()){
fprintf(stderr, "failed to init GLEW\n");
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;

}

even821
04-07-2013, 01:40 PM
ok, i changed this code:


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

with this code:


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

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

even821
04-07-2013, 01:45 PM
it seems that glew is complaining about a "missing GL version"

how can i fix this? :(

mobeen
04-07-2013, 08:06 PM
Hi,
Could u copy and paste the error reported on your console?

even821
04-08-2013, 12:20 AM
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?

even821
04-08-2013, 05:38 AM
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?

mobeen
04-08-2013, 05:46 AM
May be your hardware does not support opengl 3.3 core profile. Which hardware are u running this on?

even821
04-08-2013, 06:38 AM
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?

mobeen
04-08-2013, 07:00 AM
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?
You can use OpenGL Extension Viewer (http://www.realtech-vr.com/glview/) which will list all of the supported versions of OpenGL on your hardware.

even821
04-08-2013, 07:08 AM
ye, it seems my pc dont support opengl versions past 3.0 :( (it partly supports 3.1, but not fully)

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

mobeen
04-08-2013, 08:19 AM
ye, it seems my pc dont support opengl versions past 3.0 :( (it partly supports 3.1, but not fully)

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

even821
04-08-2013, 12:33 PM
Yes you can however the shaders will not have recent features.

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