set display settings to windowed 640x480. move mouse to
point the light ...
SYNC RATE 50 : SYNC ON : SET WINDOW LAYOUT 0, 0, 0
AUTOCAM OFF : BACKDROP OFF : DRAW TO BACK
#CONSTANT user32 = 1
#CONSTANT gdi32 = 2
LOAD DLL "user32.dll", user32
LOAD DLL "gdi32.dll", gdi32
CreateMaps()
MAKE OBJECT SPHERE 1, 32, 32, 32
TEXTURE OBJECT 1, 1
SET BUMP MAPPING ON 1, 2
REPEAT
PASTE IMAGE 1, 0, 0
TURN OBJECT LEFT 1, COS(A)
POSITION OBJECT 1, 0, 0, 50 + SIN(A) * 10
MX = MX - MOUSEMOVEX()
MY = MY + MOUSEMOVEY()
POINT LIGHT 0, MX, MY, 50
SET CURSOR 0, 0
PRINT "FPS: ", SCREEN FPS()
INC A
SYNC
UNTIL MOUSECLICK()
DELETE DLL user32
DELETE DLL gdi32
END
`--- Functions ------------------------------------------------------------------------------------
FUNCTION CreateMaps()
HIDE WINDOW
hDsk = CALL DLL(user32, "GetDesktopWindow")
hDC = CALL DLL(user32, "GetWindowDC", hDsk)
DskW = CALL DLL(gdi32, "GetDeviceCaps", hDC, 8)
DskH = CALL DLL(gdi32, "GetDeviceCaps", hDC, 10)
`--- BackMap ----------------------------------
CREATE BITMAP 1, SCREEN WIDTH(), SCREEN HEIGHT()
LOCK PIXELS
FOR DskX = DskW / 2 - SCREEN WIDTH() / 2 TO DskW / 2 + SCREEN WIDTH() / 2 - 1
FOR DskY = DskH / 2 - SCREEN HEIGHT() / 2 TO DskH / 2 + SCREEN HEIGHT() / 2 - 1
C = CALL DLL(gdi32, "GetPixel", hDC, DskX, DskY)
DOT BmpX, BmpY, RGB(RGBB(C), RGBG(C), RGBR(C))
INC BmpY
NEXT DskY
BmpY = 0
INC BmpX
NEXT DskX
UNLOCK PIXELS
GET IMAGE 1, 0, 0, SCREEN WIDTH(), SCREEN HEIGHT(), 1
DELETE BITMAP 1
`--- NormalMap --------------------------------
CREATE BITMAP 2, SCREEN WIDTH(), SCREEN HEIGHT()
LOCK PIXELS
BmpX = 0
BmpY = 0
FOR DskX = DskW / 2 - SCREEN WIDTH() / 2 TO DskW / 2 + SCREEN WIDTH() / 2 - 1
FOR DskY = DskH / 2 - SCREEN HEIGHT() / 2 TO DskH / 2 + SCREEN HEIGHT() / 2 - 1
NX = CALL DLL(gdi32, "GetPixel", hDC, DskX - 1, DskY)
R = RGBB(NX)
NX = CALL DLL(gdi32, "GetPixel", hDC, DskX + 1, DskY)
R = (R - RGBB(NX) + 255) / 2
NY = CALL DLL(gdi32, "GetPixel", hDC, DskX, DskY - 1)
G = RGBB(NY)
NY = CALL DLL(gdi32, "GetPixel", hDC, DskX, DskY + 1)
G = (G - RGBB(NY) + 255) / 2
DOT BmpX, BmpY, RGB(R, G, 255)
INC BmpY
NEXT DskY
BmpY = 0
INC BmpX
NEXT DskX
UNLOCK PIXELS
GET IMAGE 2, 0, 0, SCREEN WIDTH(), SCREEN HEIGHT(), 1
DELETE BITMAP 2
CALL DLL user32, "ReleaseDC", hDsk, hDC
RESTORE WINDOW
ENDFUNCTION