コード例 #1
0
void RenderState::bindFramebuffer(const Framebuffer::Pointer& fbo, bool force)
{
#if !defined(ET_CONSOLE_APPLICATION)
	if (fbo.valid())
	{
		bindFramebuffer(static_cast<uint32_t>(fbo->apiHandle()), GL_FRAMEBUFFER, force);
		
		setViewportSize(fbo->size(), force);
		
		if (fbo->hasRenderTargets())
			setDrawBuffersCount(fbo->drawBuffersCount());
	}
	else 
	{
		bindFramebuffer(0, GL_FRAMEBUFFER, force);
		setViewportSize(_currentState.mainViewportSize, force);
	}
#endif
}
コード例 #2
0
ファイル: framebuffer.cpp プロジェクト: Loki7979/et-engine
void Framebuffer::resolveMultisampledTo(Framebuffer::Pointer framebuffer, bool resolveColor, bool resolveDepth)
{
	vec2i sourceSize = _description.size.xy();
	vec2i targetSize = framebuffer->size();
	
	_rc->renderState().bindReadFramebuffer(static_cast<uint32_t>(apiHandle()));
	
#if (ET_DEBUG)
	GLint sourceSamples = 0;
	glGetIntegerv(GL_SAMPLES, &sourceSamples);
	checkOpenGLError("glGetIntegerv(GL_SAMPLES, ...)");
	
	GLint sourceSampleBuffers = 0;
	glGetIntegerv(GL_SAMPLE_BUFFERS, &sourceSampleBuffers);
	checkOpenGLError("glGetIntegerv(GL_SAMPLE_BUFFERS, ...)");
#endif
	
	_rc->renderState().bindDrawFramebuffer(static_cast<uint32_t>(framebuffer->apiHandle()));
	
#if (ET_DEBUG)
	GLint targetSamples = 0;
	glGetIntegerv(GL_SAMPLES, &targetSamples);
	checkOpenGLError("glGetIntegerv(GL_SAMPLES, ...)");
	
	GLint targetSampleBuffers = 0;
	glGetIntegerv(GL_SAMPLE_BUFFERS, &targetSampleBuffers);
	checkOpenGLError("glGetIntegerv(GL_SAMPLE_BUFFERS, ...)");
	
	if ((targetSamples != 0) && (targetSamples != sourceSamples))
	{
		log::info("glBlitFramebuffer will likely fail:\n"
			"GL_SAMPLES of target (%d) and source (%d) framebuffers are different", targetSamples, sourceSamples);
	}
	
	if (((sourceSampleBuffers > 0) || (targetSampleBuffers > 0)) && (sourceSize != targetSize))
	{
		log::info("glBlitFramebuffer will likely fail:\n"
			"GL_SAMPLE_BUFFERS of target (%d) and source (%d) framebuffers are greater than zero\n"
			"and dimensions are not identical (%dx%d and %dx%d", targetSampleBuffers, sourceSampleBuffers,
			targetSize.x, targetSize.y, sourceSize.x, sourceSize.y);
	}
#endif
	
#	if (ET_OPENGLES)
	if (OpenGLCapabilities::instance().version() < OpenGLVersion::Version_3x)
	{
		glResolveMultisampleFramebufferAPPLE();
		checkOpenGLError("glResolveMultisampleFramebuffer");
	}
#	endif
	
	if (resolveColor)
	{
		glBlitFramebuffer(0, 0, sourceSize.x, sourceSize.y, 0, 0, targetSize.x, targetSize.y,
			GL_COLOR_BUFFER_BIT, (sourceSize == targetSize) ? GL_NEAREST : GL_LINEAR);
		checkOpenGLError("glBlitFramebuffer");
	}

	if (resolveDepth)
	{
		glBlitFramebuffer(0, 0, sourceSize.x, sourceSize.y, 0, 0, targetSize.x, targetSize.y,
			GL_DEPTH_BUFFER_BIT, GL_NEAREST);
		checkOpenGLError("glBlitFramebuffer");
	}
}