void CDX9Renderer::CopyMultisampleSurfaceToTexture(TextureHandle ms, TextureHandle th, const RECT& area)
	{
		CRASSERT(TextureExists(ms) && TextureExists(th));

		// Check the multisample surface was created with multisampled = true in CreateRenderTargetTexture
		// and that the th parameter wasn't!
		CRASSERT(ms->surface_ptr != NULL && th->texture_ptr != NULL);

		batch.push_back(new (this) CBatch_CopySurfaceToTexture(this, ms, th, area));
	}
Esempio n. 2
0
AtlasedTexture& CTextureAtlas::GetTextureWithBackup(const std::string& name, const std::string& backupName)
{
	if (TextureExists(name))
		return textures[StringToLower(name)];

	if (TextureExists(backupName))
		return textures[StringToLower(backupName)];

	return dummy;
}
Esempio n. 3
0
AtlasedTexture& CTextureAtlas::GetTexture(const std::string& name)
{
	if (TextureExists(name))
		return textures[StringToLower(name)];

	return dummy;
}
sf::Texture& TextureManager::GetTexture(const std::string& name){
	if (TextureExists((name))){
		return textureMap[(name)];
	}
	else{
		throw std::runtime_error("TextureManager: Texture does not exists!");
	}
}
Esempio n. 5
0
GLuint GLReadTexture(const char* pFilename) {
	if (pFilename[0] == 0) return 0xFFFFFFFF;
	TextureAsset* pAss;
	if (TextureExists(pFilename)) {
		pAss = gTextures[pFilename];
	} else {
		char pPath[1024];
		sprintf(pPath, "meshes/textures/%s", pFilename);
		AddAsset(pFilename, LoadImageG(pPath));
		pAss = gTextures[pFilename];
		if (pAss->im != NULL) {
			MakeGLTexture(pAss);
		} else {
			printf("**** Tex %s read failed\n", pFilename);
		}
	}
	return pAss->glTextureID;
}
	// Set texture
	void CDX9Renderer::SetTexture(TextureHandle th)
	{
		// Already the current texture, discard
		if (th == current_texture)
			return;

		// Add a command
		if (th != NULL) {
			CRASSERT(TextureExists(th));

			// Multisampled rendertargets are really surfaces.  You can't call SetTexture for them.
			if (th->is_multisampled)
				throw error(_T("Cannot set a multisampled rendertarget as texture"), E_FAIL);
		}

		current_texture = th;

		batch.push_back(new (this) CBatch_SetTexture(this, th));
	}
	// Set rendertarget
	void CDX9Renderer::SetRenderTarget(TextureHandle th)
	{
		// If backbuffer was changed a render target of NULL means something different
		if (back_buffer_was_changed)
			back_buffer_was_changed = false;
		// Check not the same render target (if backbuffer was not changed)
		else if (th == current_rendertarget)
			return;

		current_rendertarget = th;

		uint new_rt_width, new_rt_height;

		if (th != NULL) {
			CRASSERT(TextureExists(th));

			if (!th->rendertarget)
				throw error(_T("Texture not a render target"), E_FAIL);

			new_rt_width = th->image_width;
			new_rt_height = th->image_height;
		}
		else {
			new_rt_width = backbuffer_width;
			new_rt_height = backbuffer_height;
		}

		bool update_3d_math = false;

		// If rendertarget has changed dimensions we need new 3D math
		if (new_rt_width != state.last_rendertarget_width || new_rt_height != state.last_rendertarget_height) {
			update_3d_math = true;
			state.last_rendertarget_width = new_rt_width;
			state.last_rendertarget_height = new_rt_height;
		}

		// Add command
		batch.push_back(new (this) CBatch_SetRenderTarget(this, th, update_3d_math));
	}