Results 1 to 6 of 6

Thread: glViewport & how to use it

  1. #1
    Senior Member Regular Contributor
    Join Date
    Mar 2005
    Posts
    115

    glViewport & how to use it

    Hi,

    I am have a map for my program that pops up when ever I press 'm', but I would create a new subwindow for it and it ate too much memory so I thought glViewport would be a better way to go. My problem is that I can't figure out how to get it to work. Here is my code.

    Code :
    void map()
    {
    	glViewport(900,0,1000,100);
     
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
    	glOrtho(-10, 10, -10, 10, -10,10);
    	glMatrixMode(GL_MODELVIEW);
    	glLoadIdentity();
     
    	<draw map>
    }
     
    void update()
    {
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
    	gluPerspective(60, 1000/700, 0.1, 50);
    	glMatrixMode(GL_MODELVIEW);
    	glLoadIdentity();
    	gluLookAt(view.x,view.y, view.z, view.lx, view.ly, view.lz, 0, 0, 1);
    	}
    }
     
    void display()
    {
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    	glViewport(0,0,width,hight);
    	glLoadIdentity();
     
    	update();
     
    	<draw scene>
     
    	if(button[M])
    		map();
     
    	glutPostRedisplay();
    	glutSwapBuffers();
    	glFlush();
    }
    What am I doing wrong? All replies are greatly appretiated

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jan 2001
    Location
    Ukraine
    Posts
    101

    Re: glViewport & how to use it

    Maybe you need to clear depth (and color) buffer before use of viewport (use scissors for applying clear operations to viewport only) or what you mean "how to get it to work!"?

  3. #3
    Senior Member Regular Contributor
    Join Date
    Mar 2005
    Posts
    115

    Re: glViewport & how to use it

    well I tried that, but I still got the same effect

  4. #4
    Member Contributor
    Join Date
    Apr 2005
    Location
    Prague, Czech Republic
    Posts
    87

    Re: glViewport & how to use it

    Have you tried
    glViewport(900,0,100,100);
    ?

    glViewport( x,y, !width!, height )

  5. #5
    Senior Member Regular Contributor
    Join Date
    Jan 2001
    Location
    Ukraine
    Posts
    101

    Re: glViewport & how to use it

    Originally posted by Terminatore3:
    well I tried that, but I still got the same effect
    What kind of effect you contemplate? Need to say that glViewport is work fine for me, so please don't expect that OpenGl is broken in this part...

  6. #6
    Senior Member Regular Contributor
    Join Date
    Mar 2005
    Posts
    115

    Re: glViewport & how to use it

    Man, I'm an idiot, thnx sorry for your time.

Similar Threads

  1. using glViewport
    By richman.feynard in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 08-31-2017, 04:07 AM
  2. glViewport
    By A elalaily in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 12-26-2009, 02:57 PM
  3. glViewport
    By V-man in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-08-2005, 05:54 PM
  4. glViewport
    By gurkama in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-14-2005, 10:46 PM
  5. glViewport()
    By huizhang in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-24-2002, 12:12 PM

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