OpenGL Extensions

Where is the right place to enable OpenGL extensions?

Since I’m using a mac I’m stuck with OpenGL 2.1. Point is some of the Open GL 3 stuff is available as extensions and I would like to use some of those features. Any suggestions besiides buying a “real” computer?

I do it like this:


#extension GL_EXT_gpu_shader4 : enable // gives a warning if not available, defines GL_EXT_gpu_shader4 if available

#ifdef GL_EXT_gpu_shader4

float getHeightSample(const in vec2 texCoord, const in vec2 dx, const in vec2 dy)


#if defined(PARALLAXMAP)

return texture2DGrad(m_ParallaxMap, texCoord, dx, dy).r; // provided by GL_EXT_gpu_shader4


return texture2DGrad(m_NormalMap, texCoord, dy, dy).a; // provided by GL_EXT_gpu_shader4




float getPomHeightSample(const in vec2 texCoord)


#if (defined(POM_USE_TEX_GRAD) && defined(GL_EXT_gpu_shader4))

return getHeightSample(texCoord, dx, dy);

#elif defined(POM_USE_TEX_LOD)

return getHeightSample(texCoord, fMipLevel);


return getHeightSample(texCoord);




1 Like

Thanks @survivor I will try that, I will also use it in in my POM shader :stuck_out_tongue: