Skip to content

SetGamma

Narta Xaymar Dirks edited this page Oct 28, 2026 · 6 revisions

Blitz3DBlitzPlusBlitzBasic

SetGamma

SetGamma:Void src_red:Int32, src_green:Int32, src_blue:Int32, dest_red:Float32, dest_green:Float32, dest_blue:Float32
Parameter Mode Type Default Description
src_red In Int32 required The input value for the red table, 0 to 255.
src_green In Int32 required The input value for the green table, 0 to 255.
src_blue In Int32 required The input value for the blue table, 0 to 255.
dest_red In Float32 required The output value for red.
dest_green In Float32 required The output value for green.
dest_blue In Float32 required The output value for blue.

Description

Sets one entry of the gamma tables: color value src of a channel is shown as the output value, which can be a fractional number from 0 to 255. Call UpdateGamma after changing the entries, which is when they start to count. The tables change what the window shows, not what was drawn, so ReadPixel and SaveBuffer still see the colors the program drew.

This example raises every step to the power of 1 / 1.8, which brightens the dark colors most. The first picture is the window before, the second after.

Differences

  • The original changed the gamma of the whole display, and left it that way until the program was done. This never changes the gamma of the display, and the window is the only thing that looks different: the tables are applied to the picture of the window when it is shown, by the GPU, and the buffers keep what was drawn. The output values are floats, and it works in a window as well as in full screen.

Examples

Graphics 320, 200, 32, 2
SetBuffer BackBuffer()
For i = 0 To 63
	v = i * 4 + 3
	Color v, 0, 0 : Rect 32 + i * 4, 20, 4, 24, 1
	Color 0, v, 0 : Rect 32 + i * 4, 48, 4, 24, 1
	Color 0, 0, v : Rect 32 + i * 4, 76, 4, 24, 1
	Color v, v, v : Rect 32 + i * 4, 104, 4, 24, 1
Next
Flip

For i = 0 To 255
	bright# = 255.0 * (i / 255.0) ^ (1.0 / 1.8)
	SetGamma i, i, i, bright, bright, bright
Next
UpdateGamma
Flip
WaitKey

After SetGamma

Related Commands

GammaBlue, GammaGreen, GammaRed, SetGfxDriver, UpdateGamma

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally