HELP!!! Simple glOrtho problem!

Marvin
Unregistered
 
Post: #1
Hey,

can anyone explain to me why this code doesn't generate a visible red line from the left bottom to the top right corner of my window?



Code:
void initGL()
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Black background
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.f, 1.f, 0.f, 1.f, 0.f, 1.f);
glMatrixMode(GL_MODELVIEW);
}

void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear screen and depth buffer
glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
glBegin(GL_LINES);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(1.0f, 1.0f, 1.0f);
glEnd();
glFlush();
}

int main(int argc, char** argv) // Create main function for bringing it all together
{

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB); // Display mode
glutInitWindowSize(500, 500);
glutCreateWindow("Aufgabe ?");
initGL();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(key); // callback for key input
// glutIdleFunc(display); // If continuous animation is required
glutMainLoop(); // Initialize the main loop

}



As you can see, I have specified the viewable volume as a cube of length one, one corner at (0, 0, 0), the other one at (1, 1, 1). I'm drawing the diagonal line through these two corners, so what I should expect on the 2D window surface is a diagonal line across the window. Why isn't this happening? My window remains BLACK.

Please help. This is such a simple thing, and I'm stuck at this already.

Cheers
Marvin
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #2
try
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);

and

glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(1.0f, 1.0f, 0.0f);

my guess is that your vertices are both getting culled

Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Quote this message in a reply
Realization
Unregistered
 
Post: #3
Could you post your reshape function? Maybe you're not looking in the right place.
Quote this message in a reply
Marvin
Unregistered
 
Post: #4
Hey folks, problem solved!

Didn't know GL_MODELVIEW is by default made to look down the negative z-Axis. Made the necessary adjustments.

As for my reshape function, it just calls the display function


Thanks

Marvin
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Simple OpenGL ES problem soulstorm 3 4,147 May 14, 2009 03:53 PM
Last Post: AnotherJake
  Very simple OpenGL problem evangs 10 5,595 Dec 10, 2007 01:32 PM
Last Post: wyrmmage
  OpenGL Texture in relation to GL orientation, and... glOrtho help. Jones 6 4,949 Jun 30, 2006 07:18 PM
Last Post: arekkusu
  glOrtho setup for rendering "impostors" into a texture. TomorrowPlusX 22 8,877 May 22, 2006 07:21 AM
Last Post: TomorrowPlusX
  picking glOrtho vs gluPerspective rhiannon 0 3,666 Jun 6, 2005 02:20 PM
Last Post: rhiannon