Firstly, like always i want to apologize about my language;]
http://img859.imageshack.us/img859/3476/asdqoe.png
http://img190.imageshack.us/img190/7605/asd2gy.png
http://img252.imageshack.us/img252/517/skinp.jpg
First img shows texture on cube, everything is looking fine
Second img shows texture on apple - obj takes from one of webs with free obj models, like you see texture is looking bad, this texture i take from website with obj, in first img i show this texture on cube
Third img is showing texture from first and second img
Like you see something is wrong in cube texture is looking fine, but in apple from where is this texture i get only one color
i have it in all obj models, which i download
function which is setting texture:
void Objloader::SetTexture()
{
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &texture.m_gl_texture_id);
glBindTexture(GL_TEXTURE_2D, texture.m_gl_texture_id);
glTexImage2D(GL_TEXTURE_2D,
0,
4, //GL_RGBA,
texture.getWidth(),
texture.getHeight(),
0,
GL_RGB,
GL_UNSIGNED_BYTE,
texture.getPixmapPointer());
//glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
//glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
to load img i use devil, but like you see img is showing, so i dont show function, which is loading img
vbo_init:
glGenBuffers(1, &vb);
glBindBuffer(GL_ARRAY_BUFFER, vb);
glBufferData(GL_ARRAY_BUFFER, sizeof(vo_data), vo_data, GL_STREAM_DRAW);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(xyz), BUFFER_OFFSET( offsetof(xyz, x) ));
glTexCoordPointer(2, GL_FLOAT, sizeof(xyz), BUFFER_OFFSET( offsetof(xyz, u) ));
drawing:
glDrawArrays( GL_TRIANGLES, 0, sth );
structure:
struct xyz{
GLfloat x;
GLfloat y;
GLfloat z;
GLfloat u;
GLfloat v;
};
texcoords, are fine, i checked it
ok the problem is with texcoords, because they only work on 1 or 0, when it is for example 0.6743, texture dont work, i don’t know why