FreeOrion

Forums for the FreeOrion project
It is currently Fri May 24, 2013 1:43 pm

All times are UTC




Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Support for earlier OpenGL versions
PostPosted: Fri Feb 11, 2011 5:06 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7898
Location: Vancouver, BC
rkupke wrote:
The smallest change necessary would be to test for gl >=2.0 directly in the rendering code.
However, if the ShaderProgram class might get used in other places it could be better to incorporate that test into ShaderProgram.

That's a reasonable suggestion, though the issue is partly dealt with by the initialization check for GL > 2.0 which should disable the use of the shaders if they aren't supported. The player would get a crash if turning them back on manually, though...


Top
 Profile  
 
 Post subject: Re: Support for earlier OpenGL versions
PostPosted: Sat Feb 12, 2011 5:32 pm 
Offline
Space Floater

Joined: Tue Feb 01, 2011 4:09 pm
Posts: 18
I have made the necessary changes to make sure shaders are not used with gl<2.0

ShaderProgram.[h|cpp]:
  • Made default constructor private because using it would be an error
  • Made constructor protected
  • Implemented factory function that returns a new ShaderProgram or NULL
  • Implemented stopUse() function to stop using a shader. If a member function is used to start using the shader there should also be one for stopping.
  • Include HumanClientApp.h, necessary for testing gl version

SidePanel.cpp, MapWnd.cpp:
  • change glUseProgram(0) into stopUse()
  • use factory function to get ShaderProgram

SidePanel.cpp:
  • try to get shader in constructor of RotatingPlanetControl instead of Render()

MapWnd.cpp:
  • try to get shader even if fog of war is switched off. Necessary because activating fog of war for the first time during program execution would not show any effect before the next turn.

The attachment contains my current project file and all my modifications for supporting older gl versions (without the changes for using smaller textures).


Attachments:
Archiv.zip [196.36 KiB]
Downloaded 16 times
Top
 Profile  
 
 Post subject: Re: Support for earlier OpenGL versions
PostPosted: Sat Feb 12, 2011 11:29 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7898
Location: Vancouver, BC
Generally some good changes. Often makes things more maintainable, even while adding flexibility.

I added some include guards and GL header includes that were necessary to build on Windows.

You've removed calls to glBindBuffer(GL_ARRAY_BUFFER, 0); after activating buffers. Won't that leave those buffers in use for any subsequent rendering?

I have a few quibbles about function naming being inconsistent: Most functions in FreeOrion code have capital letters at their start, but some of yours don't. Not a major issue, though.

rkupke wrote:
[*]try to get shader even if fog of war is switched off. Necessary because activating fog of war for the first time during program execution would not show any effect before the next turn.

I'd prefer to leave that as it was, so that the calls to the shader-getting code can be avoided when the option is off, in case there are driver issues that would cause that code to crash. Waiting one turn for shaders to be enabled isn't a huge problem.

I'll commit a tweaked version of the code, though.


Top
 Profile  
 
 Post subject: Re: Support for earlier OpenGL versions
PostPosted: Sun Feb 13, 2011 8:13 am 
Offline
Space Floater

Joined: Tue Feb 01, 2011 4:09 pm
Posts: 18
Quote:
You've removed calls to glBindBuffer(GL_ARRAY_BUFFER, 0); after activating buffers. Won't that leave those buffers in use for any subsequent rendering?


I'd expect that the pushing and popping of client/server attributes covers that in the rendering code.
Otherwise the buffer classes would need a deactivate function. The functions for creating buffers already clean up after themselves. The functions for activating buffers obviously can not do that.


If you want to avoid issues with creating shaders you need to check the fog of war setting in SidePanel.cpp, too.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2

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