Results 1 to 2 of 2

Thread: resolution problems in glut

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2001
    Location
    Islamabad,capital,Pakistan.
    Posts
    14

    resolution problems in glut

    I am working on a simple 2D application in glut. The problem is that I set glutOrtho2D() and glViewport() according to the screenWidth and screen height I want. but wheen I change the resolution of windows the resolution of the glut application does not change accordingly.
    My second problem is that I use a function to reshape the viewport of the window but it reshapes the window as such that it leaves quit alot of space either vertically on one side or horizontally down. What should I do. The funcrtion that I pass to
    glutReshapeFunc() is as follows. If anyone can provide me a better solution I will be very thankfull:
    (I took it from the book computer graphics using openGL by F.S.HILL JR)
    ///////////////////////////////////////////
    void main(int argc, char** argv)
    {
    glutInit(&argc, argv); //initialize the toolkit
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); //set display mode
    glutInitWindowSize(screenWidth, screenHeight); //set window size
    // glutInitWindowPosition(100,100); //set window position on screen
    var=glutCreateWindow("Dot plot of a function"); //open the screen window
    glutFullScreen();
    glutDisplayFunc(myDisplay); //register redraw function
    myInit();
    glutReshapeFunc(myReshape);
    createGLUTMenus();
    glutMainLoop(); //go into a perpetual loop
    }
    //<<<<<<<<<<<<<<<<<<End of the Main Function>>>>>>>>>>>>>>>>>>>
    //<<<<<<<<<<<<<<<<<<myReshape Func>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    void myReshape(GLsizei W, GLsizei H)
    {
    int R = screenWidth/screenHeight;
    if(R==W/H)
    glViewport(0,0,W,H);
    if(R> W/H)
    glViewport(0,0,W,W/R);
    else
    glViewport(0,0,H*R,H);
    }
    Only Human

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: resolution problems in glut

    The problem is that I set glutOrtho2D() and glViewport() according to the screenWidth and screen height I want.
    I don't see where you call gluOrtho2D.

    Also, your reshape function contains lots of uneeded code. if you want the viewport to cover the entire window, just put this into your reshape function.
    Code :
    void myReshape(GLsizei W, GLsizei H)
    {
        glViewport(0, 0, W, H);
    }
    No need to mess with aspect ratio, since you have the size of the window passed to the function.

Similar Threads

  1. Replies: 4
    Last Post: 02-12-2015, 01:38 AM
  2. FBO resolution problems
    By Nowhere-01 in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 06-29-2011, 04:25 AM
  3. Frame buffer resolution with high resolution textures ?
    By totof in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 04-25-2003, 06:26 AM
  4. problems with glut
    By Tresher in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-14-2002, 06:02 AM
  5. New GLUT Problems
    By MrShoe in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-07-2001, 04:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean