コード例 #1
0
ファイル: framebuffer.cpp プロジェクト: Loki7979/et-engine
void Framebuffer::attachTexture(Texture::Pointer rt, uint32_t target)
{
	if (rt.invalid() || (rt->size() != _description.size.xy())) return;
	ET_ASSERT(glIsTexture(static_cast<uint32_t>(rt->apiHandle())));

	_rc->renderState().bindFramebuffer(static_cast<uint32_t>(apiHandle()));

	if ((rt->target() == TextureTarget::Texture_2D) || (rt->target() == TextureTarget::Texture_Rectangle))
	{
		glFramebufferTexture2D(GL_FRAMEBUFFER, target, textureTargetValue(rt->target()), 
			static_cast<uint32_t>(rt->apiHandle()), 0);

		checkOpenGLError("glFramebufferTexture2D(...) - %s", name().c_str());
	}
	else if (rt->target() == TextureTarget::Texture_Cube)
	{
		for (GLenum i = 0; i < 6; ++i)
		{
			glFramebufferTexture2D(GL_FRAMEBUFFER, target, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 
				static_cast<uint32_t>(rt->apiHandle()), 0);

			checkOpenGLError("glFramebufferTexture2D(...) - %s", name().c_str());
		}
	}
#if (!ET_OPENGLES)
	else if (rt->target() == TextureTarget::Texture_2D_Array)
	{
		glFramebufferTexture(GL_FRAMEBUFFER, target, static_cast<GLuint>(rt->apiHandle()), 0);
		checkOpenGLError("glFramebufferTexture(...) - %s", name().c_str());
	}
#endif
}
コード例 #2
0
void RenderState::bindTexture(uint32_t unit, const Texture::Pointer& texture, bool force)
{
#if !defined(ET_CONSOLE_APPLICATION)
	if (texture.valid())
		bindTexture(unit, static_cast<uint32_t>(texture->apiHandle()), texture->target(), force);
	else
		bindTexture(unit, 0, TextureTarget::Texture_2D, force);
#endif
}