about summary refs log tree commit diff
path: root/src/engine/client/graphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/client/graphics.cpp')
-rw-r--r--src/engine/client/graphics.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp
index 76fd3400..d1f0b8a8 100644
--- a/src/engine/client/graphics.cpp
+++ b/src/engine/client/graphics.cpp
@@ -179,7 +179,16 @@ CGraphics_OpenGL::CGraphics_OpenGL()
 
 void CGraphics_OpenGL::ClipEnable(int x, int y, int w, int h)
 {
-	//if(no_gfx) return;
+	if(x < 0)
+		w += x;
+	if(y < 0)
+		h += y;
+
+	x = clamp(x, 0, ScreenWidth());
+	y = clamp(y, 0, ScreenHeight());
+	w = clamp(w, 0, ScreenWidth()-x);
+	h = clamp(h, 0, ScreenHeight()-y);
+
 	glScissor(x, ScreenHeight()-(y+h), w, h);
 	glEnable(GL_SCISSOR_TEST);
 }