Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualBrother Bob

Posted 22 July 2013 - 11:57 AM

That's because you have glRotatef() before the glTranslatef().

 

I should have made that correction above when I changed how color is being handled when I re-posted your code for DrawShip. 

 

//=============================================================================================== You have the following...

void DrawShip(GLfloat position_X, GLfloat position_Y, GLfloat position_Z, GLfloat rotation, GLfloat *color)
{
        glPushMatrix();
        //glTranslatef(-position_X,-position_Y, -position_Z);
        glRotatef(rotation,0.0f,0.0f,1.0f);
        glTranslatef(position_X, position_Y, position_Z);
        glColor3f(color[0], color[1], color[2]);
        glBegin(GL_LINE_LOOP);
                glVertex3f(0.0f,-0.25f,0.0f);
                glVertex3f(-0.25f,-0.5f,0.0f);
                glVertex3f(-0.5f,-0.5f,0.0f);
                glVertex3f(-0.0f,0.5f,0.0f);
                glVertex3f(0.5f,-0.5f,0.0f);
                glVertex3f(0.25f,-0.5f,0.0f);
                glVertex3f(0.0f,-0.25f,0.0f);
        glEnd();
        glPopMatrix();
}

//============================================================= Instead, it should look like this

 

void DrawShip(GLfloat position_X, GLfloat position_Y, GLfloat position_Z, GLfloat rotation, GLfloat *color)
{
glPushMatrix();
        glTranslatef(position_X, position_Y, position_Z);
  glRotatef(rotation,0.0f,0.0f,1.0f);
      glColor3f(color[0], color[1], color[2]);
        glBegin(GL_LINE_LOOP);
                glVertex3f(0.0f,-0.25f,0.0f);
                glVertex3f(-0.25f,-0.5f,0.0f);
                glVertex3f(-0.5f,-0.5f,0.0f);
                glVertex3f(-0.0f,0.5f,0.0f);
                glVertex3f(0.5f,-0.5f,0.0f);
                glVertex3f(0.25f,-0.5f,0.0f);
                glVertex3f(0.0f,-0.25f,0.0f);
        glEnd();
glPopMatrix();
}

#3marcClintDion

Posted 22 July 2013 - 03:08 AM

There is far too much arrogance and out right abuse by site moderators, they are teaching other people to behave this way.  The posts I've made will all be shorty removed and replaced with this notice.  Game development is not the only thing being taught here, bad behavior is being taught as well.


#2marcClintDion

Posted 10 July 2013 - 02:02 AM

That's because you have glRotatef() before the glTranslatef().  

 

I should have made that correction above when I changed how color is being handled when I re-posted your code for DrawShip. 

 

//=============================================================================================== You have the following...

void DrawShip(GLfloat position_X, GLfloat position_Y, GLfloat position_Z, GLfloat rotation, GLfloat *color)
{
        glPushMatrix();
        //glTranslatef(-position_X,-position_Y, -position_Z);
        glRotatef(rotation,0.0f,0.0f,1.0f);
        glTranslatef(position_X, position_Y, position_Z);
        glColor3f(color[0], color[1], color[2]);
        glBegin(GL_LINE_LOOP);
                glVertex3f(0.0f,-0.25f,0.0f);
                glVertex3f(-0.25f,-0.5f,0.0f);
                glVertex3f(-0.5f,-0.5f,0.0f);
                glVertex3f(-0.0f,0.5f,0.0f);
                glVertex3f(0.5f,-0.5f,0.0f);
                glVertex3f(0.25f,-0.5f,0.0f);
                glVertex3f(0.0f,-0.25f,0.0f);
        glEnd();
        glPopMatrix();
}

//============================================================= Instead, it should look like this

 

void DrawShip(GLfloat position_X, GLfloat position_Y, GLfloat position_Z, GLfloat rotation, GLfloat *color)
{
   glPushMatrix();
        glTranslatef(position_X, position_Y, position_Z);
        glRotatef(rotation,0.0f,0.0f,1.0f);
        glColor3f(color[0], color[1], color[2]);
        glBegin(GL_LINE_LOOP);
                glVertex3f(0.0f,-0.25f,0.0f);
                glVertex3f(-0.25f,-0.5f,0.0f);
                glVertex3f(-0.5f,-0.5f,0.0f);
                glVertex3f(-0.0f,0.5f,0.0f);
                glVertex3f(0.5f,-0.5f,0.0f);
                glVertex3f(0.25f,-0.5f,0.0f);
                glVertex3f(0.0f,-0.25f,0.0f);
        glEnd();
   glPopMatrix();
}

#1marcClintDion

Posted 10 July 2013 - 02:01 AM

That's because you have glRotatef() before the glTranslatef().  

 

I should have made that correction above when I re-posted your code for DrawShip.  You have the following...

//===================================================================================

void DrawShip(GLfloat position_X, GLfloat position_Y, GLfloat position_Z, GLfloat rotation, GLfloat *color)
{
        glPushMatrix();
        //glTranslatef(-position_X,-position_Y, -position_Z);
        glRotatef(rotation,0.0f,0.0f,1.0f);
        glTranslatef(position_X, position_Y, position_Z);
        glColor3f(color[0], color[1], color[2]);
        glBegin(GL_LINE_LOOP);
                glVertex3f(0.0f,-0.25f,0.0f);
                glVertex3f(-0.25f,-0.5f,0.0f);
                glVertex3f(-0.5f,-0.5f,0.0f);
                glVertex3f(-0.0f,0.5f,0.0f);
                glVertex3f(0.5f,-0.5f,0.0f);
                glVertex3f(0.25f,-0.5f,0.0f);
                glVertex3f(0.0f,-0.25f,0.0f);
        glEnd();
        glPopMatrix();
}

//=============================================================Instead, it should look like this

 

void DrawShip(GLfloat position_X, GLfloat position_Y, GLfloat position_Z, GLfloat rotation, GLfloat *color)
{
   glPushMatrix();
        glTranslatef(position_X, position_Y, position_Z);
        glRotatef(rotation,0.0f,0.0f,1.0f);
        glColor3f(color[0], color[1], color[2]);
        glBegin(GL_LINE_LOOP);
                glVertex3f(0.0f,-0.25f,0.0f);
                glVertex3f(-0.25f,-0.5f,0.0f);
                glVertex3f(-0.5f,-0.5f,0.0f);
                glVertex3f(-0.0f,0.5f,0.0f);
                glVertex3f(0.5f,-0.5f,0.0f);
                glVertex3f(0.25f,-0.5f,0.0f);
                glVertex3f(0.0f,-0.25f,0.0f);
        glEnd();
   glPopMatrix();
}

PARTNERS