View unanswered posts | View active topics It is currently Sat Nov 01, 2014 11:46 am



Reply to topic  [ 1 post ] 
 Billboarding woes 
Author Message

Joined: Sun Jan 01, 2012 12:22 pm
Posts: 3
Can anyone tell me why this code isn't working? The quad just doesn't show up at all...

Code:
void drawBillboardedSprite(){
   glPushMatrix();
      int modelview[16];
      int position[16];
      int projection[16];
      
      glGetInt(GL_GET_MATRIX_POSITION, position);
      glGetInt(GL_GET_MATRIX_PROJECTION, projection);


      for (int x = 0; x < 4; x++) { // row number of output
         for (int y = 0; y < 4; y++) { // column number of output
            modelview[4*x+y] = 0;
            for (int z = 0; z < 4; z++) { // four elements are added for this output
               modelview[4*x+y] += position[4*x+z] * projection[4*z+y];
            }
         }
      }
      
      for(int i=0; i<3; i+=2 ) {
         for(int j=0; j<3; j++ ) {
            if ( i==j ) modelview[i*4+j] = 1.0f;
            else modelview[i*4+j] = 0.0f;
         }
      }
      
      m4x4 temp = m4x4();
      
      for(int i = 0; i < 16; i++){ temp.m[i] = modelview[i]; }
      
      glLoadIdentity();
      glLoadMatrix4x4(&temp);
         
      glBindTexture(GL_TEXTURE_2D, texture[0]);
      glTexParameter(0, GL_TEXTURE_COLOR0_TRANSPARENT);
   
      glBegin(GL_QUADS);
         // Front Face
         glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, -floorDepth,  0);
         glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, -floorDepth,  0);
         glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -(floorDepth - enemyHeight), 0);
         glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -(floorDepth - enemyHeight),  0);
      glEnd();   
      
      
   glPopMatrix(1);
}


Mon Jan 02, 2012 6:14 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
  Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.
Get devkitPro at SourceForge.net. Fast, secure and Free Open Source software downloads