DrawBuffer: Basic scissor support.

This commit is contained in:
Henrik Rydgard
2012-05-07 18:27:09 +02:00
parent ec57b692eb
commit f03ec57c17
2 changed files with 20 additions and 0 deletions
+13
View File
@@ -13,6 +13,7 @@
#include <algorithm>
#include <cmath>
#include "base/display.h"
#include "base/logging.h"
#include "math/math_util.h"
#include "gfx_es2/draw_buffer.h"
@@ -360,3 +361,15 @@ void DrawBuffer::EnableBlend(bool enable) {
else
glDisable(GL_BLEND);
}
void DrawBuffer::SetClipRect(float x, float y, float w, float h)
{
// Sigh, OpenGL is upside down.
glScissor(x, g_yres - y, w, h);
glEnable(GL_SCISSOR_TEST);
}
void DrawBuffer::NoClip()
{
glDisable(GL_SCISSOR_TEST);
}
+7
View File
@@ -97,6 +97,13 @@ class DrawBuffer {
// Utility to avoid having to include gl.h just for this in UI code.
void EnableBlend(bool enable);
// Rectangular clipping, implemented using scissoring.
// Must flush before and after.
void SetClipRect(float x1, float y1, float x2, float y2);
void NoClip();
private:
void DoAlign(int flags, float *x, float *y, float *w, float *h);
struct Vertex {