Hello,
I’ve been trying to get mipmapping working but I’m really confused as to why my approach doesn’t work. Here’s what I’ve got.
texture related init:
// generate the texture
CreateGLTexture("panelbrn01scr.tga", wallPieceTexture_);
glBindTexture(GL_TEXTURE_2D, wallPieceTexture_);
// set up the texture function
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// set up the texture filtering
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// generate the mipmap data for the texture
glGenerateMipmap(GL_TEXTURE_2D);
the render call:
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, wallPieceTexture_);
glBindVertexArray(wallPieceArray_);
glPushMatrix();
for(int i = 0; i < 10; i++) {
glPushMatrix();
for(int j = 0; j < 10; j++) {
glDrawArrays(GL_TRIANGLES, 0, M_WALL_PIECE_VERTICES);
glTranslatef(1.0f, 0.0f, 0.0f);
}
glPopMatrix();
glTranslatef(0.0f, 1.0f, 0.0f);
}
glPopMatrix();
glDisable(GL_TEXTURE_2D);
CreateGLTexture() by Matthew Brett:
bool CreateGLTexture(char *name, GLuint & TexID )
{
LoadTGA(name);
// Typical Texture Generation Using Data From The TGA ( CHANGE )
glGenTextures(1, &TexID); // Create The Texture ( CHANGE )
glBindTexture(GL_TEXTURE_2D, TexID);
glTexImage2D(GL_TEXTURE_2D, 0, texture_bpp / 8, texture_width, texture_height, 0, texture_type, GL_UNSIGNED_BYTE, texture_imageData);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
if (texture_imageData) // If Texture Image Exists ( CHANGE )
{
free(texture_imageData); // Free The Texture Image Memory ( CHANGE )
}
return false;
}
I would post the rendered image but due to being too new of a member the forum has restricted me in doing so. However, I’m sure all of you know what artifacts I get due to no mipmapping so shouldn’t be a problem.
I’m not sure as to where I’m going wrong here. Any help would be greatly appreciated!
Thanks in advance!