int Scan_Targa(TextureImage *picture, Tile *tile, int x, int y, int width, int height)
{
UCHAR *buffer;
int bytes_per_line;
GLuint type = GL_RGBA;
int bpp = picture->bpp/8;
tile->buffer = (GLubyte *)malloc(height*width*bpp);
x = x * (width + 1) + 1;
y = y * (height + 1) + 1;
bytes_per_line = width * bpp;
buffer = picture->buffer + y * bytes_per_line + x;
for (int index = 0; index < height; index++)
{
memcpy(tile->buffer, buffer, bytes_per_line );
tile->buffer += bytes_per_line;
buffer += picture->width * bpp;
}
glGenTextures(1, &tile->id);
glBindTexture(GL_TEXTURE_2D, tile->id);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
if(picture->bpp == 24)
type = GL_RGB;
gluBuild2DMipmaps(GL_TEXTURE_2D, type, width, height, type, GL_UNSIGNED_BYTE, tile->buffer);
return 1;
}
The gluBuild2DMipmaps crashes the program I''m getting very mad at trying to scan in templated .tga files for sprites I''ve done this in DDraw before and no probs. Please help!
glu Crashing :(
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement