Exemple #1
0
TextureID Renderer::addTexture3D(Image3D *img, unsigned int flags){
	if (!(flags & TEX_NOMIPMAPPING)) img->createMipMaps();

	Texture texture;
	texture.textureKind = TEXKIND_3D;
	texture.isRenderTarget = false;
	texture.rtLockScreenSize = false;
	texture.noLinearFilter = ((flags & TEX_NOLINEARFILTER) != 0);
	texture.clampS = ((flags & TEX_CLAMP_S) != 0);
	texture.clampT = ((flags & TEX_CLAMP_T) != 0);
	texture.clampR = ((flags & TEX_CLAMP_R) != 0);
	texture.levelOfAnisotropy = 1;
	texture.width  = img->getWidth();
	texture.height = img->getHeight();
	texture.depth  = img->getDepth();
	texture.format = img->getFormat();
	texture.mipmapped = (img->getNumberOfMipMaps() > 1);

	texture.image3D = img;

	if (createTexture(texture)){
		return insertTexture(texture);
	} else {
		delete img;
		return TEXTURE_NONE;
	}
}
Exemple #2
0
TextureID Renderer::addTexture(Image *img, unsigned int flags){
	Texture texture;

	texture.clampS = ((flags & TEX_CLAMP_S) != 0);
	texture.clampT = ((flags & TEX_CLAMP_T) != 0);
	texture.noLinearFilter = ((flags & TEX_NOLINEARFILTER) != 0);
	
	if (flags & TEX_NORMALMAP){
		if (img->getFormat() != FORMAT_I8) img->toGrayScale(byteOrderRGBA, false);
		img->toNormalMap(byteOrderRGBA, (flags & TEX_HEIGHTMAP) != 0);
		img->createMipMaps();

		//if ((flags & TEX_NOMIPMAPPING) == 0) img->createMipMaps();
		//img->toNormalMapAdvanced(1.0f, 2.0f, byteOrderRGBA);
	}

	texture.textureKind = (flags & TEX_1D)? TEXKIND_1D : TEXKIND_2D;
	texture.isRenderTarget = false;
	texture.rtLockScreenSize = false;
	texture.levelOfAnisotropy = (flags & TEX_NOANISO)? 1 : maxAnisotropic;
	texture.width  = img->getWidth();
	texture.height = img->getHeight();
	texture.depth  = 1;
	texture.format = img->getFormat();
	texture.mipmapped = (img->getNumberOfMipMaps() > 1);

	texture.images[0] = img;

	if (createTexture(texture)){
		return insertTexture(texture);
	} else {
		delete img;
		return TEXTURE_NONE;
	}
}
Texture2D* TextureManager::loadTextureFromFile(const GString& key, const GString& file_name)
{
	Texture2D* tex = Texture2D::create(file_name);
	tex->setName(key);
	insertTexture(key, tex);
	return tex;
}
Exemple #4
0
TextureID Renderer::addRenderDepth(const int width, const int height, const FORMAT format, bool lockToScreenSize){
	Texture texture;

	texture.textureKind = TEXKIND_2D;
	texture.isRenderTarget = true;
	texture.rtLockScreenSize = lockToScreenSize;
	texture.noLinearFilter = false;//((flags & TEX_NOLINEARFILTER) != 0);
	texture.clampS = true;
	texture.clampT = true;
	texture.levelOfAnisotropy = 1;
	texture.width  = width;
	texture.height = height;
	texture.depth  = 1;
	texture.format = format;
	texture.mipmapped = false;
	
	if (createRenderTarget(texture)){
		return insertTexture(texture);
	} else {
		return TEXTURE_NONE;
	}
}
Exemple #5
0
TextureID Renderer::addRenderCubemap(const int size, const FORMAT format, bool mipmapped){
	Texture texture;

	texture.textureKind = TEXKIND_CUBEMAP;
	texture.isRenderTarget = true;
	texture.rtLockScreenSize = false;
	texture.noLinearFilter = false;//((flags & TEX_NOLINEARFILTER) != 0);
	texture.clampS = true;
	texture.clampT = true;
	texture.levelOfAnisotropy = 1;
	texture.width  = size;
	texture.height = size;
	texture.depth  = 1;
	texture.format = format;
	texture.mipmapped = mipmapped;
	
	if (createRenderTarget(texture)){
		return insertTexture(texture);
	} else {
		return TEXTURE_NONE;
	}
}
Exemple #6
0
TextureID Renderer::addCubemap(Image *imgs[6]){
	Texture texture;

	texture.textureKind = TEXKIND_CUBEMAP;
	texture.isRenderTarget = false;
	texture.rtLockScreenSize = false;
	texture.noLinearFilter = false;
	texture.levelOfAnisotropy = 1;
	texture.width  = imgs[0]->getWidth();
	texture.height = imgs[0]->getHeight();
	texture.depth  = 1;
	texture.format = imgs[0]->getFormat();
	texture.mipmapped = (imgs[0]->getNumberOfMipMaps() > 1);

	memcpy(texture.images, imgs, 6 * sizeof(Image *));

	if (createTexture(texture)){
		return insertTexture(texture);
	} else {
		return TEXTURE_NONE;
	}
}
void DriverTextures::addTexture(const DriverTexture* tex)
{
    insertTexture(numTextures,tex);
};