Set the desktop gamma

Blitz3D Forums/Blitz3D Programming/Set the desktop gamma

JoshK(Posted 2005) [#1]
This will set the gamma, even if not in full-screen. This is the best way to do overbrightening of lightmaps, and ensure that the graphic will look the same on all cards.

win=CreateWindow("",0,0,400,300)
hwnd=QueryObject(win,1)
hdc=GetDC(hwnd)

;Don't fuck with this!
;=======================================
oldgammaramp=CreateBank(256*3*2)
GetDeviceGammaRamp hdc,oldgammaramp
;=======================================

gammaramp=CreateBank(256*3*2)
GetDeviceGammaRamp hdc,gammaramp
For n=0 To BankSize(gammaramp)/2-1
	DebugLog PeekByte(gammaramp,n*2+0)+" - "+PeekByte(gammaramp,n*2+1)
	r=PeekByte(gammaramp,n*2+1)*2
	If r>255 r=255
	PokeByte gammaramp,n*2+1,r
	Next
SetDeviceGammaRamp hdc,gammaramp
FreeBank gammaramp

Repeat
Delay 1
Until KeyHit(1)
SetDeviceGammaRamp hdc,oldgammaramp
End