DEADSOFTWARE

hashtable cosmetix; holmes scissoring fixes
[d2df-sdl.git] / src / game / g_holmes.inc
index 3cfdd17b09580471164bfc819190b7ee85d861e6..c053b4c73e8eb7b246bf9470fc055a808b0b6434 100644 (file)
@@ -153,6 +153,34 @@ begin
 end;
 
 
+// ////////////////////////////////////////////////////////////////////////// //
+type
+  TScissorSave = record
+  public
+    wassc: Boolean;
+    scxywh: packed array[0..3] of GLint;
+
+  public
+    procedure save (enableScissoring: Boolean);
+    procedure restore ();
+  end;
+
+procedure TScissorSave.save (enableScissoring: Boolean);
+begin
+  wassc := (glIsEnabled(GL_SCISSOR_TEST) <> 0);
+  if wassc then glGetIntegerv(GL_SCISSOR_BOX, @scxywh[0]) else glGetIntegerv(GL_VIEWPORT, @scxywh[0]);
+  //conwritefln('(%d,%d)-(%d,%d)', [scxywh[0], scxywh[1], scxywh[2], scxywh[3]]);
+  if enableScissoring then glEnable(GL_SCISSOR_TEST);
+end;
+
+
+procedure TScissorSave.restore ();
+begin
+  glScissor(scxywh[0], scxywh[1], scxywh[2], scxywh[3]);
+  if wassc then glEnable(GL_SCISSOR_TEST) else glDisable(GL_SCISSOR_TEST);
+end;
+
+
 // ////////////////////////////////////////////////////////////////////////// //
 // fonts
 const kgiFont6: array[0..256*8-1] of Byte  = (