Fix Gamma in Oculus display plugin

This commit is contained in:
Brad Davis 2016-08-08 17:34:15 -07:00
parent 719e555381
commit e352883a88

View file

@ -109,34 +109,28 @@ void OculusDisplayPlugin::hmdPresent() {
PROFILE_RANGE_EX(__FUNCTION__, 0xff00ff00, (uint64_t)_currentFrame->frameIndex) PROFILE_RANGE_EX(__FUNCTION__, 0xff00ff00, (uint64_t)_currentFrame->frameIndex)
int curIndex;
ovr_GetTextureSwapChainCurrentIndex(_session, _textureSwapChain, &curIndex);
GLuint curTexId;
ovr_GetTextureSwapChainBufferGL(_session, _textureSwapChain, curIndex, &curTexId);
// Manually bind the texture to the FBO // Manually bind the texture to the FBO
// FIXME we should have a way of wrapping raw GL ids in GPU objects without
// taking ownership of the object
auto fbo = getGLBackend()->getFramebufferID(_outputFramebuffer); auto fbo = getGLBackend()->getFramebufferID(_outputFramebuffer);
{ glNamedFramebufferTexture(fbo, GL_COLOR_ATTACHMENT0, curTexId, 0);
int curIndex; render([&](gpu::Batch& batch) {
ovr_GetTextureSwapChainCurrentIndex(_session, _textureSwapChain, &curIndex);
GLuint curTexId;
ovr_GetTextureSwapChainBufferGL(_session, _textureSwapChain, curIndex, &curTexId);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, curTexId, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
}
{
gpu::Batch batch;
batch.enableStereo(false); batch.enableStereo(false);
auto source = _compositeFramebuffer; batch.setFramebuffer(_outputFramebuffer);
auto sourceRect = ivec4(ivec2(0), source->getSize()); batch.setViewportTransform(ivec4(uvec2(), _outputFramebuffer->getSize()));
auto dest = _outputFramebuffer; batch.setStateScissorRect(ivec4(uvec2(), _outputFramebuffer->getSize()));
auto destRect = ivec4(ivec2(0), dest->getSize()); batch.clearViewTransform();
batch.blit(source, sourceRect, dest, destRect); batch.setProjectionTransform(mat4());
_backend->render(batch); batch.setPipeline(_presentPipeline);
} batch.setResourceTexture(0, _compositeFramebuffer->getRenderBuffer(0));
batch.draw(gpu::TRIANGLE_STRIP, 4);
{ });
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); glNamedFramebufferTexture(fbo, GL_COLOR_ATTACHMENT0, 0, 0);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
}
{ {
auto result = ovr_CommitTextureSwapChain(_session, _textureSwapChain); auto result = ovr_CommitTextureSwapChain(_session, _textureSwapChain);