Billboarding woes

Post Reply
cyanprime
Posts: 3
Joined: Sun Jan 01, 2012 12:22 pm

Billboarding woes

Post by cyanprime » Mon Jan 02, 2012 6:14 am

Can anyone tell me why this code isn't working? The quad just doesn't show up at all...

Code: Select all

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);
}

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests