All pastes #569236 Raw Edit

Someone

public text v1 · immutable
·published 2007-06-16 02:04 UTC
rendered paste body
...
extern GLuint texture[20];
...
bool LoadTexture(unsigned int num, char *Filename)
{
	bool status = false;
	Image* image = NULL;
	image = loadImage(Filename);
	if(image == NULL || !image->data)
	{
		std::cout << "Error Opening Image " << Filename << std::endl;
		return false;
	}
	else
	{
		std::cout << Filename << ": ";
		std::cout << image->textureWidth << " x " << image->textureHeight << " - ";
		std::cout << image->data[0] << std::endl;
	}
	status = true;
	glBindTexture(GL_TEXTURE_2D, num);
	memset(image->data, 0x80, image->textureWidth*image->textureHeight);
	glTexImage2D(GL_TEXTURE_2D, 0, 4, image->textureWidth, image->textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->data);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	//gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image->imageWidth, image->imageHeight, GL_RGB, GL_UNSIGNED_BYTE, image->data);
	
	if(image != NULL)
	{
		if(image->data)
			free(image->data);
		free(image);
	}
	return status;
}

bool LoadTextures()
{
	glGenTextures(20, &texture[0]);
	std::cout << "GenError: " << errno << std::endl;
	for(int i = 0; i < NUMTEX; i++)
	{
		std::cout << i << ":" << texture[i] << std::endl;
		LoadTexture(texture[i], texname[i]);
	}
	return true;
}