I have found the answer. Look here:
Code: Select all
#GL_COLOR_BUFFER_BIT = $00004000
#GL_DEPTH_BUFFER_BIT = $00000100
#GL_TRIANGLES = $0004
#GL_FOG = $0B60
#GL_MODELVIEW = $1700
#GL_PROJECTION = $1701
#WindowWidth = 500
#WindowHeight = 400
#WindowFlags = #PB_Window_TitleBar | #PB_Window_MaximizeGadget | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered
Global floatX.f
Global floatY.f
Global floatZ.f
Global CameraX.f, CameraY.f, CameraZ.f, CamrotX.f, CamrotY.f, CamrotZ.f, CameraSpeed.f, CameraZoom.f, hDC
CamSpeed.f = 0.025
CameraZoom = 0.5
If OpenWindow(0, 0, 0, #WindowWidth, #WindowHeight, #WindowFlags, "OpenGLCamera")
piover180.f = (ATan(1)*4)/180
pfd.PIXELFORMATDESCRIPTOR ;OpenGL starten
hDC = GetDC_(hWnd)
pfd\nSize = SizeOf(PIXELFORMATDESCRIPTOR)
pfd\nVersion = 1
pfd\dwFlags = #PFD_SUPPORT_OPENGL | #PFD_DOUBLEBUFFER | #PFD_DRAW_TO_WINDOW
pfd\iLayerType = #PFD_MAIN_PLANE
pfd\iPixelType = #PFD_TYPE_RGBA
pfd\cColorBits = 24
pfd\cDepthBits = 32
pixformat = ChoosePixelFormat_(hDC, pfd)
SetPixelFormat_(hDC, pixformat, pfd)
hrc = wglCreateContext_(hDC)
wglMakeCurrent_(hDC, hrc)
pixformat = ChoosePixelFormat_(hDC, pfd)
SetPixelFormat_(hDC, pixformat, pfd)
hrc = wglCreateContext_(hDC)
wglMakeCurrent_(hDC,hrc)
SwapBuffers_(hDC)
floatX = 0.5
floatY = 0.25
floatZ = -0.5
Repeat
glTranslatef_(0, 0, -7.0)
glMatrixMode_(#GL_MODELVIEW)
If GetAsyncKeyState_(#VK_UP) <> 0
CameraZ = CameraZ - Sin((CamrotY-90)*piover180)*CamSpeed
CameraX = CameraX - Cos((CamrotY+90)*piover180)*CamSpeed
ElseIf GetAsyncKeyState_(#VK_DOWN) <> 0
CameraZ = CameraZ + Sin((CamrotY-90)*piover180)*CamSpeed
CameraX = CameraX + Cos((CamrotY+90)*piover180)*CamSpeed
EndIf
If GetAsyncKeyState_(#VK_RIGHT) <> 0
CamrotY - (CamSpeed*5)
ElseIf GetAsyncKeyState_(#VK_LEFT) <> 0
CamrotY + (CamSpeed*5)
EndIf
glMatrixMode_(#GL_PROJECTION) ;Höhere Sichtweite, Kamera und Zoom
glLoadIdentity_()
glOrtho__(-2.0+CameraZoom, 2.0-CameraZoom, -2.0+CameraZoom, 2.0-CameraZoom, 0.0, 50.0)
glRotatef_(-CamrotY, 0.0, 1.0, 0.0)
glTranslatef_(0, 0, -10.0)
glMatrixMode_(#GL_MODELVIEW)
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glLoadIdentity_()
glRotatef_(45.0, 0, 1.0, 0.0)
glTranslatef_(-CameraX, -CameraY, -CameraZ)
glBegin_(#GL_TRIANGLES)
glNormal3f_(0, 0, 1.0)
glColor4f_(0.0, 0.0, 1.0, 1.0)
glVertex3f_(floatX, floatY, floatZ)
glColor4f_(0.0, 1.0, 0.0, 1.0)
glVertex3f_(-floatX, floatY, floatZ)
glColor4f_(1.0, 1.0, 0.0, 1.0)
glVertex3f_(-floatX, -floatY, floatZ)
glEnd_()
glBegin_(#GL_TRIANGLES)
glNormal3f_(0, 0, 1.0)
glColor4f_(0.0, 0.0, 1.0, 1.0)
glVertex3f_(floatX, floatY, floatZ+0.25)
glColor4f_(0.0, 1.0, 0.0, 1.0)
glVertex3f_(-floatX, floatY, floatZ+0.25)
glColor4f_(1.0, 1.0, 0.0, 1.0)
glVertex3f_(-floatX, -floatY, floatZ+0.25)
glEnd_()
SwapBuffers_(hDC)
Event = WindowEvent()
Delay(1) ;For WinME users
Until Event = #PB_Event_CloseWindow
End
EndIf
Uhm, here it looks a little bit crazy, but in my engine it works. And you can't show glu objects in this code. But maybe it will help other people with their walkthrough
.