Esempio n. 1
0
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
}
Esempio n. 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
}
Esempio n. 3
0
void Renderer::renderFullscreenTexture(const Texture::Pointer& texture, const vec4& tint)
{
#if !defined(ET_CONSOLE_APPLICATION)
	auto prog = _fullscreenProgram[static_cast<int>(texture->target())];

	_rc->renderState().bindTexture(_defaultTextureBindingUnit, texture);
	_rc->renderState().bindProgram(prog);
	prog->setUniform("color_texture_size", texture->sizeFloat());
	prog->setUniform("tint", tint);
	fullscreenPass();
#endif
}