OpenGL - Soil texture all black

Started by
1 comment, last by Shawn619 9 years, 12 months ago

I've never seen anyone on google searches with this problem so i came here.

I linked, included, and did everything necessary to use SOIL and it's functions.

I load the texture like so in init():


void initRendering() {



std::string vertexInputString="exampleVS.txt";

std::string fragmentInputString="exampleFS.txt";



//create new shader

InitializeProgram(shaderOne, readFiletoString(vertexInputString), readFiletoString(fragmentInputString));



//enables/disables

glEnable(GL_DEPTH_TEST);

glEnable(GL_TEXTURE_2D);

glEnable (GL_BLEND);

//glEnable(GL_LIGHTING);

//glEnable(GL_LIGHT0);



//states

glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);



//load textures

image = SOIL_load_OGL_texture(

"resources/wood.png",

SOIL_LOAD_AUTO,

SOIL_CREATE_NEW_ID,

SOIL_FLAG_INVERT_Y

);

if( 0 == image ){printf( "SOIL loading error: '%s'\n", SOIL_last_result());}





//start shader

glUseProgram(shaderOne);

}

For simplicity the wood.png is a 256x256 png texture and loads without an error message.

Here is where i draw the textured quad:


glPushMatrix();

glColor4f(0.0, 0.0, 0.0,1.0f);

glBindTexture(GL_TEXTURE_2D, image);

//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 

//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_DECAL);

//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_DECAL);

//glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); // when texture area is small, bilinear filter the closest mipmap

//glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // when texture area is large, bilinear filter the first mipmap

//glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // texture should tile

//glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

glEnable(GL_TEXTURE_2D);

glBegin(GL_QUADS);



glNormal3f(0.0, 1.0f, 0.0f);



glTexCoord2f(0.0f,0.0f); glVertex3f(-50.0f, 10.0f, 50.0f);

glTexCoord2f(0.0f,1.0f); glVertex3f(-50.0f, 10.0f, -50.0f);

glTexCoord2f(1.0f,1.0f); glVertex3f(50.0f, 10.0f, -50.0f);

glTexCoord2f(1.0f,0.0f); glVertex3f(50.0f, 10.0f, 50.0f);



glEnd();



glPopMatrix();

The result is simply an all black texture instead of a wood texture:

lkSFV.png

atyH0.png

Advertisement

glColor4f(0.0, 0.0, 0.0,1.0f);

If the texture color is being multiplied by this color then that could be the problem. Try using white instead. i.e.


glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

If that doesn't work, we might have to see your shaders.

Solved! I had my shader on when i was rending the textured quad, and since my shader doesnt support textures(yet), the color of my quad was just whatever the most recent glColor was.

This topic is closed to new replies.

Advertisement