Page 1 of 2
OpenGL Camera
Posted: Sat Jan 31, 2004 5:43 pm
by Polo
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

Posted: Sat Jan 31, 2004 6:00 pm
by DarkDragon
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.
Posted: Sat Jan 31, 2004 6:04 pm
by Polo
I have already looked at all these tutorial, the fact is I can't make them in Purebasic, because it uses Vector, and I can't use it on Pure...
Posted: Sat Jan 31, 2004 6:44 pm
by Polo
If you can translate the camera tutorial 3 of Gametutorials in Purebasic, well, please do it, me I can't

Posted: Sat Jan 31, 2004 9:38 pm
by traumatic
Polo wrote:If you can translate the camera tutorial 3 of Gametutorials in Purebasic, well, please do it, me I can't

What exactly is your problem with this?
Posted: Sat Jan 31, 2004 9:45 pm
by traumatic
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
EndStructure
and this
Code: 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) );
}
becomes
Code: Select all
Procedure.f Magnitude(*vNormal.Vector3)
ProcedureReturn Sqr( (*vNormal\x * *vNormal\x) + (*vNormal\y * *vNormal\y) + (*vNormal\z * *vNormal\z) )
EndProcedure
and so on...
Posted: Sun Feb 01, 2004 10:29 am
by Polo
Ok, thanks, I see. But is there a way to do camera without vectors ?
Posted: Sun Feb 01, 2004 12:52 pm
by Polo
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 ...
Posted: Sun Feb 01, 2004 1:07 pm
by Danilo
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 / dp
Posted: Sun Feb 01, 2004 3:08 pm
by Polo
The 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

Posted: Sun Feb 01, 2004 7:15 pm
by traumatic
Polo wrote:The problem is that what Danila[...]
Does someone know how to make it works ? I have worked on it for 4 hours, and it still doesn't work
The problem must be somewhere else as Danilos "translation" is correct
Ok, thanks, I see. But is there a way to do camera without vectors ?
Vector-Math is one of the essentials in 3D programming. Is that what you mean?
Posted: Sun Feb 01, 2004 7:34 pm
by Polo
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...
Posted: Tue Feb 03, 2004 4:18 pm
by DarkDragon
^^ Black. I have the same problem, when I use gluPerspective, gluPerspectivef or gluPerspective__. I don't know what I'm making wrong, because I have tryed gluPerspective with all known standardparameters of other languages.
Can you give us your code to test it?
Posted: Tue Feb 03, 2004 4:49 pm
by traumatic
Polo wrote:Forget what I say with vectors....
done.
Well, I join an EXE file of my camera test, and you'll see the problem :
With "Problem", do you mean seeing "nothing" or a not expected behaviour in movement?
I can't see anything on my pc at work (ATI) but it displays fine on my Geforce4 at home.
Posted: Tue Feb 03, 2004 5:50 pm
by Polo
You see nothing ? Well... No it wasn't the problem

Well, can you try the camera with th pc where it works, and tell me what I'm doing wrong ?
For the other problem, well...
Darkdragon, do you get an error message or is it just black ??