OpenGL Camera
-
DarkDragon
- Addict

- Posts: 2348
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
I'm trying to do a CAMERA.
A camera who WORKS like this stuff in c++ (in fact, I just translated it into pure...)
http://www.ultimategameprogramming.com/ ... amera2.ZIP
here is the stuff without the glu camera, tell me if it works on computers where the first exe don't
http://www.gtnsoft.com/Pure3Dwtglu.exe
A camera who WORKS like this stuff in c++ (in fact, I just translated it into pure...)
http://www.ultimategameprogramming.com/ ... amera2.ZIP
here is the stuff without the glu camera, tell me if it works on computers where the first exe don't
http://www.gtnsoft.com/Pure3Dwtglu.exe
The movement i can see in the c-example is almost identical to the one in 'your' pb-app.Polo wrote:I'm trying to do a CAMERA.
A camera who WORKS like this stuff in c++ (in fact, I just translated it into pure...)
http://www.ultimategameprogramming.com/ ... amera2.ZIP
However: You SHOUT, I stop answering...
Good programmers don't comment their code. It was hard to write, should be hard to read.
-
DarkDragon
- Addict

- Posts: 2348
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
Look at this topic: viewtopic.php?t=9276
I wanted to make a camera, too. I'm triing to use gluLookAt instead of glOrtho since this topic, but I can't rotate the camera!?!
[EDIT]
Here is my code and it works with gluPerspective(on my pc):
I'm happy ^^
I wanted to make a camera, too. I'm triing to use gluLookAt instead of glOrtho since this topic, but I can't rotate the camera!?!
black!here is the stuff without the glu camera, tell me if it works on computers where the first exe don't
http://www.gtnsoft.com/Pure3Dwtglu.exe
[EDIT]
Here is my code and it works with gluPerspective(on my pc):
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
CamrotY = 50
hWnd = OpenWindow(0, 0, 0, #WindowWidth, #WindowHeight, #WindowFlags, "OpenGLCamera")
If hWnd <> 0
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
glu = gluNewQuadric_()
Repeat
glTranslatef_(0, 0, -7.0)
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_()
gluPerspective__(45, WindowWidth()/WindowHeight(), 0.0, 20.0)
gluLookAt__(CameraX, CameraY, CameraZ, CameraX - Cos((CamrotY+90)*piover180)*5, 0.0, -CameraZ - Sin((CamrotY-90)*piover180)*5, 0.0, 1.0, 0.0)
; glOrtho__(-2.0+CameraZoom, 2.0-CameraZoom, -2.0+CameraZoom, 2.0-CameraZoom, 0.0, 20.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
EndIfgluPerspective__ , gluLookAt__ problems
I have been trying to run the code listed on this page using PureBasic and keep getting an error of this nature:
gluPerspective__() is not a function, an array, or a linked list.
I get a similar error with gluLookAt__ if I remark out the gluPerspective__ statement.
If I reduce the number of underscores to one after the command, PureBasic seems to recognize the function, but tells me that I have an incorrect number of parameters. I am new to PureBasic from C programming using OpenGL/GLUT, but based on the C gluPerspective statement, the number of parameters appears to be correct.
Am I missing an include file that provides glu/glut functionality?
Thanks,
Stan
gluPerspective__() is not a function, an array, or a linked list.
I get a similar error with gluLookAt__ if I remark out the gluPerspective__ statement.
If I reduce the number of underscores to one after the command, PureBasic seems to recognize the function, but tells me that I have an incorrect number of parameters. I am new to PureBasic from C programming using OpenGL/GLUT, but based on the C gluPerspective statement, the number of parameters appears to be correct.
Am I missing an include file that provides glu/glut functionality?
Thanks,
Stan
Re: gluPerspective__ , gluLookAt__ problems
viewtopic.php?t=9116sblank wrote: Am I missing an include file that provides glu/glut functionality?
Good programmers don't comment their code. It was hard to write, should be hard to read.
glWrapper fixed glu commands...
Thanks... worked like a charm!
This language definitely has potential...
Stan
This language definitely has potential...
Stan


