PDA

View Full Version : when to use #extension in GLSL?



dobradusa
12-07-2006, 10:25 PM
In my fragment program, how do I know whether I need to explicitly enable some extension using #extension? I presume it depends on what OpenGL core version the graphics card driver implements. So the NPOT textures extension, which became part of 2.0 core, should probably be explicitly enabled on a machine with older driver (let's assume that I couldn't update the driver). Could someone confirm my speculations?

Relic
12-07-2006, 11:15 PM
Bad example. Shaders don't know about texture sizes. They just work with samplers and texture coodinates. If that is slow or fast depends on the HW capability. If the extension or OpenGL 2.0 is not exported you will get an OpenGL error as soon as you download a NPOT image.

What you need to do in the shader source for example is to enable ARB_draw_buffers when using gl_FragData[], etc.
The compiler should tell you what's required when you use non-core functionality.
Similarly for the #version tag.

Komat
12-07-2006, 11:48 PM
Originally posted by dobradusa:
In my fragment program, how do I know whether I need to explicitly enable some extension using #extension?You need to enable extensions that are not part of the core of the language version (not OGL version) you are targeting with the #version directive.