What can be done with GLSL extension directives?


GameMaker's standard implementation of GLSL ES version 1.00rev17 leaves out some functionality that is commonly used in graphics programming. Fortunately, we can access some of these features by using GLSL's #extension directive.

Here're two examples that demonstrate how to enable two particularly useful extensions. (Bear in mind that I've tested these on Windows but not other platforms.)

GL_EXT_frag_depth, which enables per-pixel depth setting (gl_FragDepthEXT):

GL_OES_standard_derivatives, which enables derivative functions (dFdx/dFdy/fwidth):

I'm hardly the first person to demonstrate this extension directive functionality, but beyond these two extensions, I don't really know what other extensions are available and what they can do. There's an extension registry here and a GitHub repo for Angle (the OGL-to-DX transpiler GM uses) here but that's a lot of information to wade through. Anyone have any suggestions?
Last edited:


Tried vertex texture fetch in HLSL and had no luck, I suspect because GM isn't binding the necessary sampler(s) to the vertex shader. I'll try again in GLSL ES, though I don't hold out much hope.

The EXT_multiview_draw_buffers spec says it's written against ES 2.x but we might get lucky there.
Last edited:


Has anybody been able to get any other GLSL ES extensions to work? GLSL ES MRTs would change a lot!


Not sure if it's possible to use that MRT extension just because of how everything works in the background.

For MRTs, gl_FragData is used instead of gl_FragColor and, according to the spec, it's initialized using the value of gl_MaxDrawBuffers:
mediump vec4 gl_FragData[gl_MaxDrawBuffers];
That gl_MaxDrawBuffers variable is a built-in constant:
const mediump int gl_MaxDrawBuffers = 1;
The value of gl_MaxDrawBuffers does appear to be equal to 1.
I tried redefining it in the vertex shader but it seems like every definition of a variable prefixed with gl_ throws a compiler error.

I do hope there is a way, though :)
  • Like
Reactions: Xor