Jump to content

  • Log In with Google      Sign In   
  • Create Account

Textures and Color: why don't we get along?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 masonium   Members   -  Reputation: 118

Like
Likes
Like

Posted 09 October 2001 - 01:58 PM

I have two functions, in two separate classes.
  
void BlockDudeEditor::DrawLevel()
{
	glColor3f(1.0f, 1.0f, 1.0f);

	float offset = grid_l / 2.0f;
	float grid_pos_x, grid_pos_y;
	
	// first draw the background

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, background_tex);
	glBegin(GL_QUADS);
		glTexCoord2f(0.0f, 0.0f);
		glVertex3f(-NUM_TILES_X * grid_l * 0.5f, 
			-NUM_TILES_Y * grid_l * 0.5f, -offset); // -offset to have the background behind the cubes

		
		glTexCoord2f(0.0f, 1.0f);
		glVertex3f(-NUM_TILES_X * grid_l * 0.5f, 
			NUM_TILES_Y * grid_l * 1.5f, -offset);
		
		glTexCoord2f(2.0f, 1.0f);
		glVertex3f(NUM_TILES_X * grid_l * 1.5f, 
			NUM_TILES_Y * grid_l * 1.5f, -offset);
		
		glTexCoord2f(2.0f, 0.0f);
		glVertex3f(NUM_TILES_X * grid_l * 1.5f, 
			-NUM_TILES_Y * grid_l * 0.5f, -offset);
	glEnd();

	for (int x = 0; x < NUM_TILES_X; x++)
	{
		for (int y = 0; y < NUM_TILES_Y; y++)
		{
			if (grid[x][y] == 0)
				continue;

			switch (grid[x][y])
			{
			case 1:
				glBindTexture(GL_TEXTURE_2D, brick_tex);
				break;
			case 2:
				glBindTexture(GL_TEXTURE_2D, block_tex);
				break;
			default: break;
			}
			
			if (x == 0)
				if (y == 9)
					glBindTexture(GL_TEXTURE_2D, brick_tex);

			grid_pos_x = (x) * grid_l + offset;
			grid_pos_y = (y) * grid_l + offset;
				
			glPushMatrix();
				glTranslatef(grid_pos_x, grid_pos_y, 0.0f);
				DrawCube(grid_l, 1.0f, false, GL_QUADS);
			glPopMatrix();
		}
	}
}
  
and...
  
void BlockDudeCursor::Draw(BlockDudeEditor bde)
	{
		glDisable(GL_TEXTURE_2D);
		glPushMatrix();
			glColor3f(0.0f, 0.0f, 1.0f);
			glTranslatef((x + 0.5f) * bde.grid_l, (y + 0.5f) * bde.grid_l, 0.0f);
			DrawCube(bde.grid_l, 1.0f, false, GL_QUADS);
		glPopMatrix();
		glEnable(GL_TEXTURE_2D);
	}
  
whenever I call both of these functions, the texture for the the DrawLevel function does not show up. instead, it''s just the color that I declare in BlockDudeCursor::Draw. When I don''t call BlockDudeCursor::Draw, the texture shows up perfectly. What is the problem?

Sponsor:

#2 MENTAL   Members   -  Reputation: 382

Like
Likes
Like

Posted 10 October 2001 - 12:05 AM

here''s a hint:


glDisable(GL_TEXTURE_2D);
glPushMatrix();
glColor3f(0.0f, 0.0f, 1.0f);
glTranslatef((x + 0.5f) * bde.grid_l, (y + 0.5f) * bde.grid_l, 0.0f);
DrawCube(bde.grid_l, 1.0f, false, GL_QUADS);
glPopMatrix();
glEnable(GL_TEXTURE_2D);


ARGH!!!!!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS