Jump to content
  • Advertisement
Sign in to follow this  
ronnybrendel

OpenGL [solved] glfw doesnt work properly

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

- im running kubuntu 6.06 (ubuntu with kde - ubuntu is a debian derivative ) - my xorg: $~/src/test_opengl$ Xorg -version X Window System Version 7.0.0 Release Date: 21 December 2005 X Protocol Version 11, Revision 0, Release 7.0 - my problem: no callbacks are called: no reshape, no mouse, no keyboard :( ... i have tried to call "glfwPollEvents()" by hand (tho the docs say it isnt necessary) .. doesnt work
int main( int argc, char** argv ) {


	GLFWvidmode videomode;
	int width;
	int height;
	int alphabits;
	int depthbits;
	int stencilbits;
	double timernew; /* holds the new time */
	double timerold; /* holds the old time */
	double timer; /* holds the timeinterval important for calculations */

	glfwInit();
	glfwGetDesktopMode( &videomode );
	
	
	if( GLFW_FULLSCREEN == MODE ) {
		width= videomode.Width;
		height= videomode.Height;
	} else {
		width= WIDTH;
		height= HEIGHT;
	}
	alphabits= ALPHABITS;
	depthbits= DEPTHBITS;
	stencilbits= STENCILBITS;


	/* set callbacks */
	glfwSetWindowSizeCallback( reshape );
	glfwSetKeyCallback( keyboardInput );
	glfwSetCharCallback( characterInput );
	glfwSetMousePosCallback( mousePos );
	glfwSetMouseButtonCallback( mouseButton );
	glfwSetMouseWheelCallback( mouseWheel );


	/* stuff */
	glfwDisable( GLFW_SYSTEM_KEYS ); // preventing alt+tab
	
	/* windowsetup */
	glfwOpenWindow( width, height, videomode.RedBits, videomode.GreenBits, videomode.BlueBits, alphabits, depthbits, stencilbits, MODE );
	glfwSetWindowTitle( "test_opengl" );
	glfwSetWindowPos( 0, 0 );


	timerold= glfwGetTime();

	while( false == stop ) {

		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
		timernew= glfwGetTime();
		timer= timernew-timerold;

		// TODO


		timerold= timernew;
		glfwSwapBuffers();
	}

	glfwCloseWindow();
	glfwTerminate();
	
	return 0;
}


Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by ronnybrendel
- im running kubuntu 6.06 (ubuntu with kde - ubuntu is a debian derivative )

- my xorg:
$~/src/test_opengl$ Xorg -version
X Window System Version 7.0.0
Release Date: 21 December 2005
X Protocol Version 11, Revision 0, Release 7.0

- my problem: no callbacks are called: no reshape, no mouse, no keyboard :( ... i have tried to call "glfwPollEvents()" by hand (tho the docs say it isnt necessary) .. doesnt work


*** Source Snippet Removed ***


try setting the callbacks after creating the window.

int main( int argc, char** argv ) {


GLFWvidmode videomode;
int width;
int height;
int alphabits;
int depthbits;
int stencilbits;
double timernew; /* holds the new time */
double timerold; /* holds the old time */
double timer; /* holds the timeinterval important for calculations */

glfwInit();
glfwGetDesktopMode( &videomode );


if( GLFW_FULLSCREEN == MODE ) {
width= videomode.Width;
height= videomode.Height;
} else {
width= WIDTH;
height= HEIGHT;
}
alphabits= ALPHABITS;
depthbits= DEPTHBITS;
stencilbits= STENCILBITS;


/* windowsetup */
glfwOpenWindow( width, height, videomode.RedBits, videomode.GreenBits, videomode.BlueBits, alphabits, depthbits, stencilbits, MODE );
glfwSetWindowTitle( "test_opengl" );
glfwSetWindowPos( 0, 0 );


/* set callbacks */
glfwSetWindowSizeCallback( reshape );
glfwSetKeyCallback( keyboardInput );
glfwSetCharCallback( characterInput );
glfwSetMousePosCallback( mousePos );
glfwSetMouseButtonCallback( mouseButton );
glfwSetMouseWheelCallback( mouseWheel );


/* stuff */
glfwDisable( GLFW_SYSTEM_KEYS ); // preventing alt+tab

timerold= glfwGetTime();

while( false == stop ) {

glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
timernew= glfwGetTime();
timer= timernew-timerold;

// TODO


timerold= timernew;
glfwSwapBuffers();
}

glfwCloseWindow();
glfwTerminate();

return 0;
}

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!