From 8a4938f82b05b86c8f0ed010210eb6d1847c04c9 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 28 Feb 2016 18:15:00 +0100 Subject: OPENGL: Move pipeline code to pipelines/. --- backends/graphics/opengl/pipelines/pipeline.cpp | 47 +++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 backends/graphics/opengl/pipelines/pipeline.cpp (limited to 'backends/graphics/opengl/pipelines/pipeline.cpp') diff --git a/backends/graphics/opengl/pipelines/pipeline.cpp b/backends/graphics/opengl/pipelines/pipeline.cpp new file mode 100644 index 0000000000..64121d512a --- /dev/null +++ b/backends/graphics/opengl/pipelines/pipeline.cpp @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "backends/graphics/opengl/pipelines/pipeline.h" +#include "backends/graphics/opengl/framebuffer.h" + +namespace OpenGL { + +Pipeline::Pipeline() + : _activeFramebuffer(nullptr) { +} + +Framebuffer *Pipeline::setFramebuffer(Framebuffer *framebuffer) { + Framebuffer *oldFramebuffer = _activeFramebuffer; + if (oldFramebuffer) { + oldFramebuffer->deactivate(); + } + + _activeFramebuffer = framebuffer; + if (_activeFramebuffer) { + _activeFramebuffer->activate(); + setProjectionMatrix(_activeFramebuffer->getProjectionMatrix()); + } + + return oldFramebuffer; +} + +} // End of namespace OpenGL -- cgit v1.2.3 From 26f106497a863b84c502d122b5ba749176b2c426 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 28 Feb 2016 23:58:04 +0100 Subject: OPENGL: Implement CLUT8 look up as Pipeline. --- backends/graphics/opengl/pipelines/pipeline.cpp | 27 ++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'backends/graphics/opengl/pipelines/pipeline.cpp') diff --git a/backends/graphics/opengl/pipelines/pipeline.cpp b/backends/graphics/opengl/pipelines/pipeline.cpp index 64121d512a..f79a923f86 100644 --- a/backends/graphics/opengl/pipelines/pipeline.cpp +++ b/backends/graphics/opengl/pipelines/pipeline.cpp @@ -26,17 +26,38 @@ namespace OpenGL { Pipeline::Pipeline() - : _activeFramebuffer(nullptr) { + : _activeFramebuffer(nullptr), _isActive(false) { +} + +void Pipeline::activate() { + _isActive = true; + + if (_activeFramebuffer) { + _activeFramebuffer->activate(); + setProjectionMatrix(_activeFramebuffer->getProjectionMatrix()); + } + + activateInternal(); +} + +void Pipeline::deactivate() { + deactivateInternal(); + + if (_activeFramebuffer) { + _activeFramebuffer->deactivate(); + } + + _isActive = false; } Framebuffer *Pipeline::setFramebuffer(Framebuffer *framebuffer) { Framebuffer *oldFramebuffer = _activeFramebuffer; - if (oldFramebuffer) { + if (_isActive && oldFramebuffer) { oldFramebuffer->deactivate(); } _activeFramebuffer = framebuffer; - if (_activeFramebuffer) { + if (_isActive && _activeFramebuffer) { _activeFramebuffer->activate(); setProjectionMatrix(_activeFramebuffer->getProjectionMatrix()); } -- cgit v1.2.3 From 6dacc96d1f6ed804197382c59765c8cec5146c62 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 2 Mar 2016 14:30:34 +0100 Subject: OPENGL: Only set projection matrix once on pipeline activation. --- backends/graphics/opengl/pipelines/pipeline.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'backends/graphics/opengl/pipelines/pipeline.cpp') diff --git a/backends/graphics/opengl/pipelines/pipeline.cpp b/backends/graphics/opengl/pipelines/pipeline.cpp index f79a923f86..6a59cd28e7 100644 --- a/backends/graphics/opengl/pipelines/pipeline.cpp +++ b/backends/graphics/opengl/pipelines/pipeline.cpp @@ -34,7 +34,6 @@ void Pipeline::activate() { if (_activeFramebuffer) { _activeFramebuffer->activate(); - setProjectionMatrix(_activeFramebuffer->getProjectionMatrix()); } activateInternal(); @@ -59,7 +58,6 @@ Framebuffer *Pipeline::setFramebuffer(Framebuffer *framebuffer) { _activeFramebuffer = framebuffer; if (_isActive && _activeFramebuffer) { _activeFramebuffer->activate(); - setProjectionMatrix(_activeFramebuffer->getProjectionMatrix()); } return oldFramebuffer; -- cgit v1.2.3