Fixing transparancy issues.

Started by
2 comments, last by Kalidor 18 years, 9 months ago
Somehow, my terrain is being rendered with alpha blending or something on... it's like the terrain is being rendered with full transparency. Here is all the rendering code:
	
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		// Clear Screen And Depth Buffer
	glLoadIdentity();
	glTranslatef(x, y, z);
	glRotatef(rx, 1.0f, 0.0f, 0.0f);
	glRotatef(ry, 0.0f, 1.0f, 0.0f);
	glRotatef(rz, 0.0f, 0.0f, 1.0f);
    
    glDisable(GL_TEXTURE_2D);
    DrawSelector();	
    
    if (mode == FILLED) //Textured mode... why the transparency??!! 
    {
     	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, texture_id);
    }
    else //Wireframe mode
    {
        glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
    }

	RenderHeightmap(height_map); //Draw the heightmap with triangle strips
Can you see any reasons why it would be transparent? Thanks.
my siteGenius is 1% inspiration and 99% perspiration
Advertisement
Post your DrawSelector and RenderHeightmap functions as well.
void RenderHeightmap(const HeightMap * height_map){    for (float y = 0.0f; y < (float)height_map->Height() - 1; ++y)    {        glBegin(GL_TRIANGLE_STRIP);        for ( float x = 0.0f; x < (float)height_map->Width(); ++x)        {                glTexCoord2f(x/height_map->Width(), y/height_map->Height());                glVertex3f(x, y, height_map->GetTileInfo((int)x, (int)y).height);                glTexCoord2f(x/height_map->Width(), (y+1)/height_map->Height());                glVertex3f(x, y + 1.0f, height_map->GetTileInfo((int)x, (int)(y + 1.0f)).height);        }        glEnd();    }}void DrawSelector(){    float select_height = height_map->GetTileInfo(select_x, select_y).height;    float right_bound = (float)height_map->Width() - 1.0f;    float bottom_bound = (float)height_map->Height() - 1.0f;        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);        glBegin(GL_LINES);        glVertex3f(0.0f, 0.0f, height_map->GetTileInfo(0, 0).height);    glVertex3f((float)select_x, (float)select_y, select_height);        glVertex3f(right_bound, 0.0f, height_map->GetTileInfo(height_map->Width() - 1, 0).height);    glVertex3f((float)select_x, (float)select_y, select_height);        glVertex3f(right_bound, bottom_bound, height_map->GetTileInfo(height_map->Width() - 1, height_map->Height() - 1).height);    glVertex3f((float)select_x, (float)select_y, select_height);        glVertex3f(0.0f, bottom_bound, height_map->GetTileInfo(0, height_map->Height() - 1).height);    glVertex3f((float)select_x, (float)select_y, select_height);        glEnd();}


Thanks, and sorry. Um, I already posted about this, but in the RenderHeightmap function, how should I be rendering the texture? I tried by the way another poster showed me, as you can see above, but unfortunately that takes the texture and spreads it over the whole screen, and I'm looking for it to be used once per inner loop iteration. Any advice = rate++, for what it's worth from my not-quite-there rating. Thank you much.
my siteGenius is 1% inspiration and 99% perspiration
Quote:Original post by silverphyre673
...but unfortunately that takes the texture and spreads it over the whole screen, and I'm looking for it to be used once per inner loop iteration...
Don't divide by the width and height. I think that's what you're asking.

As for the transparency, are you sure that blending is disabled? As in, you're not enabling it anywhere else in your program and forgetting to disable it? Or maybe your not enabling depth-testing and some polygons that shouldn't be visible are? Maybe a screenshot would help.

This topic is closed to new replies.

Advertisement