problems with orthogonal view

I’m having problems using an orthogonal view. At the beginning of my draw method i have:

  
  
	if(isOrthogonal) {  
		glMatrixMode(GL_PROJECTION);  
		glLoadIdentity();  
  
		gluOrtho2D(0, ofGetWidth(), 0, ofGetHeight());  
		glScalef(1, -1, 1);  
		glTranslatef(0, -ofGetHeight(), 0);  
		glMatrixMode(GL_MODELVIEW);  
	}  

And i cannot see anything. To keep it simple I am rendering a cube at 0,0 and width/2, height/2 - and screen is just black. if i toggle the orthogonal mode off it all looks fine. I"ve tried commenting out the scale and translate, but still see nothing. Is this something to do with openframeworks?

problem is the gluOrtho2D it turns out, only draws stuff at 0 depth. Working code is:

  
	if(isOrthogonal) {  
		glMatrixMode(GL_PROJECTION);  
		glLoadIdentity();  
		glOrtho(0, ofGetWidth(), 0, ofGetHeight(), -100, 2000);  
		glMatrixMode(GL_MODELVIEW);  
	}  

Hmm i can’t get your code memo to work!

Example:

  
  
//--------------------------------------------------------------  
void testApp::draw(){  
	glMatrixMode(GL_PROJECTION);   
	glLoadIdentity();   
	glOrtho(0, ofGetWidth(), 0, ofGetHeight(), -100, 2000);   
	glMatrixMode(GL_MODELVIEW);   
	  
	glTranslated(0,0, ofRandom(-100,100));  
	ofRect(-50, -50,100,100);  
}  
  

I just get a black screen, can’t see where my box is in the world…

sorry for reopening this old topic but i have actual the same problem.

i need an orthogonal view and i get either an empty screen or the settings don’t change anything.

  1. empty screen:
  
  
void testApp::update(){  
  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
  
    glMatrixMode(GL_PROJECTION);  
    glLoadIdentity();  
    glOrtho(0, ofGetWidth(), 0, ofGetHeight(), -100, 200);  
    glMatrixMode(GL_MODELVIEW);  
  
    glBegin(GL_TRIANGLES);  
     glColor3f(1.0,0.0,0.0);  glVertex3f(50, 100, 0.0);  
     glColor3f(0.0,1.0,0.0);  glVertex3f(100, 150, 0.0);  
     glColor3f(0.0,0.0,1.0);  glVertex3f(40, 200, 0.0);  
    glEnd();  
}  
  

  1. here the triangle is drawn but the parameters in glOrtho don’t change anything
  
//--------------------------------------------------------------  
void testApp::update(){  
  
    glMatrixMode(GL_PROJECTION);  
    glLoadIdentity();  
    glOrtho(0, ofGetWidth(), 0, ofGetHeight(), -100, 2000);  
    glMatrixMode(GL_MODELVIEW);  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
  
  
    glBegin(GL_TRIANGLES);  
     glColor3f(1.0,0.0,0.0);  glVertex3f(50, 100, 0.0);  
     glColor3f(0.0,1.0,0.0);  glVertex3f(100, 150, 0.0);  
     glColor3f(0.0,0.0,1.0);  glVertex3f(40, 200, 0.0);  
    glEnd();  
}  

can someone give me a hint?

thanks and greets,
felix