Results 1 to 2 of 2

Thread: glScissor() and gluOrtho2D()

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2009
    Posts
    2

    glScissor() and gluOrtho2D()

    Hi,
    I have a little problem with using these two function, if anyone could help
    What I want to achieve ?
    - draw a few points at the window
    - draw at the bottom small view of this drawed points

    First I draw the points, then after glScissor() and glViewPort(), I'm trying to make a orthographic viewing, but it only shows the black screen.

    Code :
    #include <GL/glut.h>
    #include <stdio.h>
    #include <stdlib.h>
     
    void display()
    {
    	int i;
     
    	glEnable(GL_SCISSOR_TEST);
            glMatrixMode(GL_MODELVIEW);
     
    	glClearColor(0.0f,0.0f,0.0f,0.0f);
    	glClear(GL_COLOR_BUFFER_BIT);
    	glColor3f(0.0f,1.0f,0.0f);
    	//draw few points
    	glPointSize(15);
    	glBegin(GL_LINE_STRIP);
    	for(i=0;i<100;i++)	
    		glVertex2f(rand()%800,rand()%500);
    	glEnd();
     
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
    	glViewport (0, 100, (GLsizei) 800, (GLsizei) 500);
    	glScissor (0, 100, (GLsizei) 800, (GLsizei) 500);
    	gluOrtho2D(0,  800, 0, 500 );
     
    	glLoadIdentity();
    	glViewport(0,0,800,100);
      	glScissor(0,0,800,100);
    	gluOrtho2D(0,  800, 0, 500 );
    	glFinish();
    }
     
    int main(int argc,char**argv)
    {
    	srand(time(NULL));
    	glutInit(&amp;argc,argv);
    	glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
    	glutInitWindowSize(800,600);
    	glutCreateWindow("POINTS");
    	glutDisplayFunc(display);
    	glutMainLoop();
    }
    plz help me

  2. #2
    Junior Member Newbie
    Join Date
    Sep 2009
    Location
    France, Norway
    Posts
    23

    Re: glScissor() and gluOrtho2D()

    You need to keep the resize function you see in all simple examples... it will setup OpenGL states before you are actually start drawing...

    in you example, you setup the viewport and such after drawing....

Similar Threads

  1. glScissor & performance
    By Korval in forum OpenGL: Advanced Coding
    Replies: 20
    Last Post: 07-02-2007, 05:31 PM
  2. glScissor z inaccuracies
    By FatalXC in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 09-10-2002, 07:42 AM
  3. oposite of glScissor
    By elimin8tor in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-13-2002, 05:36 PM
  4. glScissor - rectangles
    By holy_moly in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 03-27-2000, 10:32 PM
  5. glScissor
    By holy_moly in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-23-2000, 09:04 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