Exemple #1
0
void addMaterial(GeometryConverter *cvt, std::ostream &os, const std::string &mtlName,
		const fs::path &texturesDir, const Spectrum &diffuseValue, 
		const std::string &diffuseMap, const std::string maskMap) {
	if (mtlName == "") 
		return;
	SLog(EInfo, "Copying material \"%s\" ..", mtlName.c_str());
	std::string indent = "";

	if (maskMap != "") {
		indent = "\t";
		os << "\t<bsdf id=\"" << mtlName << "\" type=\"mask\">" << endl;
		os << "\t\t<texture name=\"opacity\" type=\"bitmap\">" << endl;
		os << "\t\t\t<string name=\"filename\" value=\"textures/" << copyTexture(cvt, texturesDir, maskMap) << "\"/>" << endl;
		os << "\t\t</texture>" << endl;
		os << "\t\t<bsdf type=\"diffuse\">" << endl;
	} else {
		os << "\t<bsdf id=\"" << mtlName << "\" type=\"diffuse\">" << endl;
	}

	if (diffuseMap == "") {
		Float r, g, b;
		diffuseValue.toLinearRGB(r, g, b);
		os << indent << "\t\t<rgb name=\"reflectance\" value=\"" 
			<< r << " " << g << " " << b << "\"/>" << endl;
	} else {
		os << indent << "\t\t<texture name=\"reflectance\" type=\"bitmap\">" << endl
		   << indent << "\t\t\t<string name=\"filename\" value=\"textures/" << copyTexture(cvt, texturesDir, diffuseMap) << "\"/>" << endl
		   << indent << "\t\t</texture>" << endl;
	}

	os << indent << "\t</bsdf>" << endl << endl;

	if (maskMap != "") 
		os << "\t</bsdf>" << endl;
}
Exemple #2
0
//! constructor
CD3D9Texture::CD3D9Texture(IImage* image, CD3D9Driver* driver,
			   u32 flags, const io::path& name, void* mipmapData)
: ITexture(name), Texture(0), RTTSurface(0), Driver(driver), DepthSurface(0),
	TextureSize(0,0), ImageSize(0,0), Pitch(0), ColorFormat(ECF_UNKNOWN),
	HasMipMaps(false), HardwareMipMaps(false), IsRenderTarget(false)
{
	#ifdef _DEBUG
	setDebugName("CD3D9Texture");
	#endif

	HasMipMaps = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);

	Device=driver->getExposedVideoData().D3D9.D3DDev9;
	if (Device)
		Device->AddRef();

	if (image)
	{
		if (createTexture(flags, image))
		{
			if (copyTexture(image))
			{
				regenerateMipMapLevels(mipmapData);
			}
		}
		else
			os::Printer::log("Could not create DIRECT3D9 Texture.", ELL_WARNING);
	}
}
Exemple #3
0
void MenuTask::render()
{
    drawBackground();

    copyTexture(menu, *menu_with_selection);

    const int selection_y[MENU_ITEM_MAX] = { 14, 36, 63, 88, 112, 136 };

    drawTexture(selection, *menu_with_selection, 0, 0, selection.width, selection.height, 23, selection_y[menu_selected_item], selection.width, selection.height);

    drawTexture(*menu_with_selection, *screen, 0, 0, menu_width_visible, menu_with_selection->height, SCREEN_WIDTH - menu_width_visible, 0, menu_width_visible, menu_with_selection->height);
}
Exemple #4
0
//! constructor
CD3D9Texture::CD3D9Texture(IImage* image, CD3D9Driver* driver,
					   u32 flags, const char* name)
: ITexture(name), Image(image), Texture(0), RTTSurface(0), Driver(driver),
TextureSize(0,0), ImageSize(0,0), Pitch(0),
HasMipMaps(false), HardwareMipMaps(false), IsRenderTarget(false)
{
	#ifdef _DEBUG
	setDebugName("CD3D9Texture");
	#endif

	const bool generateMipLevels = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);

	Device=driver->getExposedVideoData().D3D9.D3DDev9;
	if (Device)
		Device->AddRef();

	if (Image)
	{
		Image->grab();

		if (createTexture(flags))
		{
			if (copyTexture() && generateMipLevels)
			{
				// create mip maps.
				#ifdef _IRR_USE_D3DXFilterTexture_
					// The D3DXFilterTexture function seems to get linked wrong when
					// compiling with both D3D8 and 9, causing it not to work in the D3D9 device.
					// So mipmapgeneration is replaced with my own bad generation
					HRESULT hr  = D3DXFilterTexture(Texture, NULL, D3DX_DEFAULT, D3DX_DEFAULT);
					if (FAILED(hr))
						os::Printer::log("Could not create direct3d mip map levels.", ELL_WARNING);
					else
						HasMipMaps = true;
				#else
					createMipMaps();
					HasMipMaps = true;
				#endif
			}
		}
		else
			os::Printer::log("Could not create DIRECT3D9 Texture.", ELL_WARNING);
	}
}
Exemple #5
0
void Task::drawBackground()
{
    copyTexture(*background, *screen);
}
Exemple #6
0
void Task::saveBackground()
{
    copyTexture(*screen, *background);

    background_saved = true;
}