Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualBrother Bob

Posted 22 July 2013 - 12:01 PM

I've made a change to how the colors are initialized and passed into DrawShip(), the changes allow the color to vary from ship to ship by using an array for the colors.

It's also a cleaner to pass the other variables to DrawShip() in this manner but not required.

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

 

GLfloat ship_01_COLOR[] = {1.0f, 0.0f, 0.0f};
GLfloat ship_02_COLOR[] = {0.0f, 1.0f, 0.0f};
 
//-----------------------------------------------------------------------------------------------------------------------------------------------
 
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();
}

 

//-----------------------------------------------------------------------------------------------------------------------------------------------

 

void Render()

{

 

        //=============================================================================================================
        glPushMatrix();
                DrawShip(ship_01_POSITION_X,ship_01_POSITION_Y,ship_01_POSITION_Z,ship_01_ROTATION, ship_01_COLOR);
        glPopMatrix();
        //=============================================================================================================
        glPushMatrix();
                DrawShip(ship_02_POSITION_X,ship_02_POSITION_Y,ship_02_POSITION_Z,ship_02_ROTATION, ship_02_COLOR);
        glPopMatrix();
        //=============================================================================================================

 

 

}


#2marcClintDion

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.


#1marcClintDion

Posted 07 July 2013 - 11:58 PM

I've made a change to how the colors are initialized and passed into DrawShip(), the changes allow the color to vary from ship to ship by using an array for the colors.

It's also a cleaner to pass the other variables to DrawShip() in this manner but not required.

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

 

GLfloat ship_01_COLOR[] = {1.0f, 0.0f, 0.0f};
GLfloat ship_02_COLOR[] = {0.0f, 1.0f, 0.0f};
 
//-----------------------------------------------------------------------------------------------------------------------------------------------
 
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();
}

 

//-----------------------------------------------------------------------------------------------------------------------------------------------

 

void Render()

{

 

        //=============================================================================================================
        glPushMatrix();
                DrawShip(ship_01_POSITION_X,ship_01_POSITION_Y,ship_01_POSITION_Z,ship_01_ROTATION, ship_01_COLOR);
        glPopMatrix();
        //=============================================================================================================
        glPushMatrix();
                DrawShip(ship_02_POSITION_X,ship_02_POSITION_Y,ship_02_POSITION_Z,ship_02_ROTATION, ship_02_COLOR);
        glPopMatrix();
        //=============================================================================================================

 

 

}


PARTNERS