Im having some trouble whit the 6 tga faces for my cube, i cant see the image cleary in the face, I just see kind of like the color of the tga but no the image clearly. I load the cube from an obj model, I ve been using different models of cube.obj with diferent texture coords ant still the same result.
Then I realize that the cube is just like takin the negative X and positive Y images, and expanding them all over the cube and not even well just like the color of the tga.
Here is part of my code
U5.Loc = glGetUniformLocation ( U5.programObject, “u_s_texture” );
U5.TexId =Cubemap (“pos_x.tga”,“pos_y.tga”,“pos_z.tga”,“neg_x.tga”,“neg_y.tga”,“neg_z.tga”);
GLuint Cubemap( char PX,charPY, char *PZ,char NX,charNY, char *NZ)
{
GLuint textureId;
int width,
height;
int width2,
height2;
int width3,
height3;
int width4,
height4;
int width5,
height5;
int width6,
height6;
char *BPX = esLoadTGA ( PX, &width, &height );
char *BPY = esLoadTGA ( PY, &width2, &height2 );
char *BPZ = esLoadTGA ( PZ, &width3, &height3 );
char *BNX = esLoadTGA ( NX, &width4, &height4 );
char *BNY = esLoadTGA ( NY, &width5, &height5 );
char *BNZ = esLoadTGA ( NZ, &width6, &height6 );
GLuint texId;
if ( BPX == NULL || BPY == NULL || BPZ == NULL || BNX == NULL ||BNY == NULL || BNZ == NULL )
{
esLogMessage ( "Error loading (%s) image.
", PX );
system(“pause”);
return 0;
}
// Generate a texture object
glGenTextures ( 1, &textureId );
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Bind the texture object
glBindTexture ( GL_TEXTURE_CUBE_MAP, textureId );
// for ( q=0;q<6;q++){
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X,0,GL_RGB,width,height,0,GL_RGB,GL_UNSIGNED_BYTE,BPX);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X,0,GL_RGB,width4,height4,0,GL_RGB,GL_UNSIGNED_BYTE,BNX);//—
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y,0,GL_RGB,width2,height2,0,GL_RGB,GL_UNSIGNED_BYTE,BPY);//**
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,0,GL_RGB,width5,height5,0,GL_RGB,GL_UNSIGNED_BYTE,BNY);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z,0,GL_RGB,width3,height3,0,GL_RGB,GL_UNSIGNED_BYTE,BPZ);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,0,GL_RGB,width6,height6,0,GL_RGB,GL_UNSIGNED_BYTE,BNZ);
//}
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLbyte vShaderStr[] =
"uniform mat4 u_mvpMatrix;
"
"attribute vec4 a_position;
"
"attribute vec4 a_texCoord;
"
"varying vec4 v_pos;
"
"void main()
"
"{
"
" gl_Position = u_mvpMatrix * a_position;
" v_pos = a_texCoord;
"
"}
";
GLbyte fShaderStr[] =
"precision mediump float;
"
"varying vec2 v_texCoord;
"
"uniform sampler2D s_betty;
"
"varying vec4 v_pos;
"
"uniform samplerCube u_s_texture;
"
"void main()
"
"{
"
" gl_FragColor=textureCube(u_s_texture, v_pos.xyz);
"
"}
";