Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: GLFW vs. FreeGlut: Initial window size

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2015
    Posts
    16

    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
    Code :
    glfwCreateWindow(500, 500, "test.cpp", NULL, NULL);

    is a lot smaller than that created using FreeGlut with the statement
    Code :
    glutInitWindowSize(500, 500);

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

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,123
    Quote Originally Posted by chachacha View Post
    (Mods, I got no response in the Toolkits forum so posting here)
    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
    Code :
    glfwCreateWindow(500, 500, "test.cpp", NULL, NULL);

    is a lot smaller than that created using FreeGlut with the statement
    Code :
    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.
    Last edited by Dark Photon; 06-17-2017 at 08:59 AM.

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2015
    Posts
    16
    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?

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,123
    Quote Originally Posted by chachacha View Post
    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:

    Code cpp:
    #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.)?

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2017
    Posts
    5
    Here's an interesting discussion that might help you.

  6. #6
    Junior Member Newbie
    Join Date
    Dec 2015
    Posts
    16
    Quote Originally Posted by Dark Photon View Post
    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:

    Code cpp:
    #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.

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,687
    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.

  8. #8
    Junior Member Newbie
    Join Date
    Dec 2015
    Posts
    16
    Quote Originally Posted by mhagain View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •