GLFW vs. FreeGlut: Initial window size

(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.

Please read Forum Posting Guidelines. 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.

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?

[QUOTE=chachacha;1287567]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?[/QUOTE]

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.)?

Here’s an interesting discussion that might help you.

[QUOTE=Dark Photon;1287568]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.)?[/QUOTE]

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.

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.

[QUOTE=mhagain;1287589]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.[/QUOTE]

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