PDA

View Full Version : GLFW vs. FreeGlut: Initial window size



chachacha
06-17-2017, 03:36 AM
(Mods, I got no response in the Toolkits forum so posting here)

The size of the OpenGL window created using GLFW with the statement

glfwCreateWindow(500, 500, "test.cpp", NULL, NULL);

is a lot smaller than that created using FreeGlut with the statement

glutInitWindowSize(500, 500);

At least on my system. Any idea why might be? Thanks.

Dark Photon
06-17-2017, 08:50 AM
(Mods, I got no response in the Toolkits forum so posting here)

Please read Forum Posting Guidelines (https://www.opengl.org/discussion_boards/showthread.php/176139-Forum-Posting-Guidelines?p=1230021&viewfull=1#post1230021). In particular, don't cross-post. Given that the posting rate on this site isn't torential, I think most folks read everything that is posted on these forums.



The size of the OpenGL window created using GLFW with the statement

glfwCreateWindow(500, 500, "test.cpp", NULL, NULL);

is a lot smaller than that created using FreeGlut with the statement

glutInitWindowSize(500, 500);

At least on my system. Any idea why might be? Thanks.

No, no idea.

You might follow-up with more detail. For instance, exactly what size is each window coming up? Is either one correct? Which one? That'll at least give folks something else to go on here. You might also post a short, standalone test program for the broken one that illustrates the problem. That way, folks can download/compile/try it locally, and give you some feedback.

chachacha
06-17-2017, 01:14 PM
Both programs are pretty trivial, basically window creation in main(). Here are the pixel dimensions of the created windows:
FreeGlut:752 x 798
GLFW: 502 x 546

So, neither is what's asked for, neither is square, and their dimensions and aspect ratios are different from one another. Why?

Dark Photon
06-17-2017, 01:55 PM
Both programs are pretty trivial, basically window creation in main(). Here are the pixel dimensions of the created windows:
FreeGlut:752 x 798
GLFW: 502 x 546

So, neither is what's asked for, neither is square, and their dimensions and aspect ratios are different from one another. Why?

Just looking at those numbers, I suspect your GLFW window is correct. That is, it looks like you may be counting the pixels for the window decorations (border) that you can't draw on. I suspect the interior of the window that you can draw on is 500x500, but check that out.

I'm not sure what's going on with your GLUT window. Try this:


#include <GL/gl.h>
#include <GL/glut.h>

//================================================== ==========================

void Setup()
{
glClearColor( 0.27, 0.50, 0.70, 1.0 );
}

//================================================== ==========================

void reshape(GLsizei w, GLsizei h)
{
h = (h == 0 ? 1 : h );

glViewport(0, 0, w, h);

glutPostRedisplay();
}

//================================================== ==========================

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}

//================================================== ==========================

void keyboard( unsigned char key, int x, int y )
{
// Key Bindings
switch( key )
{
case 27 : exit(0); break;
}
glutPostRedisplay();
}

//================================================== ==========================

int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowPosition(0, 0);
glutInitWindowSize(500,500);
glutCreateWindow("Window Test");

glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);

// Not needed
//glutReshapeWindow(500,500);

Setup();

glutMainLoop();
}


If you still see problems, which platform are you on, and what GLUT lib and version are you using (e.g. freeglut, etc.)?

WhiteSword
06-18-2017, 03:30 AM
Here's an interesting discussion that might help you.

chachacha
06-19-2017, 08:33 AM
Just looking at those numbers, I suspect your GLFW window is correct. That is, it looks like you may be counting the pixels for the window decorations (border) that you can't draw on. I suspect the interior of the window that you can draw on is 500x500, but check that out.

I'm not sure what's going on with your GLUT window. Try this:


#include <GL/gl.h>
#include <GL/glut.h>

//================================================== ==========================

void Setup()
{
glClearColor( 0.27, 0.50, 0.70, 1.0 );
}

//================================================== ==========================

void reshape(GLsizei w, GLsizei h)
{
h = (h == 0 ? 1 : h );

glViewport(0, 0, w, h);

glutPostRedisplay();
}

//================================================== ==========================

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}

//================================================== ==========================

void keyboard( unsigned char key, int x, int y )
{
// Key Bindings
switch( key )
{
case 27 : exit(0); break;
}
glutPostRedisplay();
}

//================================================== ==========================

int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowPosition(0, 0);
glutInitWindowSize(500,500);
glutCreateWindow("Window Test");

glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);

// Not needed
//glutReshapeWindow(500,500);

Setup();

glutMainLoop();
}


If you still see problems, which platform are you on, and what GLUT lib and version are you using (e.g. freeglut, etc.)?

Thanks for the code. Tried it and the size is exactly as mine 752 x 798. I am using FreeGlut -MSVC-2.8.1 and the platform is Win10/MSVS 2015.

mhagain
06-19-2017, 09:43 AM
In the Windows 10 Settings app, type "dpi" into the "Find a setting" box - "Change the size of text, apps and other items" should appear as a suggestion, so click on that.

Under "Scale and layout", "Change the size of text, apps and other items" you will find that you have it set to 150%.

Basically, GLFW is ignoring your DPI settings whereas FreeGLUT is respecting them.

chachacha
06-19-2017, 09:08 PM
In the Windows 10 Settings app, type "dpi" into the "Find a setting" box - "Change the size of text, apps and other items" should appear as a suggestion, so click on that.

Under "Scale and layout", "Change the size of text, apps and other items" you will find that you have it set to 150%.

Basically, GLFW is ignoring your DPI settings whereas FreeGLUT is respecting them.

Bingo! Thanks. That's exactly what it was.