OpenGL Camera
OpenGL Camera
I'm trying to do a camera with OpenGL, but it seems to be extremely difficult. I have readed some C++ tutorials, but, for the moment, I have some troubles to make it in Purebasic, it don't seems easy to translate it... Could someone help ? Perhaps someone here have already does that and can post his code 
-
DarkDragon
- Addict

- Posts: 2348
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
Uhm, you can define the view with glMatrixMode_(#GL_PROJECTION) : glLoadIdentity_() : Your Code : glMatrixMode_(#GL_MODELVIEW)
"Your Code" can be replaced by glOrtho, glViewport and so on. Look in the OpenGL tutorials.
My favorites:
1: http://nehe.gamedev.net/
2: http://gametutorials.com/
3: http://www.ultimategameprogramming.com/index2.php
And I have the OpenGL helpfile, but I don't know where you can download it.
"Your Code" can be replaced by glOrtho, glViewport and so on. Look in the OpenGL tutorials.
My favorites:
1: http://nehe.gamedev.net/
2: http://gametutorials.com/
3: http://www.ultimategameprogramming.com/index2.php
And I have the OpenGL helpfile, but I don't know where you can download it.
Polo wrote:[...]because it uses Vector, and I can't use it on Pure...[...]
"Vector" is neither C nor OpenGl-related.
I'm just taking a guess here, but maybe this may bring you on the right track:
Code: Select all
Structure Vector3
x.f
y.f
z.f
EndStructureCode: Select all
float Magnitude(CVector3 vNormal)
{
// This will give us the magnitude or "Norm" as some say of, our normal.
// The magnitude has to do with the length of the vector. We use this
// information to normalize a vector, which gives it a length of 1.
// Here is the equation: magnitude = sqrt(V.x^2 + V.y^2 + V.z^2) Where V is the vector
return (float)sqrt( (vNormal.x * vNormal.x) +
(vNormal.y * vNormal.y) +
(vNormal.z * vNormal.z) );
}Code: Select all
Procedure.f Magnitude(*vNormal.Vector3)
ProcedureReturn Sqr( (*vNormal\x * *vNormal\x) + (*vNormal\y * *vNormal\y) + (*vNormal\z * *vNormal\z) )
EndProcedureGood programmers don't comment their code. It was hard to write, should be hard to read.
Have troubles with translating that :
// Normalize the direction.
float dp = (float)sqrt(xLookDirection * xLookDirection + yLookDirection * yLookDirection + zLookDirection * zLookDirection);
xLookDirection /= dp;
yLookDirection /= dp;
zLookDirection /= dp;
Well, I don't know what I'm supposed to put ...
// Normalize the direction.
float dp = (float)sqrt(xLookDirection * xLookDirection + yLookDirection * yLookDirection + zLookDirection * zLookDirection);
xLookDirection /= dp;
yLookDirection /= dp;
zLookDirection /= dp;
Well, I don't know what I'm supposed to put ...
Polo wrote:Have troubles with translating that :
Code: Select all
; Normalize the direction.
dp.f = Sqr(xLookDirection * xLookDirection + yLookDirection * yLookDirection + zLookDirection * zLookDirection)
xLookDirection / dp
yLookDirection / dp
zLookDirection / dpThe problem is that what Danila as wrote don't work at all... If I don't put it, (I have translated all except this), well, it works, but the camero don't always go where it is supposed to, and if I put what Danilo as wrote, well, the camera don't move
...
Does someone know how to make it works ? I have worked on it for 4 hours, and it still doesn't work
...
Does someone know how to make it works ? I have worked on it for 4 hours, and it still doesn't work
Polo wrote:The problem is that what Danila[...]
The problem must be somewhere else as Danilos "translation" is correctDoes someone know how to make it works ? I have worked on it for 4 hours, and it still doesn't work![]()
Vector-Math is one of the essentials in 3D programming. Is that what you mean?Ok, thanks, I see. But is there a way to do camera without vectors ?
Good programmers don't comment their code. It was hard to write, should be hard to read.
Forget what I say with vectors....
Well, I join an EXE file of my camera test, and you'll see the problem :
http://www.gtnsoft.com/Pure3D.exe
To move, just use the Arrow keys...
Well, I join an EXE file of my camera test, and you'll see the problem :
http://www.gtnsoft.com/Pure3D.exe
To move, just use the Arrow keys...
-
DarkDragon
- Addict

- Posts: 2348
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
done.Polo wrote:Forget what I say with vectors....
With "Problem", do you mean seeing "nothing" or a not expected behaviour in movement?Well, I join an EXE file of my camera test, and you'll see the problem :
I can't see anything on my pc at work (ATI) but it displays fine on my Geforce4 at home.
Good programmers don't comment their code. It was hard to write, should be hard to read.
