Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,379 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,175 people online right now. Registration is fast and FREE... Join Now!




Rotating the camera with the mouse

 
Reply to this topicStart new topic

Rotating the camera with the mouse

bushimports
post 21 Aug, 2008 - 03:30 PM
Post #1


New D.I.C Head

*
Joined: 21 Aug, 2008
Posts: 6

I am trying to use the mouse with glut passive motion func to rotate the camera/scene with the mouse. the arrow keys and the page up page down seem to work ok but the mouse is not working correctly. It seems that if you run your cursor across the top of the page that the cube is rotating one way on the y axis and then back the other direction. I don't know what to do to get it to rotate properly. Also the rotation on the x axis for looking up and down is also screwy. actually I think the cursor should stay positioned in the center of the screen. I did a cout test to see if glut was recognizing the center of the window but even though it knows exactly where the cusor is on the screen it does not seem to be able to aknowlede the center of the window. Probably the best way for you to see what I am trying to explain is to compile the program and see for ypurself what it is doing. I used the 2008 express version of microsofts IDE to compile this. Please try to keep the answer as simple as possible because I am new to all of this (programming in general).
Much Thanks , L.J.Bush

CODE

#include <math.h>
#include <stdlib.h>
#include <GL/glut.h>
#include <iostream>
//#define pi = 3.14159;
using namespace std;

bool lbuttonDown;
int direction;
float angle=0.0,ratio;
float x=0.0f,y=0.0f,z=0.0f;
float lx=0.0f,ly=0.0f,lz=0.0f;
float upx=0.0f,upy=1.0f,upz=0.0f;
float _angle = 30.0f;
float _cameraAngle = 0.0f;

void RotY(float ang) {

    lx = sin(ang);
    lz = -cos(ang);
    glLoadIdentity();
    gluLookAt(x, y, z,
              x + lx,y + ly,z + lz,
              0.0f,1.0f,0.0f);
}

void moveFB(int direction) {
    x = x + direction*(lx)*0.1;
    z = z + direction*(lz)*0.1;
    glLoadIdentity();
    gluLookAt(x, y, z,
              x + lx,y + ly,z + lz,
              0.0f,1.0f,0.0f);
}

void RotX(float ang) {
    ly = sin(ang);
    lz = -cos(ang);
    glLoadIdentity();
    gluLookAt(x, y, z,
              x + lx,y + ly,z + lz,
              0,1,0);
/*if (angle + x > 360) {
      angle = 360;
  }
else if(angle - x < -360) {
angle = -360;
  }*/

}

void initRendering() {
    glEnable(GL_DEPTH_TEST);
}

void handleKeypress(unsigned char key,
                    int x, int y) {
    switch (key) {
        case 27:
        exit(0);
        
    }
}

void handleSpecialKey(int key, int x, int y) {
    
    switch (key) {
        case GLUT_KEY_LEFT :
            angle -= 0.1f;
            RotY(angle);
            break;
        case GLUT_KEY_RIGHT :
            angle +=0.1f;
            RotY(angle);
            break;
        case GLUT_KEY_UP :
            moveFB(1);
            break;
        case GLUT_KEY_DOWN :
            moveFB(-1);
            break;
        /*case GLUT_KEY_UP && GLUT_KEY_RIGHT:
            angle+=0.1f
            ((moveFB(1), RotY(angle));
            break;
        case GLUT_KEY_UP && GLUT_KEY_LEFT:              
            angle-=0.1f
            (moveFB(1), RotY(angle));
            break;
        case GLUT_KEY_DOWN && GLUT_KEY_RIGHT:
            angle+=0.1f
            (moveFB(-1), RotY(angle));
            break;
        case GLUT_KEY_DOWN && GLUT_KEY_LEFT:
            angle-=0.1f
            (moveFB(-1), RotY(angle));
            break;*/
        case GLUT_KEY_PAGE_UP :
            angle +=0.01f;
            RotX(angle);
            break;
        case GLUT_KEY_PAGE_DOWN :
            angle -=0.01f;
            RotX(angle);
            break;
      
    
    }
}
void mouse(int button, int state, int x, int y)
{
    if (button == GLUT_RIGHT_BUTTON)
    {
        if (state == GLUT_DOWN)
            glScalef(2.0,2.0,2.0);
        else
            
            cout << "right button lifted at (" <<  x << "," << y << ")" << endl;
    }
    else if (button == GLUT_LEFT_BUTTON)
    {
        if (state == GLUT_DOWN)
            cout << "you shot me" << endl;
        
          
    }
}

void motionPassive(int x, int y)
{  
    glutSetCursor(GLUT_CURSOR_FULL_CROSSHAIR);  

    cout << "Mouse moved at "
        << "(" << x << "," << y << ")" << endl;
            
    
    if(x >= (GLUT_WINDOW_WIDTH/2)){  
     cout << "Mouse is Greater than the center of the width" << endl;
        
    angle = x/10 * 0.5f;//- (GLUT_WINDOW_WIDTH)* 0.1f;
    RotY(angle);
    }
    else if(x <=  (GLUT_WINDOW_WIDTH)){  
    cout << "Mouse is Less than the center of the width" << endl;
    
    angle = x/10 * -0.5f;//-(GLUT_WINDOW_WIDTH)* -0.1f;
    RotY(angle);
    }
    
    
    if(y >= ((GLUT_WINDOW_HEIGHT)/2)){  
    cout << "Mouse is Greater than the center of the height" << endl;
    
    angle = y/10 * 0.1f;//- (GLUT_WINDOW_HEIGHT)* 0.1f;
    RotX(angle);
    }
    else if(y <= ((GLUT_WINDOW_HEIGHT)/2)){  
    cout << "Mouse is Less than the center of the height" << endl;
    
    angle = y/10 * -0.1f;
    RotX(angle);
    }
    

}



void handleResize(int w, int h) {
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0,
                   (double)w / (double)h,
                   0.25,
                   200.0);
}

void drawScene() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_COLOR_MATERIAL);  
    glShadeModel(GL_SMOOTH);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(x, y, z,
              x + lx,y + ly,z + lz,
            0.0f,1.0f,0.0f);

    
    //glRotatef(LookUpDown,1.0,0,0);      
    glPushMatrix();
    
    glTranslatef(0.0f, 0.0f, 0.0f); //Move to the center of the trapezoid
    glRotatef(_angle, 0.0f, 1.0f, 0.0f);
    glScalef(0.01f, 0.01f, 0.01f);
    glBegin(GL_QUADS);
    //Cross back
    glColor4f(1.0f,1.0f, 0.0f, 0.9f);
    glVertex3f(-0.5, 2.5, -0.5);
    glVertex3f(-0.5, -3.0, -0.5);
    glVertex3f(0.5, -3.0, -0.5);
    glVertex3f(0.5, 2.5, -0.5);
    
    glVertex3f(-2.0, 1.0, -0.5);
    glVertex3f(-2.0, 0.0, -0.5);
    glVertex3f(2.0, 0.0, -0.5);
    glVertex3f(2.0, 1.0, -0.5);
  
    
    //Cross front
    glColor4f(1.0f, 1.0f, 0.0f, 0.5f);
    glVertex3f(-0.5, 2.5, 0.5);
    glVertex3f(-0.5, -3.0, 0.5);
    glVertex3f(0.5, -3.0, 0.5);
    glVertex3f(0.5, 2.5, 0.5);
    
    glVertex3f(-2.0, 1.0, 0.5);
    glVertex3f(-2.0, 0.0, 0.5);
    glVertex3f(2.0, 0.0, 0.5);
    glVertex3f(2.0, 1.0, 0.5);

      //Cross top
    glVertex3f(0.5, 2.5, 0.5);
    glVertex3f(-0.5, 2.5, 0.5);
    glVertex3f(-0.5, 2.5, -0.5);
    glVertex3f(0.5, 2.5, -0.5);
    //Cross left top side
    glVertex3f(-0.5, 2.5, 0.5);
    glVertex3f(-0.5, 2.5, -0.5);
    glVertex3f(-0.5, 1.0, -0.5);
    glVertex3f(-0.5, 1.0, 0.5);        
    //Cross left side  top
    glVertex3f(-0.5, 1.0, 0.5);
    glVertex3f(-0.5, 1.0, -0.5);
    glVertex3f(-2.0, 1.0, -0.5);
    glVertex3f(-2.0, 1.0, 0.5);        
    
    //Cross left side  end
    glVertex3f(-2.0, 1.0, 0.5);
    glVertex3f(-2.0, 1.0, -0.5);
    glVertex3f(-2.0, 0.0, -0.5);
    glVertex3f(-2.0, 0.0, 0.5);        
    
    //Cross left side bottom
    glVertex3f(-2.0, 0.0, 0.5);
    glVertex3f(-0.5, 0.0, 0.5);
    glVertex3f(-0.5, 0.0, -0.5);
    glVertex3f(-2.0, 0.0, -0.5);        
    //Cross left bottom side
    glVertex3f(-0.5, 0.0, 0.5);
    glVertex3f(-0.5, 0.0, -0.5);
    glVertex3f(-0.5, -3.0, -0.5);
    glVertex3f(-0.5, -3.0, 0.5);
    //Cross  bottom
    glVertex3f(0.5, -3.0, 0.5);
    glVertex3f(0.5, -3.0, -0.5);
    glVertex3f(-0.5, -3.0, -0.5);
    glVertex3f(-0.5, -3.0, 0.5);
    
    //Cross right bottom side
    glVertex3f(0.5, 0.0, 0.5);
    glVertex3f(0.5, -3.0, 0.5);
    glVertex3f(0.5, -3.0, -0.5);
    glVertex3f(0.5, 0.0, -0.5);
    
    //Cross right side bottom
    glVertex3f(0.5, 0.0, 0.5);
    glVertex3f(0.5, 0.0, -0.5);
    glVertex3f(2.0, 0.0, -0.5);
    glVertex3f(2.0, 0.0, 0.5);
    //Cross right side end
    glVertex3f(2.0, 1.0, 0.5);
    glVertex3f(2.0, 0.0, 0.5);
    glVertex3f(2.0, 0.0, -0.5);
    glVertex3f(2.0, 1.0, -0.5);
    
    //Cross right side top
    glVertex3f(0.5, 1.0, 0.5);
    glVertex3f(2.0, 1.0, 0.5);
    glVertex3f(2.0, 1.0, -0.5);
    glVertex3f(0.5, 1.0, -0.5);
    //Cross right side top
    glVertex3f(0.5, 1.0, 0.5);
    glVertex3f(0.5, 1.0, -0.5);
    glVertex3f(0.5, 2.5, -0.5);
    glVertex3f(0.5, 2.5, 0.5);
    glEnd();
    glPopMatrix();
    
    glPushMatrix();
    glBegin(GL_QUADS);
    glTranslatef(0.0f, -1.5f, 0.0f);
    glRotatef(_angle,0.0,0.0,0.0);
    //floor
    glColor3f(0.5, 1.0, 0.0);
    glVertex3f(-10.0,-0.5,10);
    glVertex3f(-10.0,-0.5,-10);
    glVertex3f(10.0,-0.5,-10);
    glVertex3f(10.0,-0.5,10);
    
    
    
    
    //front
    glColor3f(1.0, 0.0, 0.0);
    glVertex3f(-0.5,-0.5,-5);
    glVertex3f(0.5,-0.5,-5);
    glVertex3f(0.5,0.5,-5);
    glVertex3f(-0.5,0.5,-5);

    //back
    glColor3f(0.0, 1.0, 0.0);
    glVertex3f(-0.5,-0.5,-6);
    glVertex3f(0.5,-0.5,-6);
    glVertex3f(0.5,0.5,-6);
    glVertex3f(-0.5,0.5,-6);

    //botom
    glColor3f(0.0, 0.0, 1.0);
    glVertex3f(-0.5,-0.5,-5);
    glVertex3f(0.5,-0.5,-5);
    glVertex3f(0.5,-0.5,-6);
    glVertex3f(-0.5,-0.5,-6);

    //up
    glColor3f(0.9, 0.9, 0.9);
    glVertex3f(-0.5,0.5,-5);
    glVertex3f(0.5,0.5,-5);
    glVertex3f(0.5,0.5,-6);
    glVertex3f(-0.5,0.5,-6);

    //left
    glColor3f(0.0, 0.0, 1.0);
    glVertex3f(-0.5,-0.5,-5);
    glVertex3f(-0.5,-0.5,-6);
    glVertex3f(-0.5,0.5,-6);
    glVertex3f(-0.5,0.5,-5);

    //right
    glColor3f(0.0, 0.0, 1.0);
    glVertex3f(0.5,-0.5,-5);
    glVertex3f(0.5,-0.5,-6);
    glVertex3f(0.5,0.5,-6);
    glVertex3f(0.5,0.5,-5);
    glEnd();
    glPopMatrix();
    glutSwapBuffers();
}
void update(int value) {
    _angle += 4.0f;
    if (_angle > 360) {
        _angle -= 360;
    }
    
    glutPostRedisplay();
    glutTimerFunc(25, update, 0);
}    
    int main(int argc, char** argv) {
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowSize(500,500);
    glutCreateWindow("Rotaion Test");
    initRendering();
    
    //glutFullScreen();
    glutDisplayFunc(drawScene);
    glutKeyboardFunc(handleKeypress);
    glutSpecialFunc(handleSpecialKey);
    glutReshapeFunc(handleResize);
    glutTimerFunc(25,update,0);
    glutMouseFunc(mouse);
    glutPassiveMotionFunc(motionPassive);
    glutMainLoop();
    return 0;
}

User is offlineProfile CardPM

Go to the top of the page

bobjob
post 22 Aug, 2008 - 09:50 PM
Post #2


D.I.C Head

**
Joined: 29 Mar, 2008
Posts: 61



Thanked 1 times
My Contributions


Do you need to use GLUT for the camera?

y not just do this

CODE

   glRotatef(xRot,1.0f,0.0f,0.0f); //rotate our camera on teh x-axis (left and right)
   glRotatef(yRot,0.0f,1.0f,0.0f); //rotate our camera on the y-axis (up and down)
   glTranslated(-xpos,-ypos,-zpos); //translate the screen to the position of our camera



and just change the rotation values when u move the mouse.

so your render code should look something like

CODE

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The ModelView Matrix
  

//placeCamera
glRotatef(xRot,1.0f,0.0f,0.0f); //rotate our camera on teh x-axis (left and right)
glRotatef(yRot,0.0f,1.0f,0.0f); //rotate our camera on the y-axis (up and down)
glTranslated(-xpos,-ypos,-zpos); //translate the screen to the position of our camera

//draw 3d Screne;
drawObject();



CODE

void drawObject() {

                glPushMatrix();
    glRotatef(_angle, 0.0f, 1.0f, 0.0f);
    glScalef(0.01f, 0.01f, 0.01f);
    glBegin(GL_QUADS);
    //Cross back
    glColor4f(1.0f,1.0f, 0.0f, 0.9f);
    glVertex3f(-0.5, 2.5, -0.5);
    glVertex3f(-0.5, -3.0, -0.5);
    glVertex3f(0.5, -3.0, -0.5);
    glVertex3f(0.5, 2.5, -0.5);
    
    glVertex3f(-2.0, 1.0, -0.5);
    glVertex3f(-2.0, 0.0, -0.5);
    glVertex3f(2.0, 0.0, -0.5);
    glVertex3f(2.0, 1.0, -0.5);
  
    
    //Cross front
    glColor4f(1.0f, 1.0f, 0.0f, 0.5f);
    glVertex3f(-0.5, 2.5, 0.5);
    glVertex3f(-0.5, -3.0, 0.5);
    glVertex3f(0.5, -3.0, 0.5);
    glVertex3f(0.5, 2.5, 0.5);
    
    glVertex3f(-2.0, 1.0, 0.5);
    glVertex3f(-2.0, 0.0, 0.5);
    glVertex3f(2.0, 0.0, 0.5);
    glVertex3f(2.0, 1.0, 0.5);

      //Cross top
    glVertex3f(0.5, 2.5, 0.5);
    glVertex3f(-0.5, 2.5, 0.5);
    glVertex3f(-0.5, 2.5, -0.5);
    glVertex3f(0.5, 2.5, -0.5);
    //Cross left top side
    glVertex3f(-0.5, 2.5, 0.5);
    glVertex3f(-0.5, 2.5, -0.5);
    glVertex3f(-0.5, 1.0, -0.5);
    glVertex3f(-0.5, 1.0, 0.5);        
    //Cross left side  top
    glVertex3f(-0.5, 1.0, 0.5);
    glVertex3f(-0.5, 1.0, -0.5);
    glVertex3f(-2.0, 1.0, -0.5);
    glVertex3f(-2.0, 1.0, 0.5);        
    
    //Cross left side  end
    glVertex3f(-2.0, 1.0, 0.5);
    glVertex3f(-2.0, 1.0, -0.5);
    glVertex3f(-2.0, 0.0, -0.5);
    glVertex3f(-2.0, 0.0, 0.5);        
    
    //Cross left side bottom
    glVertex3f(-2.0, 0.0, 0.5);
    glVertex3f(-0.5, 0.0, 0.5);
    glVertex3f(-0.5, 0.0, -0.5);
    glVertex3f(-2.0, 0.0, -0.5);        
    //Cross left bottom side
    glVertex3f(-0.5, 0.0, 0.5);
    glVertex3f(-0.5, 0.0, -0.5);
    glVertex3f(-0.5, -3.0, -0.5);
    glVertex3f(-0.5, -3.0, 0.5);
    //Cross  bottom
    glVertex3f(0.5, -3.0, 0.5);
    glVertex3f(0.5, -3.0, -0.5);
    glVertex3f(-0.5, -3.0, -0.5);
    glVertex3f(-0.5, -3.0, 0.5);
    
    //Cross right bottom side
    glVertex3f(0.5, 0.0, 0.5);
    glVertex3f(0.5, -3.0, 0.5);
    glVertex3f(0.5, -3.0, -0.5);
    glVertex3f(0.5, 0.0, -0.5);
    
    //Cross right side bottom
    glVertex3f(0.5, 0.0, 0.5);
    glVertex3f(0.5, 0.0, -0.5);
    glVertex3f(2.0, 0.0, -0.5);
    glVertex3f(2.0, 0.0, 0.5);
    //Cross right side end
    glVertex3f(2.0, 1.0, 0.5);
    glVertex3f(2.0, 0.0, 0.5);
    glVertex3f(2.0, 0.0, -0.5);
    glVertex3f(2.0, 1.0, -0.5);
    
    //Cross right side top
    glVertex3f(0.5, 1.0, 0.5);
    glVertex3f(2.0, 1.0, 0.5);
    glVertex3f(2.0, 1.0, -0.5);
    glVertex3f(0.5, 1.0, -0.5);
    //Cross right side top
    glVertex3f(0.5, 1.0, 0.5);
    glVertex3f(0.5, 1.0, -0.5);
    glVertex3f(0.5, 2.5, -0.5);
    glVertex3f(0.5, 2.5, 0.5);
    glEnd();
    glPopMatrix();

}





also there is alot of things that dont need to be in your code eg.

glTranslatef(0.0f, 0.0f, 0.0f); //Move to the center of the trapezoid - not so!
this does nothing, it translates 0 on all axis


glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_COLOR_MATERIAL);
glShadeModel(GL_SMOOTH);
this does not need to be called each loop, just do this once at startup
therefore add this code to the:
void initRendering() function.


add this to the bottom of the handleResize function
glMatrixMode(GL_MODELVIEW); //remove this from drawScene function
glLoadIdentity();


This post has been edited by bobjob: 22 Aug, 2008 - 09:56 PM
User is online!Profile CardPM

Go to the top of the page

bushimports
post 23 Aug, 2008 - 02:06 PM
Post #3


New D.I.C Head

*
Joined: 21 Aug, 2008
Posts: 6

QUOTE(bobjob @ 22 Aug, 2008 - 10:50 PM) *

Do you need to use GLUT for the camera?

y not just do this

CODE

   glRotatef(xRot,1.0f,0.0f,0.0f); //rotate our camera on teh x-axis (left and right)
   glRotatef(yRot,0.0f,1.0f,0.0f); //rotate our camera on the y-axis (up and down)
   glTranslated(-xpos,-ypos,-zpos); //translate the screen to the position of our camera



and just change the rotation values when u move the mouse.

so your render code should look something like

CODE

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The ModelView Matrix
  

//placeCamera
glRotatef(xRot,1.0f,0.0f,0.0f); //rotate our camera on teh x-axis (left and right)
glRotatef(yRot,0.0f,1.0f,0.0f); //rotate our camera on the y-axis (up and down)
glTranslated(-xpos,-ypos,-zpos); //translate the screen to the position of our camera

//draw 3d Screne;
drawObject();



CODE

void drawObject() {

                glPushMatrix();
    glRotatef(_angle, 0.0f, 1.0f, 0.0f);
    glScalef(0.01f, 0.01f, 0.01f);
    glBegin(GL_QUADS);
    //Cross back
    glColor4f(1.0f,1.0f, 0.0f, 0.9f);
    glVertex3f(-0.5, 2.5, -0.5);
    glVertex3f(-0.5, -3.0, -0.5);
    glVertex3f(0.5, -3.0, -0.5);
    glVertex3f(0.5, 2.5, -0.5);
    
    glVertex3f(-2.0, 1.0, -0.5);
    glVertex3f(-2.0, 0.0, -0.5);
    glVertex3f(2.0, 0.0, -0.5);
    glVertex3f(2.0, 1.0, -0.5);
  
    
    //Cross front
    glColor4f(1.0f, 1.0f, 0.0f, 0.5f);
    glVertex3f(-0.5, 2.5, 0.5);
    glVertex3f(-0.5, -3.0, 0.5);
    glVertex3f(0.5, -3.0, 0.5);
    glVertex3f(0.5, 2.5, 0.5);
    
    glVertex3f(-2.0, 1.0, 0.5);
    glVertex3f(-2.0, 0.0, 0.5);
    glVertex3f(2.0, 0.0, 0.5);
    glVertex3f(2.0, 1.0, 0.5);

      //Cross top
    glVertex3f(0.5, 2.5, 0.5);
    glVertex3f(-0.5, 2.5, 0.5);
    glVertex3f(-0.5, 2.5, -0.5);
    glVertex3f(0.5, 2.5, -0.5);
    //Cross left top side
    glVertex3f(-0.5, 2.5, 0.5);
    glVertex3f(-0.5, 2.5, -0.5);
    glVertex3f(-0.5, 1.0, -0.5);
    glVertex3f(-0.5, 1.0, 0.5);        
    //Cross left side  top
    glVertex3f(-0.5, 1.0, 0.5);
    glVertex3f(-0.5, 1.0, -0.5);
    glVertex3f(-2.0, 1.0, -0.5);
    glVertex3f(-2.0, 1.0, 0.5);        
    
    //Cross left side  end
    glVertex3f(-2.0, 1.0, 0.5);
    glVertex3f(-2.0, 1.0, -0.5);
    glVertex3f(-2.0, 0.0, -0.5);
    glVertex3f(-2.0, 0.0, 0.5);        
    
    //Cross left side bottom
    glVertex3f(-2.0, 0.0, 0.5);
    glVertex3f(-0.5, 0.0, 0.5);
    glVertex3f(-0.5, 0.0, -0.5);
    glVertex3f(-2.0, 0.0, -0.5);        
    //Cross left bottom side
    glVertex3f(-0.5, 0.0, 0.5);
    glVertex3f(-0.5, 0.0, -0.5);
    glVertex3f(-0.5, -3.0, -0.5);
    glVertex3f(-0.5, -3.0, 0.5);
    //Cross  bottom
    glVertex3f(0.5, -3.0, 0.5);
    glVertex3f(0.5, -3.0, -0.5);
    glVertex3f(-0.5, -3.0, -0.5);
    glVertex3f(-0.5, -3.0, 0.5);
    
    //Cross right bottom side
    glVertex3f(0.5, 0.0, 0.5);
    glVertex3f(0.5, -3.0, 0.5);
    glVertex3f(0.5, -3.0, -0.5);
    glVertex3f(0.5, 0.0, -0.5);
    
    //Cross right side bottom
    glVertex3f(0.5, 0.0, 0.5);
    glVertex3f(0.5, 0.0, -0.5);
    glVertex3f(2.0, 0.0, -0.5);
    glVertex3f(2.0, 0.0, 0.5);
    //Cross right side end
    glVertex3f(2.0, 1.0, 0.5);
    glVertex3f(2.0, 0.0, 0.5);
    glVertex3f(2.0, 0.0, -0.5);
    glVertex3f(2.0, 1.0, -0.5);
    
    //Cross right side top
    glVertex3f(0.5, 1.0, 0.5);
    glVertex3f(2.0, 1.0, 0.5);
    glVertex3f(2.0, 1.0, -0.5);
    glVertex3f(0.5, 1.0, -0.5);
    //Cross right side top
    glVertex3f(0.5, 1.0, 0.5);
    glVertex3f(0.5, 1.0, -0.5);
    glVertex3f(0.5, 2.5, -0.5);
    glVertex3f(0.5, 2.5, 0.5);
    glEnd();
    glPopMatrix();

}





also there is alot of things that dont need to be in your code eg.

glTranslatef(0.0f, 0.0f, 0.0f); //Move to the center of the trapezoid - not so!
this does nothing, it translates 0 on all axis


glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_COLOR_MATERIAL);
glShadeModel(GL_SMOOTH);
this does not need to be called each loop, just do this once at startup
therefore add this code to the:
void initRendering() function.


add this to the bottom of the handleResize function
glMatrixMode(GL_MODELVIEW); //remove this from drawScene function
glLoadIdentity();







Thanks man I'll see if I can make it work I actually am just starting to learn to do anything with OpenGL and it seems to be pretty easy it's just hard for me to remember everything ,my memory does not seem to be as good as it used to be . The reason I was using glut is because I really did not want to have to learn windows it just takes too much code and is not that easy to remember,I think that very little of what I have covered in windows has stuck very well. I guess if I have problems I'll be back. Much Thanks again, L.J. Bush
User is offlineProfile CardPM

Go to the top of the page

Tom9729
post 23 Aug, 2008 - 10:17 PM
Post #4


Debian guru

Group Icon
Joined: 30 Dec, 2007
Posts: 1,447



Thanked 10 times

Dream Kudos: 325
My Contributions


I actually don't think GLU is related to GLUT.

Personally I don't really like using gluLookAt(), but that's just me.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 06:18AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month