All pastes #443138 Raw Edit

Someone

public text v1 · immutable
·published 2007-04-16 17:28 UTC
rendered paste body
Texture::Texture(char* filename, int type)
{
	//Lagra filnamnet
	strcpy(this->filename, filename);

	//Set active texunit
	//glActiveTexture(GL_TEXTURE0);

	ILuint ImgId;
	ilInit();

	// Generate the main image name to use.
	ilGenImages(1, &ImgId);
	// Bind this image name.
	ilBindImage(ImgId);
	
	// Loads the image specified by File into the ImgId image.
	
	if(type == TEXTURE_2D){
		ilLoadImage(filename);
		printf("ilLoad: %25s\n", filename);
		gltype = GL_TEXTURE_2D;
		if( ilGetInteger(IL_IMAGE_HEIGHT) == 1 || ilGetInteger(IL_IMAGE_WIDTH) == 1 )
			gltype = GL_TEXTURE_1D;

		//Create and bind texture object
		glGenTextures(1,&TexID);
		glBindTexture(gltype, TexID);
				
		if( gltype == GL_TEXTURE_2D )
			gluBuild2DMipmaps(GL_TEXTURE_2D, ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL), ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT), ilGetInteger(IL_IMAGE_FORMAT), ilGetInteger(IL_IMAGE_TYPE), ilGetData());
		else if( gltype == GL_TEXTURE_1D )
			gluBuild1DMipmaps(GL_TEXTURE_1D, ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL), ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_FORMAT), ilGetInteger(IL_IMAGE_TYPE), ilGetData());
	
//		 We're done with our image, so we go ahead and delete it.
	ilDeleteImages(1, &ImgId);
	}