Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++ opengl Orthogonal mode hex tile wrong

Started by Renran Aug 20, 2012 at 8:15 AM 3 replies 2.2k views
Original Post
Renran
Renran
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
Goran Milovanovic
Goran Milovanovic
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.
+---------------------------------------------------------------------+ | Game Dev video tutorials  ->   http://www.youtube.com/goranmilovano | +-------------------------------------
FXACE
FXACE
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.
Renran
Renran
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
Renran
Renran
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.