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 3 of 3

Thread: difficulty with main

  1. #1
    Intern Contributor
    Join Date
    May 2017
    Posts
    80

    difficulty with main

    Hi everyone, new to OpenGL here.

    I can experiment for giggles by changing glutInitWindowSize and WindowSize but doing so with no perceptible effect. Why can't I change my glutInitWindowSize/WindowSize?
    Code cpp:
    #include <windows.h>  // for MS Windows
    #include <GL/glut.h>  // GLUT, include glu.h and gl.h
     
    /* Handler for window-repaint event. Call back when the window first appears and
       whenever the window needs to be re-painted. */
    void display() {
       glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set background color to black and opaque
       glClear(GL_COLOR_BUFFER_BIT);         // Clear the color buffer (background)
     
       // Draw a Red 1x1 Square centered at origin
       glBegin(GL_QUADS);              // Each set of 4 vertices form a quad
          glColor3f(1.0f, 0.0f, 0.0f); // Red
          glVertex2f(-0.5f, -0.5f);    // x, y
          glVertex2f( 0.5f, -0.5f);
          glVertex2f( 0.5f,  0.5f);
          glVertex2f(-0.5f,  0.5f);
       glEnd();
     
       glFlush();  // Render now
    }
     
    /* Main function: GLUT runs as a console application starting at main()  */
    int main(int argc, char** argv) {
       glutInit(&argc, argv);                 // Initialize GLUT
       glutCreateWindow("OpenGL Setup Test"); // Create a window with the given title
       glutInitWindowSize(320, 320);   // Set the window's initial width & height
       glutInitWindowPosition(50, 50); // Position the window's initial top-left corner
       glutDisplayFunc(display); // Register display callback handler for window re-paint
       glutMainLoop();           // Enter the event-processing loop
       return 0;
    }
    int main(int argc, char** argv) {
       glutInit(&argc, argv);                 // Initialize GLUT
       glutCreateWindow("OpenGL Super Setup Test"); // Create a window with the given title
       glutInitWindowSize(250, 280);   // Set the window's initial width & height
       glutInitWindowPosition(45, 45); // Position the window's initial top-left corner
       glutDisplayFunc(display); // Register display callback handler for window re-paint
       glutMainLoop();           // Enter the event-processing loop
       return 0;
    }
    Last edited by Dark Photon; 05-13-2017 at 09:17 AM.

  2. #2
    Intern Contributor
    Join Date
    May 2017
    Posts
    80
    How do I draw against a 1920 x 1080 screen then for eg? How do I transition from console screen to a screen like 1920 x 1080?

  3. #3
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,171
    Call glutInitWindowSize() and glutInitWindowPosition() before glutCreateWindow().

    If you want to resize/reposition a window after creation, use glutPositionWindow() or glutReshapeWindow().

    Re 1920x1080, if you want to make your window full-screen, see glutFullScreen().

Posting Permissions

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