glScissor() and gluOrtho2D()

Hi,
I have a little problem with using these two function, if anyone could help :sleeping:
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.


#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(&argc,argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
	glutInitWindowSize(800,600);
	glutCreateWindow("POINTS");
	glutDisplayFunc(display);
	glutMainLoop();
}

plz help me

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…