Jump to content
  • Advertisement
Sign in to follow this  
Renran

OpenGL C++ opengl Orthogonal mode hex tile wrong

This topic is 2303 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

Hello,

I know I should know this things, but here it goes:
When I make a map of hex tiles and the width and height are equal
I receive beautiful dimensioned tiles.
But when I (for instance) take a width of 20 tiles and a height of 5 tiles
then I have 5 lines with tiles with their height halved and their width intact.
I know it has something to do with the dimensions of the screen (I use
1024 x 768) but what to do about it, I want the dimension of the tiles
to be correct.

Greetings and Thanks,

Renran Edited by Renran

Share this post


Link to post
Share on other sites
Advertisement
A little more information would help. Could you post two screenshots: One where it's equal, and tiles look as they should, and the other where it's not equal, and you get the undesired effect.

Share this post


Link to post
Share on other sites
You need to update your projection matrix on "screen size change" event: (for example)

/* void onScreenSizeChange(int width, int height) { */
// width, height - new screen size
glViewport(0, 0, width, height);
// using classic OpenGL
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(width*-0.5,width*0.5,height*-0.5,height*0.5,-1,1); /* modify values here as you need */
glMatrixMode(GL_MODELVIEW);
/* } */

So, when you apply this code, on any screen dimensions you will receive quadratic tiles.

Best wishes, FXACE. Edited by FXACE

Share this post


Link to post
Share on other sites
Ok, thanks Guys I will try to do this.
I did not know where I had to look with this event.

Greetings and thanks,

Renran

Share this post


Link to post
Share on other sites
Yes FXACE, that does the trick, long ago I did also struggle with this one
but I did forget how I had to modify.

But thanks for answering guys, Goran Milovanovic and FXACE,

Fred

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!