瀏覽代碼

fix direct references to lwjgl in core

codex 9 月之前
父節點
當前提交
ed7246dca3

+ 4 - 0
jme3-core/src/main/java/com/jme3/renderer/opengl/GL2.java

@@ -74,6 +74,10 @@ public interface GL2 extends GL {
     public static final int GL_TEXTURE_WRAP_R = 0x8072;
     public static final int GL_VERTEX_PROGRAM_POINT_SIZE = 0x8642;
     public static final int GL_UNSIGNED_INT_8_8_8_8 = 0x8035;
+    
+    public static final int GL_READ_ONLY = 35000;
+    public static final int GL_WRITE_ONLY = 35001;
+    public static final int GL_READ_WRITE = 35002;
 
     /**
      * <p><a target="_blank" href="http://docs.gl/gl3/glAlphaFunc">Reference Page</a> - <em>This function is deprecated and unavailable in the Core profile</em></p>

+ 15 - 0
jme3-core/src/main/java/com/jme3/renderer/opengl/GL4.java

@@ -100,4 +100,19 @@ public interface GL4 extends GL3 {
      * @param storageBlockBinding The index storage block binding to associate with the specified storage block.
      */
     public void glShaderStorageBlockBinding(int program, int storageBlockIndex, int storageBlockBinding);
+    
+    /**
+     * Binds a single level of a texture to an image unit for the purpose of reading
+     * and writing it from shaders.
+     * 
+     * @param unit image unit to bind to
+     * @param texture texture to bind to the image unit
+     * @param level level of the texture to bind
+     * @param layered true to bind all array elements
+     * @param layer if not layered, the layer to bind
+     * @param access access types that may be performed
+     * @param format format to use when performing formatted stores
+     */
+    public void glBindImageTexture(int unit, int texture, int level, boolean layered, int layer, int access, int format);
+    
 }

+ 4 - 5
jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java

@@ -80,7 +80,6 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import org.lwjgl.opengl.GL43;
 
 
 public final class GLRenderer implements Renderer {
@@ -2550,10 +2549,10 @@ public final class GLRenderer implements Renderer {
         }
         if (context.boundTextures[unit]==null||context.boundTextures[unit].get() != img.getWeakRef().get()) {
             gl.glBindTexture(target, img.getId());
-            if (img.getAccess() != null) {
+            if (gl4 != null && img.getAccess() != null) {
                 // binds the image so that imageStore and imageLoad operations
                 // can be used in shaders on the image
-                GL43.glBindImageTexture(unit, img.getId(), 0, img.isLayered(),
+                gl4.glBindImageTexture(unit, img.getId(), 0, img.isLayered(),
                         Math.max(img.getBindLayer(), 0), img.getAccess().getGlEnum(),
                         texUtil.getImageFormat(img.getFormat(), false).internalFormat);
             }
@@ -2579,10 +2578,10 @@ public final class GLRenderer implements Renderer {
                 context.boundTextureUnit = unit;
             }
             gl.glBindTexture(target, img.getId());
-            if (img.getAccess() != null) {
+            if (gl4 != null && img.getAccess() != null) {
                 // binds the image so that imageStore and imageLoad operations
                 // can be used in shaders on the image
-                GL43.glBindImageTexture(unit, img.getId(), 0, img.isLayered(),
+                gl4.glBindImageTexture(unit, img.getId(), 0, img.isLayered(),
                         Math.max(img.getBindLayer(), 0), img.getAccess().getGlEnum(),
                         texUtil.getImageFormat(img.getFormat(), false).internalFormat);
             }

+ 4 - 5
jme3-core/src/main/java/com/jme3/texture/Image.java

@@ -37,9 +37,9 @@ import com.jme3.export.JmeImporter;
 import com.jme3.export.OutputCapsule;
 import com.jme3.export.Savable;
 import com.jme3.math.FastMath;
-import com.jme3.opencl.MemoryAccess;
 import com.jme3.renderer.Caps;
 import com.jme3.renderer.Renderer;
+import com.jme3.renderer.opengl.GL2;
 import com.jme3.texture.image.ColorSpace;
 import com.jme3.texture.image.LastTextureState;
 import com.jme3.util.BufferUtils;
@@ -49,7 +49,6 @@ import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import org.lwjgl.opengl.GL20;
 
 /**
  * <code>Image</code> defines a data format for a graphical image. The image
@@ -606,17 +605,17 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
         /**
          * The image can only read from in a shader.
          */
-        ReadOnly(true, false, GL20.GL_READ_ONLY),
+        ReadOnly(true, false, GL2.GL_READ_ONLY),
         
         /**
          * The image can written to in a shader.
          */
-        WriteOnly(false, true, GL20.GL_WRITE_ONLY),
+        WriteOnly(false, true, GL2.GL_WRITE_ONLY),
         
         /**
          * The image can both be written to and read from in a shader.
          */
-        ReadWrite(true, true, GL20.GL_READ_WRITE);
+        ReadWrite(true, true, GL2.GL_READ_WRITE);
         
         private final boolean read, write;
         private final int glEnum;

+ 6 - 0
jme3-lwjgl3/src/main/java/com/jme3/renderer/lwjgl/LwjglGL.java

@@ -80,6 +80,12 @@ public class LwjglGL extends LwjglRender implements GL, GL2, GL3, GL4 {
     public void glBindTexture(final int target, final int texture) {
         GL11.glBindTexture(target, texture);
     }
+    
+    @Override
+    public void glBindImageTexture(final int unit, final int texture, final int level,
+            final boolean layered, final int layer, final int access, final int format) {
+        GL42.glBindImageTexture(unit, texture, level, layered, layer, access, format);
+    }
 
     @Override
     public void glBlendEquationSeparate(final int colorMode, final int alphaMode) {