[colobot] 242/377: Optimized matrix operations in CGLDevice
Didier Raboud
odyx at moszumanska.debian.org
Wed Mar 30 13:34:22 UTC 2016
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch debian/master
in repository colobot.
commit 9db943b8201e06c2e0cc6397bd94303754ae36cd
Author: Tomasz Kapuściński <tomaszkax86 at gmail.com>
Date: Sat Jan 30 17:41:11 2016 +0100
Optimized matrix operations in CGLDevice
---
src/graphics/opengl/gldevice.cpp | 29 ++++++++++++++++++-----------
src/graphics/opengl/gldevice.h | 4 ++++
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index f0c7e13..5bef6f4 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -323,8 +323,15 @@ bool CGLDevice::Create()
m_framebufferSupport = DetectFramebufferSupport();
if (m_framebufferSupport != FBS_NONE)
+ {
+ glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &m_maxRenderbufferSize);
GetLogger()->Info("Framebuffer supported\n");
-
+ GetLogger()->Info("Maximum renderbuffer size: %d\n", m_maxRenderbufferSize);
+ }
+ else
+ {
+ GetLogger()->Info("Framebuffer not supported\n");
+ }
GetLogger()->Info("CDevice created successfully\n");
return true;
@@ -395,17 +402,23 @@ void CGLDevice::SetTransform(TransformType type, const Math::Matrix &matrix)
{
m_worldMat = matrix;
UpdateModelviewMatrix();
+
+ m_combinedMatrix = Math::MultiplyMatrices(m_projectionMat, m_modelviewMat);
}
else if (type == TRANSFORM_VIEW)
{
m_viewMat = matrix;
UpdateModelviewMatrix();
+
+ m_combinedMatrix = Math::MultiplyMatrices(m_projectionMat, m_modelviewMat);
}
else if (type == TRANSFORM_PROJECTION)
{
m_projectionMat = matrix;
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(m_projectionMat.Array());
+
+ m_combinedMatrix = Math::MultiplyMatrices(m_projectionMat, m_modelviewMat);
}
else if (type == TRANSFORM_SHADOW)
{
@@ -425,12 +438,12 @@ void CGLDevice::SetTransform(TransformType type, const Math::Matrix &matrix)
void CGLDevice::UpdateModelviewMatrix()
{
- m_modelviewMat = Math::MultiplyMatrices(m_viewMat, m_worldMat);
-
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glScalef(1.0f, 1.0f, -1.0f);
- glMultMatrixf(m_modelviewMat.Array());
+ glMultMatrixf(m_viewMat.Array());
+ glMultMatrixf(m_worldMat.Array());
+ glGetFloatv(GL_MODELVIEW_MATRIX, m_modelviewMat.Array());
if (m_lighting)
{
@@ -1751,13 +1764,7 @@ void CGLDevice::DestroyStaticBuffer(unsigned int bufferId)
int CGLDevice::ComputeSphereVisibility(const Math::Vector ¢er, float radius)
{
- Math::Matrix m;
- m = Math::MultiplyMatrices(m_worldMat, m);
- m = Math::MultiplyMatrices(m_viewMat, m);
- Math::Matrix sc;
- Math::LoadScaleMatrix(sc, Math::Vector(1.0f, 1.0f, -1.0f));
- m = Math::MultiplyMatrices(sc, m);
- m = Math::MultiplyMatrices(m_projectionMat, m);
+ Math::Matrix &m = m_combinedMatrix;
Math::Vector vec[6];
float originPlane[6];
diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h
index 061c263..696e6d6 100644
--- a/src/graphics/opengl/gldevice.h
+++ b/src/graphics/opengl/gldevice.h
@@ -210,6 +210,8 @@ private:
Math::Matrix m_modelviewMat;
//! Current projection matrix
Math::Matrix m_projectionMat;
+ //! Combined world-view-projection matrix
+ Math::Matrix m_combinedMatrix;
//! The current material
Material m_material;
@@ -268,6 +270,8 @@ private:
int m_maxAnisotropy = 1;
//! Maximum samples
int m_maxSamples = 1;
+ //! Maximum renderbuffer size
+ int m_maxRenderbufferSize = 0;
//! glMultiDrawArrays() available
bool m_multiDrawArrays = false;
//! Framebuffer support
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list