This is an OpenGL Image class (which is not to be confused with an OpenGL Texture). An OpenGL Image is a very recent addition to OpenGL. Unlike Textures, Images can be writeable in random access ways from shaders. Doesn't work, currently, on any version of OS X
| 9 | |
| 10 | import static org.lwjgl.opengl.GL11.*; |
| 11 | import static org.lwjgl.opengl.GL15.GL_READ_WRITE; |
| 12 | import static org.lwjgl.opengl.GL30.GL_RGBA32F; |
| 13 | import static org.lwjgl.opengl.GL42.glBindImageTexture; |
| 14 | |
| 15 | /** |
| 16 | * This is an OpenGL Image class (which is not to be confused with an OpenGL Texture). |
| 17 | * <p> |
| 18 | * An OpenGL Image is a very recent addition to OpenGL. Unlike Textures, Images can be writeable in random access ways from shaders. Doesn't work, currently, on any version of OS X |
| 19 | */ |
| 20 | public class Image implements Scene.Perform, OffersUniform<Integer> { |
| 21 | |
| 22 | public final Texture texture; |
| 23 | |
| 24 | public Image(Texture texture) { |
| 25 | this.texture = texture; |
| 26 | } |
| 27 | |
| 28 | @Override |
| 29 | public boolean perform(int pass) { |
| 30 | if (pass == -1) return perform(); |
| 31 | return true; |
| 32 | } |
| 33 | |
| 34 | private boolean perform() { |
| 35 | texture.perform(-1); |
| 36 | |
| 37 | GraphicsContext.checkError(() -> " bound texture now binding image "+texture.specification.unit+" "+((Texture.State) GraphicsContext |
| 38 | .get(texture)).name); |
| 39 | |
| 40 | int name = ((Texture.State) GraphicsContext |
| 41 | .get(texture)).name; |
| 42 | // System.out.println(" name is :"+name+" / "+texture.specification.unit); |
| 43 | glBindImageTexture(texture.specification.unit, name, 0, false, 0, GL_READ_WRITE, texture.specification.internalFormat); |
| 44 | GraphicsContext.checkError(() -> " after binding image "); |
| 45 | |
| 46 | return true; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | |
| 51 | @Override |
| 52 | public Integer getUniform() { |
| 53 | return texture.getUniform(); |
| 54 | } |
nothing calls this directly
no outgoing calls
no test coverage detected