1

I'm starting to play with OpenGL and I'd like to avoid the fixed functions as much as possible as the trend seems to be away from them. However, my graphics card is old and only supports up to OpenGL 2.1. Is there a way to write shaders for GLSL 1.20.8 and then run them without issue on OpenGL 3.0 and OpenGL 4.0 cards? Perhaps something when requesting the opengl context where you can specify a version?

  • 1
    I think I found the answer to my own question. I should use the #version directive. –  Apr 24 '11 at 08:53
  • @BlutJ774: You already found the answer. Yes it's the version directive. You could also use the __VERSION__ preprocessor statement to do conditional compilation. This is how I do it. – datenwolf Apr 24 '11 at 09:08
  • 2
    That is not really "the answer", however. Sadly, Khronos has taken great care to make writing code that runs on pre-3.2 and post-3.2 versions of OpenGL as hard as possible. No joke. I'm not talking about some special features that you can easily work around, you cannot even consistently define shader inputs/outputs so it will work on all versions. If you have any possibility to spend $25 on a card that can do GL 3.2, you should do so. Your life will be a lot happier if you target 3.2/3.3/4.x only. It is also a reasonable expectation that your users will have 3.2+ compatible cards. – Damon Apr 24 '11 at 10:08

1 Answers1

0

I should use the #version directive.