soulfreezer wrote on Thursday, August 05, 2010:
Hello,
I have problems to understand how the callback in GLFW works. If I use the
glfwSetWindowSizeCallback-function, my callback-function will be called two
times?! Is this a bug? Is the first opening of a window detected as
"resize"-event?
Here is my little code, maybe can someone help me out with this
#include “Run.h”
#include “FileLogger.h”
FileLogger fileLogger;
void init()
{
fileLogger.log(“Calling init()-Method…”);
fileLogger.log("…");
fileLogger.log(“init()-Method finished.”);
}
void GLFWCALL WindowResize( int width, int height )
{
fileLogger.log(“Calling WindowResize()-Method…”);
fileLogger.log("…");
fileLogger.log(“WindowResize()-Method finished.”);
}
void renderLoop()
{
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers();
}
int main( void )
{
int running = GL_TRUE;
glfwInit();
if( !glfwOpenWindow( 1024, 768, 32,32,32,32,0,0, GLFW_WINDOW ) )
{
glfwTerminate();
return 0;
}
init();
glfwSetWindowSizeCallback( WindowResize );
while( running )
{
renderLoop();
running = !glfwGetKey( GLFW_KEY_ESC ) && glfwGetWindowParam(
GLFW_OPENED );
}
glfwTerminate();
return 0;
}
Here the Headerfile:
#ifndef RUN_H_
#define RUN_H_
#include <GL/glfw.h>
void GLFWCALL WindowResize( int width, int height );
void renderLoop();
void init();
#endif /* RUN_H_ */
In my Logfile I find this strange output:
05.08.2010 21:34:07 Calling init()-Method…
05.08.2010 21:34:07 …
05.08.2010 21:34:07 init()-Method finished.
05.08.2010 21:34:07 Calling WindowResize()-Method…
05.08.2010 21:34:07 …
05.08.2010 21:34:07 WindowResize()-Method finished.
05.08.2010 21:34:07 Calling WindowResize()-Method…
05.08.2010 21:34:07 …
05.08.2010 21:34:07 WindowResize()-Method finished.
I am working under Ubuntu 10.04 LTS - Lucid Lynx -
Thanx so much for help
greetz
soul