Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Julio

OpenGL more 2d opengl problems

This topic is 6264 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!