Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

C++ opengl Orthogonal mode hex tile wrong


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 Renran   Members   -  Reputation: 132

Like
0Likes
Like

Posted 20 August 2012 - 02:15 AM

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, 20 August 2012 - 02:16 AM.


Sponsor:

#2 Goran Milovanovic   Members   -  Reputation: 878

Like
0Likes
Like

Posted 21 August 2012 - 07:21 AM

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.
Learn the basics with my Python 3 video tutorial series. Looking for a good game engine, and relevant tutorials? Here you go.
Small and simple Python 3.x media library: pslab

#3 FXACE   Members   -  Reputation: 178

Like
0Likes
Like

Posted 21 August 2012 - 06:35 PM

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, 21 August 2012 - 06:35 PM.


#4 Renran   Members   -  Reputation: 132

Like
0Likes
Like

Posted 23 August 2012 - 07:07 AM

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

#5 Renran   Members   -  Reputation: 132

Like
0Likes
Like

Posted 23 August 2012 - 08:24 AM

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




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