Results 1 to 4 of 4

Thread: Open Gl Camera

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    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]

  2. #2
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Thumbs down

    Why write in C++ ?

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  4. #4
    New Member
    Join Date
    Nov 2000
    Posts
    11
    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
  •  



Click Here to Expand Forum to Full Width