]> git.tdb.fi Git - libs/gl.git/commitdiff
Access clipping through the extension mechanism
authorMikko Rasa <tdb@tdb.fi>
Thu, 1 Sep 2016 13:41:15 +0000 (16:41 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 1 Sep 2016 13:41:15 +0000 (16:41 +0300)
It's not supported on OpenGL ES.

extensions/msp_clipping.glext [new file with mode: 0644]
gl.fixes.xml
source/clipping.cpp
source/clipplane.cpp
source/clipunit.cpp

diff --git a/extensions/msp_clipping.glext b/extensions/msp_clipping.glext
new file mode 100644 (file)
index 0000000..b94288c
--- /dev/null
@@ -0,0 +1 @@
+extension MSP_clipping
index f3e2e60e34ab0bef32caf4858a20f95589aad82b..8edc3731bea7baeb3c4ee77af3859cc3a715136b 100644 (file)
                 <command name="glNormalPointer" />
                 <command name="glColorPointer" />
                 <command name="glTexCoordPointer" />
+
+                <command name="glClipPlane" />
             </require>
         </extension>
 
             </require>
         </extension>
 
+        <!-- OpenGL ES does not have harwdare clipping. -->
+        <extension name="GL_MSP_clipping" supported="gl">
+            <require>
+                <enum name="GL_MAX_CLIP_PLANES" />
+                <enum name="GL_CLIP_PLANE0" />
+                <enum name="GL_CLIP_PLANE1" />
+                <enum name="GL_CLIP_PLANE2" />
+                <enum name="GL_CLIP_PLANE3" />
+                <enum name="GL_CLIP_PLANE4" />
+                <enum name="GL_CLIP_PLANE5" />
+            </require>
+        </extension>
+
         <!-- Stereo rendering is not supported on OpenGL ES, but I'm not
         certain enough of its uselessness to remove the constants outright. -->
         <extension name="GL_MSP_stereo_rendering" supported="gl">
index 430a7b6fd05918b43c62204b18859bdd47a828f0..6508ecf7f695306df3e76cf4e7f03689e00eee8b 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/gl/extensions/msp_clipping.h>
 #include <msp/gl/extensions/msp_legacy_features.h>
 #include "clipping.h"
 #include "clipplane.h"
@@ -55,8 +56,9 @@ void Clipping::update_shader_data(ProgramData &shdata, const Matrix &view_matrix
 
 void Clipping::bind(bool legacy) const
 {
+       static Require _req(MSP_clipping);
        if(legacy)
-               static Require _req(MSP_legacy_features);
+               static Require _req2(MSP_legacy_features);
        
        if(legacy!=bound_with_legacy)
                unbind();
index e0b425a4c221ff107a29b2527e2e1a544727fe89..21df0d17e36e1dc63567de245649e8634f03fd11 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/gl/extensions/msp_clipping.h>
 #include <msp/gl/extensions/msp_legacy_features.h>
 #include <msp/strings/format.h>
 #include "clipplane.h"
@@ -50,7 +51,8 @@ void ClipPlane::update_shader_data(ProgramData &shdata, const Matrix &view_inver
 
 void ClipPlane::bind_to(unsigned i) const
 {
-       Require _req(MSP_legacy_features);
+       Require _req(MSP_clipping);
+       Require _req2(MSP_legacy_features);
 
        ClipUnit &unit = ClipUnit::get_unit(i);
        if(unit.set_plane(this))
index 83080bd773e63e221a6d496b1981f9af4eb91ea4..2db721cf0985dd333ea4d4bcec2100a3326eb24b 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/gl/extensions/msp_clipping.h>
 #include <stdexcept>
 #include "clipunit.h"
 #include "gl.h"
@@ -24,6 +25,7 @@ bool ClipUnit::set_plane(const ClipPlane *p)
 
 unsigned ClipUnit::get_n_units()
 {
+       static Require _req(MSP_clipping);
        static int count = get_i(GL_MAX_CLIP_PLANES);
        return count;
 }