Jump to content

  • Log In with Google      Sign In   
  • Create Account


2D x,y coords to OpenGL screen coords


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
4 replies to this topic

#1 Julio   Members   -  Reputation: 116

Like
Likes
Like

Posted 17 June 2001 - 02:12 PM

I know OpenGL isnt'' very good for 2d, but I''m going to do it anyway. Does anybody know of any good tutorials on this? I know there are some. I am planning on making a tile engine. please don''t respond saying that I shouldn''t use OpenGL, because I already know this. All I need help on is converting screen x,y coordinates to actual OpenGL x,y coordinates. Thanks to any who dare, Joe HHSDrum@yahoo.com

Sponsor:

#2 Null and Void   Moderators   -  Reputation: 1087

Like
Likes
Like

Posted 17 June 2001 - 02:22 PM

OpenGL works fine in 2D (I''m making an isometric engine in it). What you should do is use an isometric projection matrix (one where distance from the origin has no effect on the 2D coordinate it produces). It goes something like this (copy/pasted from my engine):
  
glViewport(0,0,Width,Height); // <- H/W of screen


glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glOrtho(0.0f,Width,Height,0.0f,-1.0f,1.0f); // <- H/W of screen


glMatrixMode(GL_MODELVIEW);


[Resist Windows XP''s Invasive Production Activation Technology!]

#3 Impossible   Members   -  Reputation: 134

Like
Likes
Like

Posted 17 June 2001 - 02:23 PM

It''s not too difficult. Use glOrth when setting up the perspective.

#4 Julio   Members   -  Reputation: 116

Like
Likes
Like

Posted 17 June 2001 - 03:09 PM

thanks for the replies guys, I know it''s not impossible, just not as simple as dx7.

HHSDrum@yahoo.com

#5 Null and Void   Moderators   -  Reputation: 1087

Like
Likes
Like

Posted 17 June 2001 - 03:13 PM

It''s a whole lot easier when you''re doing non-rectangular objects and any type of alpha blending (lighting, for example) .

[Resist Windows XP''s Invasive Production Activation Technology!]




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