diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2012-10-08 07:28:11 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2012-10-08 07:28:11 +0400 |
commit | 244ce92dbd1f32960e0f909933d99cd0e6027dcc (patch) | |
tree | ee71a9619fb257d9d7deffce53051fa1a6214cdf /source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp | |
parent | aa1e50be946dfeb17f9bb98b242bdbf6775f1ab6 (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/BlenderRoutines/KX_BlenderCanvas.cpp')
-rw-r--r-- | source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp index 4f450bcd668..0b41cceb646 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp @@ -33,6 +33,7 @@ #include "KX_BlenderCanvas.h" #include "DNA_screen_types.h" #include <stdio.h> +#include <assert.h> KX_BlenderCanvas::KX_BlenderCanvas(struct wmWindow *win, RAS_Rect &rect, struct ARegion *ar) : @@ -44,6 +45,8 @@ m_frame_rect(rect) // area boundaries needed for mouse coordinates in Letterbox framing mode m_area_left = ar->winrct.xmin; m_area_top = ar->winrct.ymax; + + glGetIntegerv(GL_VIEWPORT, (GLint*)m_viewport); } KX_BlenderCanvas::~KX_BlenderCanvas() @@ -166,10 +169,31 @@ SetViewPort( m_area_rect.SetRight(minx + x2); m_area_rect.SetTop(miny + y2); + m_viewport[0] = minx+x1; + m_viewport[1] = miny+y1; + m_viewport[2] = vp_width; + m_viewport[3] = vp_height; + glViewport(minx + x1, miny + y1, vp_width, vp_height); glScissor(minx + x1, miny + y1, vp_width, vp_height); } + const int* +KX_BlenderCanvas:: +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 KX_BlenderCanvas::SetMouseState(RAS_MouseState mousestate) { |