Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2012-10-08 07:28:11 +0400
committerMitchell Stokes <mogurijin@gmail.com>2012-10-08 07:28:11 +0400
commit244ce92dbd1f32960e0f909933d99cd0e6027dcc (patch)
treeee71a9619fb257d9d7deffce53051fa1a6214cdf /source/gameengine/GamePlayer/common
parentaa1e50be946dfeb17f9bb98b242bdbf6775f1ab6 (diff)
BGE: Setting up the RAS_ICanvas interface as the primary way to alter the OpenGL
viewport. This helps to eliminate OpenGL calls in weird places like the physics code and to reduce glGet calls, which are expensive. There should be no functional changes (except maybe a very slight speed improvement).
Diffstat (limited to 'source/gameengine/GamePlayer/common')
-rw-r--r--source/gameengine/GamePlayer/common/GPC_Canvas.cpp22
-rw-r--r--source/gameengine/GamePlayer/common/GPC_Canvas.h3
2 files changed, 25 insertions, 0 deletions
diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp
index 7581484a41f..b5c1c29238a 100644
--- a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp
@@ -57,6 +57,8 @@ GPC_Canvas::GPC_Canvas(
m_displayarea.m_y1 = 0;
m_displayarea.m_x2 = width;
m_displayarea.m_y2 = height;
+
+ glGetIntegerv(GL_VIEWPORT, (GLint*)m_viewport);
}
@@ -121,11 +123,31 @@ void GPC_Canvas::SetViewPort(int x1, int y1, int x2, int y2)
* whole canvas/rendertools mess.
*/
glEnable(GL_SCISSOR_TEST);
+
+ m_viewport[0] = x1;
+ m_viewport[1] = y1;
+ m_viewport[2] = x2-x1 + 1;
+ m_viewport[3] = y2-y1 + 1;
glViewport(x1,y1,x2-x1 + 1,y2-y1 + 1);
glScissor(x1,y1,x2-x1 + 1,y2-y1 + 1);
};
+const int *GPC_Canvas::GetViewPort()
+{
+#ifdef DEBUG
+ // If we're in a debug build, we might as well make sure our values don't differ
+ // from what the gpu thinks we have. This could lead to nasty, hard to find bugs.
+ int viewport[4];
+ glGetIntegerv(GL_VIEWPORT, viewport);
+ assert(viewport[0] == m_viewport[0]);
+ assert(viewport[1] == m_viewport[1]);
+ assert(viewport[2] == m_viewport[2]);
+ assert(viewport[3] == m_viewport[3]);
+#endif
+
+ return m_viewport;
+}
void GPC_Canvas::ClearBuffer(
int type
diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h
index 453b9505183..2a597c4c43d 100644
--- a/source/gameengine/GamePlayer/common/GPC_Canvas.h
+++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h
@@ -90,6 +90,8 @@ protected:
* relative to the context */
RAS_Rect m_displayarea;
+ int *m_viewport;
+
/** Storage for the banners to display. */
TBannerMap m_banners;
/** State of banner display. */
@@ -153,6 +155,7 @@ public:
);
void SetViewPort(int x1, int y1, int x2, int y2);
+ const int *GetViewPort();
void ClearColor(float r, float g, float b, float a);