b2dLoadScreenShader

Category: Shaders

Syntax:

b2dLoadScreenShader:Int(filename:String)


Parameters

Returns

Int



Summary

Loads and compiles a full-screen post-process shader.

Takes filename (a GLSL fragment shader).

Returns a shader handle (a positive integer), or 0 if it failed to compile - the compiler's message, with your own line numbers, is printed to the console.

The scene is drawn into an offscreen target and then composited into the window through this shader, so its "image" is the finished frame. The preamble exposes that frame as screenTexture, and also as imageTexture and fontTexture - all three are the same sampler, so a shader ported from elsewhere keeps whichever name it used.

Only the fragment stage is yours; the runtime supplies the vertex stage and prepends the uniform declarations. These are named b2d* on every target. They post-process the finished 2D frame; the earlier b3d* names were a leftover from when they sat alongside the 3D entity shaders.

View detailed documentation online



Example
Local crt:Int = b2dLoadScreenShader("CRT.glsl")
If crt = 0 Then
	Print "Shader failed to compile - see the console"
	Return 1
EndIf
b2dSetShaderFloat(crt, "0", 200.0)      ; slot 0: scanline count
b2dApplyScreenShader(crt)

While sysQuitRequested() = 0
	sysUpdateEvents()
	b2dCls()
	; ... draw the scene normally ...
	b2dFlip()
Wend
b2dFreeScreenShader(crt)

BambooBasic © 2026 Michael Denathorn