more 2d opengl problems

Started by
2 comments, last by Julio 22 years, 9 months ago
well, I''ve tried multiple methods. read the tutorial on opengl.org about 2d opengl, yet for some reason their code works and mine doesn''t. here''s how I''m initializing:
  
glViewport(0,0,640,480);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0f,640.0f,0.0f,480.0f);// 2d version of gluOrtho()

glMatrixMode(GL_MODELVIEW);
  
I made sure the depth buffer is disabled, and the min_z and max_z clipping planes are by default set to -1 and 1. my simple rendering code is:
  
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef (1.0f, 1.0f, -1.0f);	// in fov, min clip plane

glBegin(GL_TRIANGLES);			//ccw order

	glVertex2f(-1.0f,0.0f);
	glVertex2f(1.0f,0.0f);
	glVertex2f(0.0f,1.0f);
glEnd();
  
I know I''m probably doing something stupid wrong. If anybody can find it I''d appreciate it. Thanks, Joe HHSDrum@yahoo.com
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
Advertisement
Hey,

Try this out.

Instead of doing gluOrtho2D(0.0f, 640.0f, 0.0f, 480.0f);

do

gluOrtho2D(0.0f, 640.0f, 480.0f, 0.0f);

and the translatef(1.0f, 0.0f, -1.0f); doesn''t have anything to do with clipping planes. That just places your object at points in the coords system. if you wanna specify your cliping planes than instead of gluOrtho2D(****) use this

glOrtho(left, right, bottom, top, near clipping, far clipping);

that should help

if(!You_Like_Game_Dev){ return Loser;}else{ return Cool;}
I know glTranslatef doesn''t have anything to do with the clipping planes. I read in a tutorial that gluOrtho() sets the clipping planes by default to -1 and 1. I''ll mess around with it some more.
thanks for the reply,
Joe

HHSDrum@yahoo.com
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
I got it working. I had everything right, I just wasn''t drawing my triangle big enough. For future reference my original syntax for gluOrtho was correct. It is different than the syntax for glOrtho, not to get confused.

HHSDrum@yahoo.com
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911

This topic is closed to new replies.

Advertisement