Advertisement

glu Crashing :(

Started by May 02, 2001 04:22 AM
5 comments, last by Derilect101 23 years, 6 months ago
  
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!
here''s my stab in the dark...

* is width & height powers of 2?
* is it crashing - as in exception, or just not working? If some program fault, try checking all the pointers. I think you''ve got y wrong somehow, or perhaps width & height mean the tile sizes in which case I think your build2dmipmaps is wrong.

that''s for starters - have a look into it and get back to the forum with more info if still stumped.

HTH!

~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
~~~Cheers!Brett PorterPortaLib3D : A portable 3D game/demo libary for OpenGLCommunity Service Announcement: Read How to ask questions the smart way before posting!
Advertisement
my width and height are powers of 2 heres my call
Scan_Targa(&texture[3],&tile,0,0,64,64);
trying to scan in a 128x128 with 4 64 x 64 images on it if that helps and it does crash says it occured in glu32.dll and when I take out buildmipmaps it doesnt crash its like its not copying the buffer to the tile buffer any ideas
try glTexImage2D(..) instaed of buildmipmaps, does it also crash.
also i notice you havent set the unpack alignment to 1. also you havent set the texture WRAP modes eg GL_CLAMP, GL_REPEAT

http://members.xoom.com/myBollux
Still crashes with the glTexImage2D thing and why would I have to set the image parameter to wrap or repeat if I''m using it as a plain tile in ortho mode. I also appreciate all your help I''ll be so happy *if* I ever get this function working
>>why would I have to set the image parameter to wrap or repeat if I''m using it as a plain tile in ortho mode<<

cause it won''t draw anything otherwise

http://members.xoom.com/myBollux
Advertisement
Tried that still crashed this function pisses me off LOL

This topic is closed to new replies.

Advertisement