Shaders for OpenGL 1.5?

Sage
Posts: 1,066
Joined: 2004.07
Post: #1
Can shaders be created for OpenGL 1.5? I've been looking around but it all seems to be for GLSL which, unless I'm wrong, is for OpenGL 2.0. Any pointers to websites that can give me a good introduction to shaders? I've never tried using them before but they look fun. I'm using a PowerBook G4 with a 64mb Radeon 9700 and a PC with an ATi X800XL. I'm trying to be cross platform with everything I do in case that does change anything.Thanks.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #2
Both assembly shaders and GLSL shaders are available in OpenGL 1.5 through extensions. However, GLSL shaders are only available on Mac OS X 10.4.3 and higher, but assembly shaders are available on OS X 10.2.8 and higher.

AFAIK, the only difference between OpenGL 1.5 and OpenGL 2.0 is more of the extensions became part of the core. Correct my if I'm wrong, though.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #3
That's good to know. Too bad about the GLSL. I've read about Cg shaders. Are those available for OpenGL 1.5 as well? I'm developing using Mac OS X 10.3.9 right now so that's sort of my lowest supported system for the time being.

Any links to getting started with these shaders? I could do assembly, though it sounds quite complex.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #4
I'm not sure about Cg shaders. I think they're only for NVidia cards, though. However, I believe that you can compile them into assembly shaders. You'll have to look it up.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
The "version" of OpenGL is completely irrelevant. Look at the extensions string.

Cg is a hack which compiles to ARB_vertex_program and ARB_fragment_program.

GLSL requires ARB_shader_objects, ARB_vertex_shader, ARB_fragment_shader and ARB_shading_language_100.

Note that GLSL is actually more powerful than Cg, since it can access the dynamic branching and looping capabilities of the Radeon X1xxx cards.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #6
Small clarifications:

GLSL is available on 10.4.0, if you use the software renderer.
GLSL is hardware accelerated as of 10.4.3.

GLSL is exposed through extensions in OpenGL 1.x. The functionality is rolled into the core in OpenGL 2.0, but there are API differences; you need to read the specification carefully to see what changed (although this doesn't matter on the Mac currently since none of the renderers claim 2.0 yet.)

To use GLSL on the Mac, you should look at the extensions string. You need ARB_shader_objects and ARB_shading_language_100, and one or both of ARB_vertex_shader and ARB_fragment_shader. Apple's GLSL implementation provides software emulation of ARB_vertex_shader so it is available on all hardware, but only recent (ARB-fragment program capable) video cards will export ARB_fragment_shader.

A simple "GLSLShowpiece" example is included with Xcode, at /Developer/Examples/OpenGL/Cocoa. You can also use Shader Builder to write GLSL shaders. (But it would be nice if we had more examples and updated tools...)
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #7
Shader Builder also supports assembly shaders and has a handy lookup tool. In fact, I think it's built more for assembly shaders than GLSL shaders. When I start writing more shaders, they will likely be in assembly because they are more widely supported, and with things like dynamic branching and looping not available through hardware on all but the current generation of graphics cards, that benefit of GLSL is lost.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #8
GLSL software renderer, Thank you arekkusu!
I can finally learn GLSL Grin I had no idea I could use it on software before now.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #9
Does anybody know if the GLSL software shaders need to be run on a software OpenGL context, or if they can be run alongside the hardware context? I think assembly shaders might also be able to run in software, though I'm not sure.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
The floating-point software renderer supports ARB_fragment_program and ARB_fragment_shader.

If you have a context with a renderer which supports ARB_fragment_shader, and you write a shader which can't run in hardware, it will fall back to the floating-point software renderer.

AFAIK if you have a context which does not support ARB_fragment_shader, there's no way to get even software rendering for it.

ARB_vertex_program and ARB_vertex_shader are supported in software on all renderers.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #11
Yes, OSC is correct. More explanation for people getting started with GLSL:

If you have a recent video card that exports ARB_fragment_shader, this only means that some GLSL programs might run with hardware acceleration. Unlike previous ARB assembly languages, GLSL is a "real" programming language. You can easily write code that is too big or complex for any existing video card. When this happens, the spec requires software fallback-- it doesn't matter how fast or slow it is, but it has to draw. So there is software fallback for all renderers that export ARB_fragment_shader. If you are programming for speed (i.e. a game) you'll need to test out your shader on all the hardware you care about to make sure you don't fall back.

On the other hand, if you have an older video card that doesn't export ARB_fragment_shader, you won't be able to use GLSL for fragment programming unless you explicitly request the software renderer during context creation.

In theory, we could export all of the capabilities of the software fallback on all renderers, but there is a bit of reality check here; most typical applications using OpenGL are trying to leverage hardware acceleration and we judge the software fallback to be "too slow" to export all the time.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #12
arekkusu Wrote:To use GLSL on the Mac, you should look at the extensions string. You need ARB_shader_objects and ARB_shading_language_100, and one or both of ARB_vertex_shader and ARB_fragment_shader.
I used the OpenGL Extensions Viewer from your website and found that I have ARB_shader_objects, ARB_vertex_shader, and ARB_fragment_shader but not ARB_shading_language_100. Does this mean I'm stuck with the assembly shaders? If so does anyone have any links for starting learning?
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #13
Nick, upgrade to Tiger. ARB_shading_language_100 is in Tiger.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #14
I'm planning on upgrading to Tiger eventually (probably late April), so perhaps I should just avoid learning shaders and focus on something else until then.
Quote this message in a reply
Member
Posts: 110
Joined: 2002.07
Post: #15
a good place to go for learning GLSL is
http://www.lighthouse3d.com/opengl/glsl/index.php?intro

there is some nice exmple how to load a shader from files and use it in opengl
it took me an hour to add it in my app and get thing workin with lights

Love and it took me 1 week to play with it just for fun Love
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  GLSL geometry- and multipass-shaders (nogo?) mcMike 3 5,794 May 2, 2008 05:51 AM
Last Post: mcMike
  Enabling OGL fog in shaders kordova 7 5,226 Jul 12, 2006 10:12 AM
Last Post: kordova
  Program for previewing / editing textures & shaders? haxolotl 4 4,548 Jun 7, 2006 12:48 PM
Last Post: ravuya
  cubemaps with shaders akb825 3 3,158 Apr 5, 2006 06:24 PM
Last Post: akb825
  How to acheive this effect with shaders unknown 11 4,500 Feb 4, 2006 12:26 PM
Last Post: unknown