FreeOrion

Forums for the FreeOrion project
It is currently Tue May 21, 2013 11:42 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Ortho & Zoom question
PostPosted: Tue Jul 06, 2010 1:43 am 
Offline
Space Krill

Joined: Tue Jul 06, 2010 1:07 am
Posts: 2
Dumb questions, but I'm a n00b trying learn OpenGL + the FreeOrion source:

1.) Is the map/universe (i.e, star systems) rendered in ortho or perspective? it's not immediately clear to me.
2.) Where can I find the relevant GL calls for map/universe zoom? I'm going through MapWnd.cpp source and checking out the various zoom functions, but they just seem to alter the geometry. I'm interested in looking at the OpenGL code that acts on it.


Top
 Profile  
 
 Post subject: Re: Ortho & Zoom question
PostPosted: Tue Jul 06, 2010 4:16 am 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7890
Location: Vancouver, BC
I'm not a GL expert, but I'll try to be helpful...

1) As far as I know, the map is rendered in orthogonal mode. See HumanClientApp::Enter2DMode() and the calls to glOrtho.

2) I'm not entirely sure about this, but I think zooming the map is done two different ways, sometimes redundantly, depending on how some rendering options are set. In most cases, the zooming of the map doesn't depend directly on the geometry modifications done in the zoom functions, but instead is the result of the glScalef and glTranslatef calls in MapWnd::Render.
* For system rendering, when using "optmized system rendering", the vertex and and texture coordinate buffers are then rendered, and appear zoomed due to the scaling above. When not using "optimized system rendering" the geometry data is used, and SystemIcons render themselves based on their specified size and position during the zoom function, temporarily undoing the glScalef and glTranslatef calls.
* For fleet movement lines, MapWnd::RenderMovementLine does its own manual zooming, temporarily ignoring the scaling in MapWnd::Render, by calculating the screen position of start and end points of starlanes. This is done so that starlane thickness doesn't change with zoom level.
* Galaxy gas is always rendered like optimized systems, with the scaling and panning translation provided by the glScalef and glTranslatef calls in MapWnd::Render.
* Background starfields are rendered unscaled, regardless of zoom level, before the calls to glScalef and glTranslatef.
* For starlanes, the code in MapWnd::RenderStarlanes appears to be using the scaling and panning translation for glScalef and glTranslatef in MapWnd::Render, but for some reason this doesn't affect the rendered thickness of the starlanes. This may be because a call to glLineWidth is made after the glScalef, but I'm not sure how order of calls to scaling and line width setting affects the results.


Top
 Profile  
 
 Post subject: Re: Ortho & Zoom question
PostPosted: Fri Jul 09, 2010 9:40 pm 
Offline
Space Krill

Joined: Tue Jul 06, 2010 1:07 am
Posts: 2
So playing around I deleted all calls to glScale/Translate in MapWnd.cpp, it still zooms. Rendering is bit screwed up, but it zooms, with optimized rendering turned on & off.

Now I'm on a mission to figure out how this works. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group