Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


more 2d opengl problems


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Julio   Members   -  Reputation: 116

Like
Likes
Like

Posted 23 June 2001 - 04:19 AM

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

Sponsor:

#2 OpenGLGuy   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 June 2001 - 04:37 AM

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



#3 Julio   Members   -  Reputation: 116

Like
Likes
Like

Posted 23 June 2001 - 05:07 AM

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

#4 Julio   Members   -  Reputation: 116

Like
Likes
Like

Posted 23 June 2001 - 05:29 AM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS