Source wurde am 15.07.2007 aus der MMJ-Quellcodesammlung (Dietmar Horn) in die Babyklappe auf XProfan.Com abgelegt:
OGL-Demo: Planeten
Declare Texture%[4],
DisplayList%[3],
Rotation![3],
SelfRot![3],
LightPos&[3]
Declare rot!, Ende%, Namen$[4]
proc DrawGLScene
oGL(Clear)
oGL(Origin, 0, -2.8, (-50))
oGL(Rotate, rot!, 0, 0)
Sonne
oGL(SetName, 0)
oGL(Texture, Texture%[0], 1)
oGL(Push)
oGL(Rotate, 0, SelfRot![0], 0)
oGL(Sphere, 2.8, 32, 32)
oGL(Pop)
Mars
oGL(SetName, 1)
oGL(Texture, Texture%[1], 1)
oGL(Push)
oGL(Rotate, 0, Rotation![1], 0)
oGL(Move, 0.0, 1.2, 20.0)
oGL(Rotate, 0, SelfRot![1], 0)
oGL(Sphere, 1.6, 32, 32)
oGL(Pop)
Erde
oGL(SetName, 2)
oGL(Texture, Texture%[2], 1)
oGL(Push)
oGL(Rotate, 0, Rotation![2], 0)
oGL(Move, 0.0, 0.8, 10.0)
oGL(Rotate, 0, SelfRot![2], 0)
oGL(Sphere, 2.0, 32, 32)
Mond
oGL(SetName, 3)
oGL(Texture, Texture%[3], 1)
oGL(Rotate, 0, Rotation![3], 0)
oGL(Move, 0.0, 1.2, 3.5)
oGL(Sphere, 0.8, 16, 16)
oGL(Pop)
Hintergrund
oGL(SetName, 4)
oGL(Texture, Texture%[4], 2)
oGL(Rotate, -rot!, 0, 0) Der Hintergrund soll nicht rotieren
oGL(Move, 0, -35, -30)
oGL(Quad, 94, 70)
oGL(Rotate, rot!, 0, 0)
oGL(Show)
EndProc
WindowTitle Planeten
WindowStyle 31
CLS
Messagebox(Linksklick auf Objekt: Objektname in der Titelleiste
+
Rechtsklick: Titelleiste wird zurückgesetzt
+
BildHoch/BildRunter kippen das System, OpenGL-Demo qPlanetenq, 64)
oGL(Init, %hWnd, 0, 0, 0, 1)
texture%[0] = oGL(LoadTextureBMP,sun.bmp,3)
texture%[1] = oGL(LoadTextureBMP,mars.bmp,3)
texture%[2] = oGL(LoadTextureBMP,earth.bmp,3)
texture%[3] = oGL(LoadTextureBMP,moon.bmp,3)
texture%[4] = oGL(LoadTextureBMP,space.bmp,3)
Namen$[0] = Sonne
Namen$[1] = Mars
Namen$[3] = Mond
Namen$[2] = Erde
Namen$[4] = Sterne
Ende% = 0
setTimer 50 max. 20 Frames /sek.
WhileNot ende%
WaitInput
If IsKey(27)
Ende% = 1
EndIf
If IsKey(1)
oGL(StartTest, %MouseX, %MouseY)
DrawGLScene()
SetText %hWnd, namen$[oGL(EndTest)]
ElseIf IsKey(2)
SetText %hWnd, Planeten
ElseIf IsKey(34)
rot! = rot! + 1
ElseIf IsKey(33)
rot! = rot! - 1
EndIf
SelfRot![0] = SelfRot![0] + 0.5 Sonne
SelfRot![1] = SelfRot![1] + 5 Mars
SelfRot![2] = SelfRot![2] + 5 Erde
SelfRot![3] = SelfRot![3] + 5 Mond
WhileLoop 0, 3
Case SelfRot![&loop] > 360 : SelfRot![&loop] = 0
EndWhile
Rotation![3] = Rotation![3] - 12.5 Mond
Rotation![2] = Rotation![2] + 2.5 Erde
Rotation![1] = Rotation![1] + 1.5 Mars
WhileLoop 1, 3
Case Rotation![&loop] > 360 : Rotation![&loop] = 0
Case Rotation![&loop] < 0 : Rotation![&loop] = 360
EndWhile
DrawGLScene()
EndWhile
killTimer
end