|
-
Dec 23rd, 2000, 05:41 AM
#1
Thread Starter
Frenzied Member
Hi,
Here is What I have so far:
int DrawGLScene(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, triz);
glRotatef(triy, 0.0f, 1.0f, 0.0f);
glRotatef(trix, 1.0f, 0.0f, 0.0f);
glBegin(GL_TRIANGLES);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 1.0f, 0.0f);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glColor3f(0.0f, 0.0f, 1.0f);
glVertex3f(1.0f, -1.0f, 1.0f);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f( 1.0f,-1.0f, 1.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f( 1.0f,-1.0f, -1.0f);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f( 1.0f,-1.0f, -1.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(-1.0f,-1.0f, -1.0f);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(-1.0f,-1.0f,-1.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-1.0f,-1.0f, 1.0f);
glEnd();
if (keys[VK_LEFT])
{
triy++;
}
if (keys[VK_RIGHT])
{
triy--;
}
if (keys[VK_UP])
{
trix--;
}
if (keys[VK_DOWN])
{
trix++;
}
if (keys[VK_F2])
{
triz = triz + 0.1f;
}
if (keys[VK_F3])
{
triz = triz - 0.1f;
}
return TRUE;
}
This code works fine for drawing a triangle to the screen and then you can move the camera around the triangle. What my problem is, is that I want to be able to rotate the camera on the spot as opposed to rotating it relative to the trangle.
Ok, I have figured that I have to use the glLookAt();
Does any one know hot to use this ?
[Edited by PsyVision on 12-23-2000 at 05:47 AM]
-
Dec 28th, 2000, 05:40 AM
#2
Frenzied Member
-
Dec 28th, 2000, 09:00 AM
#3
Monday Morning Lunatic
Because it's faster, and pointers make it much more flexible for graphics. (chains of doubly linked lists, for example).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Dec 28th, 2000, 03:51 PM
#4
New Member
Without gluLookat:
Put the viewer at (0,0,0), then glrotate.
With gluLookAt:
Code:
Visual Basic:
gluLookAt cameraX, cameraY, cameraZ, pointtolookatX, _
pointtolookatY, pointtolookatZ, 0, 1, 0
If you want to tilt the camera you'll need to alter the last three values: 0, 1, 0
Code:
Sub PostMessage(Message As String)
On Error Goto Debug
Forum.Messages.Post Message, Name
Exit Sub
Debug:
For ctr = 1 To Bugs.Count
Bugs(ctr).Squish
If Bugs(ctr).Status <> vbDead Then
Flamethrower.Target = Bug(ctr)
Flamethrower.Burn
End If
Next ctr
Resume
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|