GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
int depth;
if(T.GetBPP() == 24)
{
depth = GL_RGB;
}
else
{
depth = GL_RGBA;
}
glTexImage2D(GL_TEXTURE_2D, 0, depth, T.GetWidth(), T.GetHeight(), 0, depth, GL_UNSIGNED_BYTE, T.GetData());
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
int depth;
if(T.GetBPP() == 24)
{
depth = GL_RGB;
}
else
{
depth = GL_RGBA;
}
glTexImage2D(GL_TEXTURE_2D, 0, depth, T.GetWidth(), T.GetHeight(), 0, depth, GL_UNSIGNED_BYTE, T.GetData());
To copy to clipboard, switch view to plain text mode
As I'm just trying to make the thing "work" for now, I've simplified it - it's not really very usable beyond one texture.
...
const Triangle * T = &TT->GetOList()[i]->GetConst();
assert(T);
if(T->GetTextureNumber() != 0xFFFFFFFF)
{
glBindTexture(GL_TEXTURE_2D, T->GetTextureNumber());
}
glBegin(GL_TRIANGLES);
for(char j = 0; j < 3; j++)
{
if(renderMode == GL_RENDER)
{
//glColor3ubv(!j?Yellow:j==1?Red:Green);
if(T->GetTextureNumber() != 0xFFFFFFFF)
{
glTexCoord2fv((*T).GetTexture(j)->GetConst().GetFloatStyle());
}
}
glNormal3fv((*T)[j].GetNormal().GetFloatStyle());
glVertex4fv((*T)[j].GetConst().GetFloatStyle());
}
glEnd();
...
...
const Triangle * T = &TT->GetOList()[i]->GetConst();
assert(T);
if(T->GetTextureNumber() != 0xFFFFFFFF)
{
glBindTexture(GL_TEXTURE_2D, T->GetTextureNumber());
}
glBegin(GL_TRIANGLES);
for(char j = 0; j < 3; j++)
{
if(renderMode == GL_RENDER)
{
//glColor3ubv(!j?Yellow:j==1?Red:Green);
if(T->GetTextureNumber() != 0xFFFFFFFF)
{
glTexCoord2fv((*T).GetTexture(j)->GetConst().GetFloatStyle());
}
}
glNormal3fv((*T)[j].GetNormal().GetFloatStyle());
glVertex4fv((*T)[j].GetConst().GetFloatStyle());
}
glEnd();
...
To copy to clipboard, switch view to plain text mode
I tried to display just the interesting portion of the draw code... basically, for each triangle, I do textures, then normals, then the vertex. I bind the texture before the glBegin() function.
Bookmarks