Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

glortho function - assistance required...

4: Adsense

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

#1 chilun   Members   

122
Like
0Likes
Like

Posted 25 October 2013 - 03:50 AM

Hi all;

 

I have some trouble with trying to use the glOrtho function to scale some graphics to a window (height - 500, width - 500).

I've created a function called reshape to do this, but for some reason I think my numbers are off as the graphics are scaling to the size I would like, but for some reason it is only scaling into the top-left hand corner of the window - I want to make sure that the scaling fills the entire size of the window. Can anyone provide any tips on what I can do?

 

Thank you

...void reshape(int w, int h)
{
glViewport(0,0, w, h);
GLfloat aspect = (GLfloat)w / (GLfloat) h;
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, w, h, 0.0f, 0.0f, 1.0f);
}
...


int main (int argc, char **argv)
{

...
glutInitWindowSize(500, 500);
glutReshapeFunc(reshape);
...
}


#2 Goran Milovanovic   Members   

1104
Like
0Likes
Like

Posted 26 October 2013 - 11:50 PM

Try:

 

GLfloat x = w / 2;
GLfloat y = h / 2;
glOrtho(-x, x, -y, y, -1.0f, 1.0f);

 

Scaling the projection matrix will scale everything in the scene. If you just want to scale a specific object, you should do so by scaling its world transform matrix.

 

... Is the example small enough to post somewhere? That would help.


+---------------------------------------------------------------------+

| Game Dev video tutorials  ->   http://www.youtube.com/goranmilovano |
+---------------------------------------------------------------------+

#3 chilun   Members   

122
Like
0Likes
Like

Posted 28 October 2013 - 05:19 PM

Hi Goran;

 

I'll definitely try what you suggested and will come back to you with a response.

 

Thank you very much indeed :)






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.