summaryrefslogtreecommitdiffstats
path: root/make/config/jogl/gl-impl-CustomJavaCode-common.java
blob: b1500adcf914f1b1e1f0a1fafb1a14ddd4ca429f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
    private final GLProfile glProfile;
    private final GLContextImpl _context;

    @Override
    public GLProfile getGLProfile() {
        return this.glProfile;
    }

    @Override
    public final int getBoundBuffer(int target) {
        return bufferStateTracker.getBoundBufferObject(target, this);
    }

    @Override
    public final GLBufferStorage getBufferStorage(int bufferName) {
        return bufferObjectTracker.getBufferStorage(bufferName);
    }

    @Override
    public final boolean isVBOArrayBound() {
        return checkArrayVBOBound(false);
    }

    @Override
    public final boolean isVBOElementArrayBound() {
        return checkElementVBOBound(false);
    }

    @Override
    public final GL getDownstreamGL() throws GLException {
        return null;
    }

    @Override
    public final GL getRootGL() throws GLException {
        return this;
    }

    @Override
    public final boolean isGL() {
        return true;
    }
      
    @Override
    public final GL getGL() throws GLException {
        return this;
    }

    @Override
    public final boolean isFunctionAvailable(String glFunctionName) {
      return _context.isFunctionAvailable(glFunctionName);
    }

    @Override
    public final boolean isExtensionAvailable(String glExtensionName) {
      return _context.isExtensionAvailable(glExtensionName);
    }

    @Override
    public final Object getExtension(String extensionName) {
      // At this point we don't expose any extensions using this mechanism
      return null;
    }

    @Override
    public final boolean hasBasicFBOSupport() {
      return _context.hasBasicFBOSupport();
    }

    @Override
    public final boolean hasFullFBOSupport() {
      return _context.hasFullFBOSupport();
    }

    @Override
    public final int getMaxRenderbufferSamples() {
      return _context.getMaxRenderbufferSamples();
    }

    @Override
    public final boolean isTextureFormatBGRA8888Available() {
      return _context.isTextureFormatBGRA8888Available();
    }

    @Override
    public final GLContext getContext() {
      return _context;
    }

    /**
     * @see com.jogamp.opengl.GLContext#setSwapInterval(int)
     */
    @Override
    public final void setSwapInterval(int interval) {
      _context.setSwapInterval(interval);
    }

    /**
     * @see com.jogamp.opengl.GLContext#getSwapInterval()
     */
    @Override
    public final int getSwapInterval() {
      return _context.getSwapInterval();
    }

    @Override
    public final Object getPlatformGLExtensions() {
      return _context.getPlatformGLExtensions();
    }

    @Override
    public final int getBoundFramebuffer(int target) {
      return _context.getBoundFramebuffer(target);
    }

    @Override
    public final int getDefaultDrawFramebuffer() {
      return _context.getDefaultDrawFramebuffer();
    }

    @Override
    public final int getDefaultReadFramebuffer() {
      return _context.getDefaultReadFramebuffer();
    }

    @Override
    public final int getDefaultDrawBuffer() {
      return _context.getDefaultDrawBuffer();
    }

    @Override
    public final int getDefaultReadBuffer() {
      return _context.getDefaultReadBuffer();
    }

    private final GLStateTracker       glStateTracker;

    //
    // GLBufferObjectTracker Redirects
    //
    private final GLBufferObjectTracker bufferObjectTracker;
    private final GLBufferStateTracker bufferStateTracker;

    @Override
    public final void glBufferData(int target, long size, Buffer data, int usage)  {
        bufferObjectTracker.createBufferStorage(bufferStateTracker, this, 
                                                target, size, data, usage, 0 /* immutableFlags */, 
                                                glBufferDataDispatch);
    }
    private final jogamp.opengl.GLBufferObjectTracker.CreateStorageDispatch glBufferDataDispatch = 
        new jogamp.opengl.GLBufferObjectTracker.CreateStorageDispatch() {
            public final void create(final int target, final long size, final Buffer data, final int mutableUsage) {
                glBufferDataDelegate(target, size, data, mutableUsage);
            }
        };

    @Override
    public boolean glUnmapBuffer(int target)  {
        return bufferObjectTracker.unmapBuffer(bufferStateTracker, this, target, glUnmapBufferDispatch);
    }
    private final jogamp.opengl.GLBufferObjectTracker.UnmapBufferDispatch glUnmapBufferDispatch = 
        new jogamp.opengl.GLBufferObjectTracker.UnmapBufferDispatch() {
            public final boolean unmap(final int target) {
                return glUnmapBufferDelegate(target);
            }
        };

    @Override
    public final java.nio.ByteBuffer glMapBuffer(int target, int access) {
      return mapBuffer(target, access).getMappedBuffer();
    }
    @Override
    public final GLBufferStorage mapBuffer(final int target, final int access) {
      return bufferObjectTracker.mapBuffer(bufferStateTracker, this, target, access, glMapBufferDispatch);
    }
    private final jogamp.opengl.GLBufferObjectTracker.MapBufferAllDispatch glMapBufferDispatch = 
        new jogamp.opengl.GLBufferObjectTracker.MapBufferAllDispatch() {
            public final ByteBuffer allocNioByteBuffer(final long addr, final long length) { return newDirectByteBuffer(addr, length); }
            public final long mapBuffer(final int target, final int access) {
                return glMapBufferDelegate(target, access);
            }
        };

    @Override
    public final ByteBuffer glMapBufferRange(int target, long offset, long length, int access)  {
      return mapBufferRange(target, offset, length, access).getMappedBuffer();
    }
    @Override
    public final GLBufferStorage mapBufferRange(final int target, final long offset, final long length, final int access) {
      return bufferObjectTracker.mapBuffer(bufferStateTracker, this, target, offset, length, access, glMapBufferRangeDispatch);
    }
    private final jogamp.opengl.GLBufferObjectTracker.MapBufferRangeDispatch glMapBufferRangeDispatch = 
        new jogamp.opengl.GLBufferObjectTracker.MapBufferRangeDispatch() {
            public final ByteBuffer allocNioByteBuffer(final long addr, final long length) { return newDirectByteBuffer(addr, length); }
            public final long mapBuffer(final int target, final long offset, final long length, final int access) {
                return glMapBufferRangeDelegate(target, offset, length, access);
            }
        };

    private native ByteBuffer newDirectByteBuffer(long addr, long capacity);