Revision e6519ac8
Added by Leszek Koltunski over 6 years ago
src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.effect; |
21 | 21 |
|
22 |
import android.opengl.GLES30;
|
|
22 |
import android.opengl.GLES31;
|
|
23 | 23 |
|
24 | 24 |
import org.distorted.library.main.DistortedFramebuffer; |
25 | 25 |
import org.distorted.library.main.DistortedOutputSurface; |
... | ... | |
164 | 164 |
|
165 | 165 |
int offset = radius + radius*radius/4; |
166 | 166 |
radius = (radius+1)/2; |
167 |
GLES30.glViewport(0, 0, (int)w, (int)h);
|
|
167 |
GLES31.glViewport(0, 0, (int)w, (int)h);
|
|
168 | 168 |
|
169 | 169 |
// horizontal blur |
170 | 170 |
for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/w; |
... | ... | |
173 | 173 |
buffer.bindForOutput(1); |
174 | 174 |
buffer.setAsInput(0); |
175 | 175 |
|
176 |
GLES30.glUniform1f ( mProgram1.mUniform[0] , n );
|
|
177 |
GLES30.glUniform1i ( mProgram1.mUniform[1] , 0 );
|
|
178 |
GLES30.glUniform1fv( mProgram1.mUniform[2] , radius+1, mOffsets,0);
|
|
179 |
GLES30.glUniform1fv( mProgram1.mUniform[3] , radius+1, weightsCache,offset);
|
|
180 |
GLES30.glUniform1i ( mProgram1.mUniform[4] , radius);
|
|
181 |
GLES30.glVertexAttribPointer(mProgram1.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadPositions);
|
|
182 |
GLES30.glVertexAttribPointer(mProgram1.mAttribute[1], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadTexture);
|
|
183 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);
|
|
176 |
GLES31.glUniform1f ( mProgram1.mUniform[0] , n );
|
|
177 |
GLES31.glUniform1i ( mProgram1.mUniform[1] , 0 );
|
|
178 |
GLES31.glUniform1fv( mProgram1.mUniform[2] , radius+1, mOffsets,0);
|
|
179 |
GLES31.glUniform1fv( mProgram1.mUniform[3] , radius+1, weightsCache,offset);
|
|
180 |
GLES31.glUniform1i ( mProgram1.mUniform[4] , radius);
|
|
181 |
GLES31.glVertexAttribPointer(mProgram1.mAttribute[0], POS_DATA_SIZE, GLES31.GL_FLOAT, false, 0, mQuadPositions);
|
|
182 |
GLES31.glVertexAttribPointer(mProgram1.mAttribute[1], TEX_DATA_SIZE, GLES31.GL_FLOAT, false, 0, mQuadTexture);
|
|
183 |
GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, 4);
|
|
184 | 184 |
|
185 | 185 |
// vertical blur |
186 | 186 |
for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/h; |
... | ... | |
189 | 189 |
buffer.bindForOutput(0); |
190 | 190 |
buffer.setAsInput(1); |
191 | 191 |
|
192 |
GLES30.glColorMask(true,true,true,true);
|
|
193 |
GLES30.glClearColor(0.0f,0.0f,0.0f,0.0f);
|
|
194 |
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT);
|
|
195 |
|
|
196 |
GLES30.glUniform1f ( mProgram2.mUniform[0] , n );
|
|
197 |
GLES30.glUniform1i ( mProgram2.mUniform[1] , 0 );
|
|
198 |
GLES30.glUniform1fv( mProgram2.mUniform[2] , radius+1, mOffsets,0);
|
|
199 |
GLES30.glUniform1fv( mProgram2.mUniform[3] , radius+1, weightsCache,offset);
|
|
200 |
GLES30.glUniform1i ( mProgram2.mUniform[4] , radius);
|
|
201 |
GLES30.glVertexAttribPointer(mProgram2.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadPositions);
|
|
202 |
GLES30.glVertexAttribPointer(mProgram2.mAttribute[1], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadTexture);
|
|
203 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);
|
|
192 |
GLES31.glColorMask(true,true,true,true);
|
|
193 |
GLES31.glClearColor(0.0f,0.0f,0.0f,0.0f);
|
|
194 |
GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT);
|
|
195 |
|
|
196 |
GLES31.glUniform1f ( mProgram2.mUniform[0] , n );
|
|
197 |
GLES31.glUniform1i ( mProgram2.mUniform[1] , 0 );
|
|
198 |
GLES31.glUniform1fv( mProgram2.mUniform[2] , radius+1, mOffsets,0);
|
|
199 |
GLES31.glUniform1fv( mProgram2.mUniform[3] , radius+1, weightsCache,offset);
|
|
200 |
GLES31.glUniform1i ( mProgram2.mUniform[4] , radius);
|
|
201 |
GLES31.glVertexAttribPointer(mProgram2.mAttribute[0], POS_DATA_SIZE, GLES31.GL_FLOAT, false, 0, mQuadPositions);
|
|
202 |
GLES31.glVertexAttribPointer(mProgram2.mAttribute[1], TEX_DATA_SIZE, GLES31.GL_FLOAT, false, 0, mQuadTexture);
|
|
203 |
GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, 4);
|
|
204 | 204 |
|
205 | 205 |
DistortedRenderState.unuseStencilMark(); |
206 | 206 |
|
src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.effect; |
21 | 21 |
|
22 |
import android.opengl.GLES30;
|
|
22 |
import android.opengl.GLES31;
|
|
23 | 23 |
|
24 | 24 |
import org.distorted.library.main.DistortedEffects; |
25 | 25 |
import org.distorted.library.main.DistortedFramebuffer; |
... | ... | |
169 | 169 |
radius = (radius+1)/2; |
170 | 170 |
|
171 | 171 |
outBuffer.setAsOutput(); |
172 |
GLES30.glViewport(0, 0, (int)w, (int)h);
|
|
172 |
GLES31.glViewport(0, 0, (int)w, (int)h);
|
|
173 | 173 |
|
174 | 174 |
// horizontal glow |
175 | 175 |
for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/w; |
... | ... | |
178 | 178 |
outBuffer.bindForOutput(1); |
179 | 179 |
inBuffer.setAsInput(0); |
180 | 180 |
|
181 |
GLES30.glUniform1f ( mProgram1.mUniform[0] , n );
|
|
182 |
GLES30.glUniform1i ( mProgram1.mUniform[1] , 0 );
|
|
183 |
GLES30.glUniform1fv( mProgram1.mUniform[2] , radius+1, mOffsets,0);
|
|
184 |
GLES30.glUniform1fv( mProgram1.mUniform[3] , radius+1, weightsCache,offset);
|
|
185 |
GLES30.glUniform1i ( mProgram1.mUniform[4] , radius);
|
|
186 |
GLES30.glUniform4f ( mProgram1.mUniform[5] , uniforms[index+1], uniforms[index+2], uniforms[index+3], uniforms[index+4]);
|
|
187 |
GLES30.glVertexAttribPointer(mProgram1.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadPositions);
|
|
188 |
GLES30.glVertexAttribPointer(mProgram1.mAttribute[1], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadTexture);
|
|
189 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);
|
|
181 |
GLES31.glUniform1f ( mProgram1.mUniform[0] , n );
|
|
182 |
GLES31.glUniform1i ( mProgram1.mUniform[1] , 0 );
|
|
183 |
GLES31.glUniform1fv( mProgram1.mUniform[2] , radius+1, mOffsets,0);
|
|
184 |
GLES31.glUniform1fv( mProgram1.mUniform[3] , radius+1, weightsCache,offset);
|
|
185 |
GLES31.glUniform1i ( mProgram1.mUniform[4] , radius);
|
|
186 |
GLES31.glUniform4f ( mProgram1.mUniform[5] , uniforms[index+1], uniforms[index+2], uniforms[index+3], uniforms[index+4]);
|
|
187 |
GLES31.glVertexAttribPointer(mProgram1.mAttribute[0], POS_DATA_SIZE, GLES31.GL_FLOAT, false, 0, mQuadPositions);
|
|
188 |
GLES31.glVertexAttribPointer(mProgram1.mAttribute[1], TEX_DATA_SIZE, GLES31.GL_FLOAT, false, 0, mQuadTexture);
|
|
189 |
GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, 4);
|
|
190 | 190 |
|
191 | 191 |
// vertical glow |
192 | 192 |
for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/h; |
... | ... | |
195 | 195 |
outBuffer.bindForOutput(0); |
196 | 196 |
outBuffer.setAsInput(1); |
197 | 197 |
|
198 |
GLES30.glUniform1f ( mProgram2.mUniform[0] , n );
|
|
199 |
GLES30.glUniform1i ( mProgram2.mUniform[1] , 0 );
|
|
200 |
GLES30.glUniform1fv( mProgram2.mUniform[2] , radius+1, mOffsets,0);
|
|
201 |
GLES30.glUniform1fv( mProgram2.mUniform[3] , radius+1, weightsCache,offset);
|
|
202 |
GLES30.glUniform1i ( mProgram2.mUniform[4] , radius);
|
|
203 |
GLES30.glUniform4f ( mProgram1.mUniform[5] , uniforms[index+1], uniforms[index+2], uniforms[index+3], uniforms[index+4]);
|
|
204 |
GLES30.glVertexAttribPointer(mProgram2.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadPositions);
|
|
205 |
GLES30.glVertexAttribPointer(mProgram2.mAttribute[1], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadTexture);
|
|
206 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);
|
|
198 |
GLES31.glUniform1f ( mProgram2.mUniform[0] , n );
|
|
199 |
GLES31.glUniform1i ( mProgram2.mUniform[1] , 0 );
|
|
200 |
GLES31.glUniform1fv( mProgram2.mUniform[2] , radius+1, mOffsets,0);
|
|
201 |
GLES31.glUniform1fv( mProgram2.mUniform[3] , radius+1, weightsCache,offset);
|
|
202 |
GLES31.glUniform1i ( mProgram2.mUniform[4] , radius);
|
|
203 |
GLES31.glUniform4f ( mProgram1.mUniform[5] , uniforms[index+1], uniforms[index+2], uniforms[index+3], uniforms[index+4]);
|
|
204 |
GLES31.glVertexAttribPointer(mProgram2.mAttribute[0], POS_DATA_SIZE, GLES31.GL_FLOAT, false, 0, mQuadPositions);
|
|
205 |
GLES31.glVertexAttribPointer(mProgram2.mAttribute[1], TEX_DATA_SIZE, GLES31.GL_FLOAT, false, 0, mQuadTexture);
|
|
206 |
GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, 4);
|
|
207 | 207 |
|
208 | 208 |
DistortedRenderState.unuseStencilMark(); |
209 | 209 |
|
src/main/java/org/distorted/library/main/DistortedEffects.java | ||
---|---|---|
20 | 20 |
package org.distorted.library.main; |
21 | 21 |
|
22 | 22 |
import android.content.res.Resources; |
23 |
import android.opengl.GLES30; |
|
23 |
import android.opengl.GLES31; |
|
24 |
import android.util.Log; |
|
24 | 25 |
|
25 | 26 |
import org.distorted.library.R; |
26 | 27 |
import org.distorted.library.effect.Effect; |
... | ... | |
118 | 119 |
EffectQueueFragment.getUniforms(mainProgramH); |
119 | 120 |
EffectQueueVertex.getUniforms(mainProgramH); |
120 | 121 |
EffectQueueMatrix.getUniforms(mainProgramH); |
121 |
mMainTextureH= GLES30.glGetUniformLocation( mainProgramH, "u_Texture");
|
|
122 |
mMainTextureH= GLES31.glGetUniformLocation( mainProgramH, "u_Texture");
|
|
122 | 123 |
|
123 | 124 |
// BLIT PROGRAM //////////////////////////////////// |
124 | 125 |
final InputStream blitVertStream = resources.openRawResource(R.raw.blit_vertex_shader); |
... | ... | |
133 | 134 |
} |
134 | 135 |
catch(Exception e) |
135 | 136 |
{ |
136 |
android.util.Log.e("EFFECTS", "exception trying to compile BLIT program: "+e.getMessage());
|
|
137 |
Log.e("EFFECTS", "exception trying to compile BLIT program: "+e.getMessage()); |
|
137 | 138 |
throw new RuntimeException(e.getMessage()); |
138 | 139 |
} |
139 | 140 |
|
140 | 141 |
int blitProgramH = mBlitProgram.getProgramHandle(); |
141 |
mBlitTextureH = GLES30.glGetUniformLocation( blitProgramH, "u_Texture");
|
|
142 |
mBlitDepthH = GLES30.glGetUniformLocation( blitProgramH, "u_Depth");
|
|
142 |
mBlitTextureH = GLES31.glGetUniformLocation( blitProgramH, "u_Texture");
|
|
143 |
mBlitDepthH = GLES31.glGetUniformLocation( blitProgramH, "u_Depth");
|
|
143 | 144 |
|
144 | 145 |
// BLIT DEPTH PROGRAM //////////////////////////////////// |
145 | 146 |
final InputStream blitDepthVertStream = resources.openRawResource(R.raw.blit_depth_vertex_shader); |
... | ... | |
151 | 152 |
} |
152 | 153 |
catch(Exception e) |
153 | 154 |
{ |
154 |
android.util.Log.e("EFFECTS", "exception trying to compile BLIT DEPTH program: "+e.getMessage());
|
|
155 |
Log.e("EFFECTS", "exception trying to compile BLIT DEPTH program: "+e.getMessage()); |
|
155 | 156 |
throw new RuntimeException(e.getMessage()); |
156 | 157 |
} |
157 | 158 |
|
158 | 159 |
int blitDepthProgramH = mBlitDepthProgram.getProgramHandle(); |
159 |
mBlitDepthTextureH = GLES30.glGetUniformLocation( blitDepthProgramH, "u_Texture");
|
|
160 |
mBlitDepthDepthTextureH = GLES30.glGetUniformLocation( blitDepthProgramH, "u_DepthTexture");
|
|
161 |
mBlitDepthDepthH = GLES30.glGetUniformLocation( blitDepthProgramH, "u_Depth");
|
|
160 |
mBlitDepthTextureH = GLES31.glGetUniformLocation( blitDepthProgramH, "u_Texture");
|
|
161 |
mBlitDepthDepthTextureH = GLES31.glGetUniformLocation( blitDepthProgramH, "u_DepthTexture");
|
|
162 |
mBlitDepthDepthH = GLES31.glGetUniformLocation( blitDepthProgramH, "u_Depth");
|
|
162 | 163 |
|
163 | 164 |
// NORMAL PROGRAM ////////////////////////////////////// |
164 | 165 |
final InputStream normalVertexStream = resources.openRawResource(R.raw.normal_vertex_shader); |
... | ... | |
170 | 171 |
} |
171 | 172 |
catch(Exception e) |
172 | 173 |
{ |
173 |
android.util.Log.e("EFFECTS", "exception trying to compile NORMAL program: "+e.getMessage());
|
|
174 |
Log.e("EFFECTS", "exception trying to compile NORMAL program: "+e.getMessage()); |
|
174 | 175 |
throw new RuntimeException(e.getMessage()); |
175 | 176 |
} |
176 | 177 |
|
177 | 178 |
int normalProgramH = mNormalProgram.getProgramHandle(); |
178 |
mNormalMVPMatrixH = GLES30.glGetUniformLocation( normalProgramH, "u_MVPMatrix");
|
|
179 |
mNormalMVPMatrixH = GLES31.glGetUniformLocation( normalProgramH, "u_MVPMatrix");
|
|
179 | 180 |
} |
180 | 181 |
|
181 | 182 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
248 | 249 |
|
249 | 250 |
private void displayNormals(MeshObject mesh) |
250 | 251 |
{ |
251 |
GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mesh.mAttTFO[0]);
|
|
252 |
GLES30.glBeginTransformFeedback( GLES30.GL_POINTS);
|
|
252 |
GLES31.glBindBufferBase(GLES31.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mesh.mAttTFO[0]);
|
|
253 |
GLES31.glBeginTransformFeedback( GLES31.GL_POINTS);
|
|
253 | 254 |
DistortedRenderState.switchOffDrawing(); |
254 |
GLES30.glDrawArrays( GLES30.GL_POINTS, 0, mesh.numVertices);
|
|
255 |
GLES31.glDrawArrays( GLES31.GL_POINTS, 0, mesh.numVertices);
|
|
255 | 256 |
DistortedRenderState.restoreDrawing(); |
256 |
GLES30.glEndTransformFeedback();
|
|
257 |
GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
|
|
257 |
GLES31.glEndTransformFeedback();
|
|
258 |
GLES31.glBindBufferBase(GLES31.GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
|
|
258 | 259 |
|
259 | 260 |
mNormalProgram.useProgram(); |
260 |
GLES30.glUniformMatrix4fv(mNormalMVPMatrixH, 1, false, mM.getMVP() , 0);
|
|
261 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mAttTFO[0]);
|
|
262 |
GLES30.glVertexAttribPointer(mNormalProgram.mAttribute[0], MeshObject.POS_DATA_SIZE, GLES30.GL_FLOAT, false, 0, 0);
|
|
263 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0);
|
|
264 |
GLES30.glLineWidth(8.0f);
|
|
265 |
GLES30.glDrawArrays(GLES30.GL_LINES, 0, 2*mesh.numVertices);
|
|
261 |
GLES31.glUniformMatrix4fv(mNormalMVPMatrixH, 1, false, mM.getMVP() , 0);
|
|
262 |
GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, mesh.mAttTFO[0]);
|
|
263 |
GLES31.glVertexAttribPointer(mNormalProgram.mAttribute[0], MeshObject.POS_DATA_SIZE, GLES31.GL_FLOAT, false, 0, 0);
|
|
264 |
GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, 0);
|
|
265 |
GLES31.glLineWidth(8.0f);
|
|
266 |
GLES31.glDrawArrays(GLES31.GL_LINES, 0, 2*mesh.numVertices);
|
|
266 | 267 |
} |
267 | 268 |
|
268 | 269 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
276 | 277 |
mF.compute(currTime,halfW,halfH); |
277 | 278 |
mP.compute(currTime); |
278 | 279 |
|
279 |
GLES30.glViewport(0, 0, surface.mWidth, surface.mHeight );
|
|
280 |
GLES31.glViewport(0, 0, surface.mWidth, surface.mHeight );
|
|
280 | 281 |
|
281 | 282 |
mMainProgram.useProgram(); |
282 |
GLES30.glUniform1i(mMainTextureH, 0);
|
|
283 |
GLES31.glUniform1i(mMainTextureH, 0);
|
|
283 | 284 |
|
284 | 285 |
if( Distorted.GLSL >= 300 ) |
285 | 286 |
{ |
286 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mAttVBO[0]);
|
|
287 |
GLES30.glVertexAttribPointer(mMainProgram.mAttribute[0], MeshObject.POS_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET0);
|
|
288 |
GLES30.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NOR_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET1);
|
|
289 |
GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET2);
|
|
290 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0);
|
|
287 |
GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, mesh.mAttVBO[0]);
|
|
288 |
GLES31.glVertexAttribPointer(mMainProgram.mAttribute[0], MeshObject.POS_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET0);
|
|
289 |
GLES31.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NOR_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET1);
|
|
290 |
GLES31.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET2);
|
|
291 |
GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, 0);
|
|
291 | 292 |
} |
292 | 293 |
else |
293 | 294 |
{ |
294 | 295 |
mesh.mVertAttribs.position(0); |
295 |
GLES30.glVertexAttribPointer(mMainProgram.mAttribute[0], MeshObject.POS_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, mesh.mVertAttribs);
|
|
296 |
GLES31.glVertexAttribPointer(mMainProgram.mAttribute[0], MeshObject.POS_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, mesh.mVertAttribs);
|
|
296 | 297 |
mesh.mVertAttribs.position(MeshObject.POS_DATA_SIZE); |
297 |
GLES30.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NOR_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, mesh.mVertAttribs);
|
|
298 |
GLES31.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NOR_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, mesh.mVertAttribs);
|
|
298 | 299 |
mesh.mVertAttribs.position(MeshObject.POS_DATA_SIZE+MeshObject.NOR_DATA_SIZE); |
299 |
GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, mesh.mVertAttribs);
|
|
300 |
GLES31.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, mesh.mVertAttribs);
|
|
300 | 301 |
} |
301 | 302 |
|
302 | 303 |
mM.send(surface,halfW,halfH,halfZ,marginInPixels); |
303 | 304 |
mV.send(); |
304 | 305 |
mF.send(); |
305 | 306 |
|
306 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.numVertices);
|
|
307 |
GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, mesh.numVertices);
|
|
307 | 308 |
|
308 | 309 |
if( mesh.mShowNormals ) displayNormals(mesh); |
309 | 310 |
} |
... | ... | |
318 | 319 |
{ |
319 | 320 |
mBlitProgram.useProgram(); |
320 | 321 |
|
321 |
GLES30.glViewport(0, 0, surface.mWidth, surface.mHeight );
|
|
322 |
GLES30.glUniform1i(mBlitTextureH, 0);
|
|
323 |
GLES30.glUniform1f( mBlitDepthH , 1.0f-surface.mNear);
|
|
324 |
GLES30.glVertexAttribPointer(mBlitProgram.mAttribute[0], 2, GLES30.GL_FLOAT, false, 0, mQuadPositions);
|
|
325 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);
|
|
322 |
GLES31.glViewport(0, 0, surface.mWidth, surface.mHeight );
|
|
323 |
GLES31.glUniform1i(mBlitTextureH, 0);
|
|
324 |
GLES31.glUniform1f( mBlitDepthH , 1.0f-surface.mNear);
|
|
325 |
GLES31.glVertexAttribPointer(mBlitProgram.mAttribute[0], 2, GLES31.GL_FLOAT, false, 0, mQuadPositions);
|
|
326 |
GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, 4);
|
|
326 | 327 |
} |
327 | 328 |
|
328 | 329 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
331 | 332 |
{ |
332 | 333 |
mBlitDepthProgram.useProgram(); |
333 | 334 |
|
334 |
GLES30.glViewport(0, 0, surface.mWidth, surface.mHeight );
|
|
335 |
GLES30.glUniform1i(mBlitDepthTextureH, 0);
|
|
336 |
GLES30.glUniform1i(mBlitDepthDepthTextureH, 1);
|
|
337 |
GLES30.glUniform1f( mBlitDepthDepthH , 1.0f-surface.mNear);
|
|
338 |
GLES30.glVertexAttribPointer(mBlitDepthProgram.mAttribute[0], 2, GLES30.GL_FLOAT, false, 0, mQuadPositions);
|
|
339 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);
|
|
335 |
GLES31.glViewport(0, 0, surface.mWidth, surface.mHeight );
|
|
336 |
GLES31.glUniform1i(mBlitDepthTextureH, 0);
|
|
337 |
GLES31.glUniform1i(mBlitDepthDepthTextureH, 1);
|
|
338 |
GLES31.glUniform1f( mBlitDepthDepthH , 1.0f-surface.mNear);
|
|
339 |
GLES31.glVertexAttribPointer(mBlitDepthProgram.mAttribute[0], 2, GLES31.GL_FLOAT, false, 0, mQuadPositions);
|
|
340 |
GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, 4);
|
|
340 | 341 |
} |
341 | 342 |
|
342 | 343 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/library/main/DistortedFramebuffer.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.main; |
21 | 21 |
|
22 |
import android.opengl.GLES30;
|
|
22 |
import android.opengl.GLES31;
|
|
23 | 23 |
|
24 | 24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
25 | 25 |
/** |
... | ... | |
43 | 43 |
{ |
44 | 44 |
if( mColorCreated==NOT_CREATED_YET ) |
45 | 45 |
{ |
46 |
GLES30.glGenTextures( mNumColors, mColorH, 0);
|
|
47 |
GLES30.glGenFramebuffers(1, mFBOH, 0);
|
|
48 |
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFBOH[0]);
|
|
46 |
GLES31.glGenTextures( mNumColors, mColorH, 0);
|
|
47 |
GLES31.glGenFramebuffers(1, mFBOH, 0);
|
|
48 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[0]);
|
|
49 | 49 |
|
50 | 50 |
for(int i=0; i<mNumColors; i++) |
51 | 51 |
{ |
52 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[i]);
|
|
53 |
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_REPEAT);
|
|
54 |
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_REPEAT);
|
|
55 |
GLES30.glTexParameterf(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_NEAREST);
|
|
56 |
GLES30.glTexParameterf(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR);
|
|
57 |
GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, GLES30.GL_RGBA, mWidth, mHeight, 0, GLES30.GL_RGBA, GLES30.GL_UNSIGNED_BYTE, null);
|
|
52 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, mColorH[i]);
|
|
53 |
GLES31.glTexParameteri(GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_WRAP_S, GLES31.GL_REPEAT);
|
|
54 |
GLES31.glTexParameteri(GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_WRAP_T, GLES31.GL_REPEAT);
|
|
55 |
GLES31.glTexParameterf(GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_MIN_FILTER, GLES31.GL_NEAREST);
|
|
56 |
GLES31.glTexParameterf(GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_MAG_FILTER, GLES31.GL_LINEAR);
|
|
57 |
GLES31.glTexImage2D(GLES31.GL_TEXTURE_2D, 0, GLES31.GL_RGBA, mWidth, mHeight, 0, GLES31.GL_RGBA, GLES31.GL_UNSIGNED_BYTE, null);
|
|
58 | 58 |
} |
59 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, mColorH[0], 0);
|
|
60 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0);
|
|
61 |
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0);
|
|
59 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, mColorH[0], 0);
|
|
60 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0);
|
|
61 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, 0);
|
|
62 | 62 |
|
63 | 63 |
mColorCreated = checkStatus("color"); |
64 | 64 |
} |
65 | 65 |
if( mDepthStencilCreated==NOT_CREATED_YET ) // we need to create a new DEPTH or STENCIL attachment |
66 | 66 |
{ |
67 |
GLES30.glGenTextures(1, mDepthStencilH, 0);
|
|
68 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mDepthStencilH[0]);
|
|
69 |
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_REPEAT);
|
|
70 |
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_REPEAT);
|
|
71 |
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_NEAREST);
|
|
72 |
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_NEAREST);
|
|
67 |
GLES31.glGenTextures(1, mDepthStencilH, 0);
|
|
68 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, mDepthStencilH[0]);
|
|
69 |
GLES31.glTexParameteri(GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_WRAP_S, GLES31.GL_REPEAT);
|
|
70 |
GLES31.glTexParameteri(GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_WRAP_T, GLES31.GL_REPEAT);
|
|
71 |
GLES31.glTexParameteri(GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_MIN_FILTER, GLES31.GL_NEAREST);
|
|
72 |
GLES31.glTexParameteri(GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_MAG_FILTER, GLES31.GL_NEAREST);
|
|
73 | 73 |
|
74 | 74 |
if( mDepthStencil==DEPTH_NO_STENCIL ) |
75 | 75 |
{ |
76 |
GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, GLES30.GL_DEPTH_COMPONENT, mWidth, mHeight, 0, GLES30.GL_DEPTH_COMPONENT, GLES30.GL_UNSIGNED_INT, null);
|
|
76 |
GLES31.glTexImage2D(GLES31.GL_TEXTURE_2D, 0, GLES31.GL_DEPTH_COMPONENT, mWidth, mHeight, 0, GLES31.GL_DEPTH_COMPONENT, GLES31.GL_UNSIGNED_INT, null);
|
|
77 | 77 |
} |
78 | 78 |
else if( mDepthStencil==BOTH_DEPTH_STENCIL ) |
79 | 79 |
{ |
80 |
GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, GLES30.GL_DEPTH24_STENCIL8, mWidth, mHeight, 0, GLES30.GL_DEPTH_STENCIL, GLES30.GL_UNSIGNED_INT_24_8, null);
|
|
80 |
GLES31.glTexImage2D(GLES31.GL_TEXTURE_2D, 0, GLES31.GL_DEPTH24_STENCIL8, mWidth, mHeight, 0, GLES31.GL_DEPTH_STENCIL, GLES31.GL_UNSIGNED_INT_24_8, null);
|
|
81 | 81 |
} |
82 | 82 |
|
83 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0);
|
|
84 |
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFBOH[0]);
|
|
83 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0);
|
|
84 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[0]);
|
|
85 | 85 |
|
86 | 86 |
if( mDepthStencil==DEPTH_NO_STENCIL ) |
87 | 87 |
{ |
88 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_DEPTH_ATTACHMENT, GLES30.GL_TEXTURE_2D, mDepthStencilH[0], 0);
|
|
88 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_DEPTH_ATTACHMENT, GLES31.GL_TEXTURE_2D, mDepthStencilH[0], 0);
|
|
89 | 89 |
} |
90 | 90 |
else if( mDepthStencil==BOTH_DEPTH_STENCIL ) |
91 | 91 |
{ |
92 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_DEPTH_STENCIL_ATTACHMENT, GLES30.GL_TEXTURE_2D, mDepthStencilH[0], 0);
|
|
92 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_DEPTH_STENCIL_ATTACHMENT, GLES31.GL_TEXTURE_2D, mDepthStencilH[0], 0);
|
|
93 | 93 |
} |
94 | 94 |
|
95 |
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0);
|
|
95 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, 0);
|
|
96 | 96 |
|
97 | 97 |
mDepthStencilCreated = checkStatus("depth"); |
98 | 98 |
} |
... | ... | |
101 | 101 |
// OpenGL ES 3.0.5 spec, chapter 4.4.2.4 : |
102 | 102 |
// "Note that the texture image is specifically not detached from any other framebuffer objects. |
103 | 103 |
// Detaching the texture image from any other framebuffer objects is the responsibility of the application." |
104 |
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFBOH[0]);
|
|
105 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_DEPTH_ATTACHMENT , GLES30.GL_TEXTURE_2D, 0, 0);
|
|
106 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_DEPTH_STENCIL_ATTACHMENT, GLES30.GL_TEXTURE_2D, 0, 0);
|
|
107 |
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0);
|
|
104 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[0]);
|
|
105 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_DEPTH_ATTACHMENT , GLES31.GL_TEXTURE_2D, 0, 0);
|
|
106 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_DEPTH_STENCIL_ATTACHMENT, GLES31.GL_TEXTURE_2D, 0, 0);
|
|
107 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, 0);
|
|
108 | 108 |
|
109 |
GLES30.glDeleteTextures(1, mDepthStencilH, 0);
|
|
109 |
GLES31.glDeleteTextures(1, mDepthStencilH, 0);
|
|
110 | 110 |
mDepthStencilH[0]=0; |
111 | 111 |
} |
112 | 112 |
} |
... | ... | |
115 | 115 |
|
116 | 116 |
private int checkStatus(String message) |
117 | 117 |
{ |
118 |
int status = GLES30.glCheckFramebufferStatus(GLES30.GL_FRAMEBUFFER);
|
|
118 |
int status = GLES31.glCheckFramebufferStatus(GLES31.GL_FRAMEBUFFER);
|
|
119 | 119 |
|
120 |
if(status != GLES30.GL_FRAMEBUFFER_COMPLETE)
|
|
120 |
if(status != GLES31.GL_FRAMEBUFFER_COMPLETE)
|
|
121 | 121 |
{ |
122 | 122 |
android.util.Log.e("DistortedFramebuffer", "FRAMEBUFFER INCOMPLETE, "+message+" error="+status); |
123 | 123 |
|
124 |
GLES30.glDeleteTextures(1, mColorH, 0);
|
|
125 |
GLES30.glDeleteTextures(1, mDepthStencilH, 0);
|
|
126 |
GLES30.glDeleteFramebuffers(1, mFBOH, 0);
|
|
124 |
GLES31.glDeleteTextures(1, mColorH, 0);
|
|
125 |
GLES31.glDeleteTextures(1, mDepthStencilH, 0);
|
|
126 |
GLES31.glDeleteFramebuffers(1, mFBOH, 0);
|
|
127 | 127 |
mFBOH[0]= 0; |
128 | 128 |
|
129 | 129 |
return FAILED_TO_CREATE; |
... | ... | |
139 | 139 |
{ |
140 | 140 |
if( mColorH[0]>0 ) |
141 | 141 |
{ |
142 |
GLES30.glDeleteTextures(1, mColorH, 0);
|
|
142 |
GLES31.glDeleteTextures(1, mColorH, 0);
|
|
143 | 143 |
mColorH[0] = 0; |
144 | 144 |
mColorCreated = NOT_CREATED_YET; |
145 | 145 |
} |
146 | 146 |
|
147 | 147 |
if( mDepthStencilH[0]>0 ) |
148 | 148 |
{ |
149 |
GLES30.glDeleteTextures(1, mDepthStencilH, 0);
|
|
149 |
GLES31.glDeleteTextures(1, mDepthStencilH, 0);
|
|
150 | 150 |
mDepthStencilH[0]=0; |
151 | 151 |
mDepthStencilCreated = NOT_CREATED_YET; |
152 | 152 |
} |
153 | 153 |
|
154 |
GLES30.glDeleteFramebuffers(1, mFBOH, 0);
|
|
154 |
GLES31.glDeleteFramebuffers(1, mFBOH, 0);
|
|
155 | 155 |
mFBOH[0] = 0; |
156 | 156 |
} |
157 | 157 |
|
... | ... | |
225 | 225 |
{ |
226 | 226 |
if( mColorH[0]>0 ) |
227 | 227 |
{ |
228 |
GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
|
|
229 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[0]);
|
|
228 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE0);
|
|
229 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, mColorH[0]);
|
|
230 | 230 |
return true; |
231 | 231 |
} |
232 | 232 |
|
... | ... | |
243 | 243 |
{ |
244 | 244 |
if( texture>=0 && texture<mNumColors && mColorH[texture]>0 ) |
245 | 245 |
{ |
246 |
GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
|
|
247 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[texture]);
|
|
246 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE0);
|
|
247 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, mColorH[texture]);
|
|
248 | 248 |
return true; |
249 | 249 |
} |
250 | 250 |
|
... | ... | |
257 | 257 |
{ |
258 | 258 |
if( texture>=0 && texture<mNumColors && mColorH[texture]>0 ) |
259 | 259 |
{ |
260 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, mColorH[texture], 0);
|
|
260 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, mColorH[texture], 0);
|
|
261 | 261 |
} |
262 | 262 |
} |
263 | 263 |
|
src/main/java/org/distorted/library/main/DistortedOutputSurface.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.main; |
21 | 21 |
|
22 |
import android.opengl.GLES30;
|
|
22 |
import android.opengl.GLES31;
|
|
23 | 23 |
import android.opengl.Matrix; |
24 | 24 |
|
25 | 25 |
import org.distorted.library.effect.EffectQuality; |
... | ... | |
128 | 128 |
|
129 | 129 |
mClearDepth = 1.0f; |
130 | 130 |
mClearStencil = 0; |
131 |
mClear = GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT;
|
|
131 |
mClear = GLES31.GL_DEPTH_BUFFER_BIT | GLES31.GL_COLOR_BUFFER_BIT;
|
|
132 | 132 |
|
133 | 133 |
mBuffer = new DistortedOutputSurface[1+EffectQuality.LENGTH]; |
134 | 134 |
|
... | ... | |
194 | 194 |
|
195 | 195 |
DistortedObject.toDo(); // create the FBOs immediately. This is safe as we must be holding the OpenGL context now. |
196 | 196 |
|
197 |
GLES30.glStencilMask(0xff);
|
|
198 |
GLES30.glDepthMask(true);
|
|
199 |
GLES30.glColorMask(true,true,true,true);
|
|
200 |
GLES30.glClearColor(0.0f,0.0f,0.0f,0.0f);
|
|
201 |
GLES30.glClearDepthf(1.0f);
|
|
202 |
GLES30.glClearStencil(0);
|
|
197 |
GLES31.glStencilMask(0xff);
|
|
198 |
GLES31.glDepthMask(true);
|
|
199 |
GLES31.glColorMask(true,true,true,true);
|
|
200 |
GLES31.glClearColor(0.0f,0.0f,0.0f,0.0f);
|
|
201 |
GLES31.glClearDepthf(1.0f);
|
|
202 |
GLES31.glClearStencil(0);
|
|
203 | 203 |
|
204 | 204 |
for(int j=0; j<EffectQuality.LENGTH; j++) |
205 | 205 |
{ |
206 | 206 |
mBuffer[j].setAsOutput(); |
207 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, mBuffer[j].mColorH[1], 0);
|
|
208 |
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT|GLES30.GL_DEPTH_BUFFER_BIT|GLES30.GL_STENCIL_BUFFER_BIT);
|
|
209 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, mBuffer[j].mColorH[0], 0);
|
|
210 |
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT);
|
|
207 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, mBuffer[j].mColorH[1], 0);
|
|
208 |
GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT|GLES31.GL_DEPTH_BUFFER_BIT|GLES31.GL_STENCIL_BUFFER_BIT);
|
|
209 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, mBuffer[j].mColorH[0], 0);
|
|
210 |
GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT);
|
|
211 | 211 |
} |
212 | 212 |
} |
213 | 213 |
|
... | ... | |
215 | 215 |
|
216 | 216 |
private int blitWithDepth(long currTime, DistortedOutputSurface buffer) |
217 | 217 |
{ |
218 |
GLES30.glViewport(0, 0, mWidth, mHeight);
|
|
218 |
GLES31.glViewport(0, 0, mWidth, mHeight);
|
|
219 | 219 |
setAsOutput(currTime); |
220 |
GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
|
|
221 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, buffer.mColorH[0]);
|
|
222 |
GLES30.glActiveTexture(GLES30.GL_TEXTURE1);
|
|
223 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, buffer.mDepthStencilH[0]);
|
|
220 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE0);
|
|
221 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, buffer.mColorH[0]);
|
|
222 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE1);
|
|
223 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, buffer.mDepthStencilH[0]);
|
|
224 | 224 |
|
225 |
GLES30.glDisable(GLES30.GL_STENCIL_TEST);
|
|
226 |
GLES30.glStencilMask(0x00);
|
|
225 |
GLES31.glDisable(GLES31.GL_STENCIL_TEST);
|
|
226 |
GLES31.glStencilMask(0x00);
|
|
227 | 227 |
|
228 | 228 |
DistortedEffects.blitDepthPriv(this); |
229 |
GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
|
|
230 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0);
|
|
231 |
GLES30.glActiveTexture(GLES30.GL_TEXTURE1);
|
|
232 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0);
|
|
229 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE0);
|
|
230 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0);
|
|
231 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE1);
|
|
232 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0);
|
|
233 | 233 |
|
234 | 234 |
// clear buffers |
235 |
GLES30.glStencilMask(0xff);
|
|
236 |
GLES30.glDepthMask(true);
|
|
237 |
GLES30.glColorMask(true,true,true,true);
|
|
238 |
GLES30.glClearColor(0.0f,0.0f,0.0f,0.0f);
|
|
239 |
GLES30.glClearDepthf(1.0f);
|
|
240 |
GLES30.glClearStencil(0);
|
|
235 |
GLES31.glStencilMask(0xff);
|
|
236 |
GLES31.glDepthMask(true);
|
|
237 |
GLES31.glColorMask(true,true,true,true);
|
|
238 |
GLES31.glClearColor(0.0f,0.0f,0.0f,0.0f);
|
|
239 |
GLES31.glClearDepthf(1.0f);
|
|
240 |
GLES31.glClearStencil(0);
|
|
241 | 241 |
|
242 | 242 |
buffer.setAsOutput(); |
243 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, buffer.mColorH[1], 0);
|
|
244 |
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT|GLES30.GL_DEPTH_BUFFER_BIT|GLES30.GL_STENCIL_BUFFER_BIT);
|
|
245 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, buffer.mColorH[0], 0);
|
|
246 |
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT);
|
|
243 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, buffer.mColorH[1], 0);
|
|
244 |
GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT|GLES31.GL_DEPTH_BUFFER_BIT|GLES31.GL_STENCIL_BUFFER_BIT);
|
|
245 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, buffer.mColorH[0], 0);
|
|
246 |
GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT);
|
|
247 | 247 |
|
248 | 248 |
return 1; |
249 | 249 |
} |
... | ... | |
410 | 410 |
*/ |
411 | 411 |
public void setAsOutput(long time) |
412 | 412 |
{ |
413 |
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFBOH[0]);
|
|
413 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[0]);
|
|
414 | 414 |
|
415 | 415 |
if( mTime!=time ) |
416 | 416 |
{ |
417 | 417 |
mTime = time; |
418 | 418 |
DistortedRenderState.colorDepthStencilOn(); |
419 |
GLES30.glClearColor(mClearR, mClearG, mClearB, mClearA);
|
|
420 |
GLES30.glClearDepthf(mClearDepth);
|
|
421 |
GLES30.glClearStencil(mClearStencil);
|
|
422 |
GLES30.glClear(mClear);
|
|
419 |
GLES31.glClearColor(mClearR, mClearG, mClearB, mClearA);
|
|
420 |
GLES31.glClearDepthf(mClearDepth);
|
|
421 |
GLES31.glClearStencil(mClearStencil);
|
|
422 |
GLES31.glClear(mClear);
|
|
423 | 423 |
DistortedRenderState.colorDepthStencilRestore(); |
424 | 424 |
} |
425 | 425 |
} |
... | ... | |
433 | 433 |
|
434 | 434 |
public void setAsOutput() |
435 | 435 |
{ |
436 |
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFBOH[0]);
|
|
436 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[0]);
|
|
437 | 437 |
} |
438 | 438 |
|
439 | 439 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
473 | 473 |
|
474 | 474 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
475 | 475 |
/** |
476 |
* Set the (R,G,B,A) values of GLES30.glClearColor() to set up color with which to clear
|
|
476 |
* Set the (R,G,B,A) values of GLES31.glClearColor() to set up color with which to clear
|
|
477 | 477 |
* this Surface at the beginning of each frame. |
478 | 478 |
* |
479 | 479 |
* @param r the Red component. Default: 0.0f |
src/main/java/org/distorted/library/main/DistortedRenderState.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.main; |
21 | 21 |
|
22 |
import android.opengl.GLES30;
|
|
22 |
import android.opengl.GLES31;
|
|
23 | 23 |
|
24 | 24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
25 | 25 |
/** |
... | ... | |
71 | 71 |
|
72 | 72 |
mState.depthTest = 1; |
73 | 73 |
mState.depthMask = 1; |
74 |
mState.depthFunc = GLES30.GL_LEQUAL;
|
|
74 |
mState.depthFunc = GLES31.GL_LEQUAL;
|
|
75 | 75 |
|
76 | 76 |
mState.blend = 1; |
77 |
mState.blendSrc = GLES30.GL_SRC_ALPHA;
|
|
78 |
mState.blendDst = GLES30.GL_ONE_MINUS_SRC_ALPHA;
|
|
77 |
mState.blendSrc = GLES31.GL_SRC_ALPHA;
|
|
78 |
mState.blendDst = GLES31.GL_ONE_MINUS_SRC_ALPHA;
|
|
79 | 79 |
|
80 | 80 |
mState.stencilTest = 0; |
81 | 81 |
mState.stencilMask = STENCIL_MASK; |
82 |
mState.stencilFuncFunc = GLES30.GL_NEVER;
|
|
82 |
mState.stencilFuncFunc = GLES31.GL_NEVER;
|
|
83 | 83 |
mState.stencilFuncRef = 0; |
84 | 84 |
mState.stencilFuncMask = STENCIL_MASK; |
85 |
mState.stencilOpSfail = GLES30.GL_KEEP;
|
|
86 |
mState.stencilOpDpfail = GLES30.GL_KEEP;
|
|
87 |
mState.stencilOpDppass = GLES30.GL_KEEP;
|
|
85 |
mState.stencilOpSfail = GLES31.GL_KEEP;
|
|
86 |
mState.stencilOpDpfail = GLES31.GL_KEEP;
|
|
87 |
mState.stencilOpDppass = GLES31.GL_KEEP;
|
|
88 | 88 |
|
89 | 89 |
mClear = 0; |
90 | 90 |
} |
... | ... | |
98 | 98 |
cState.colorMaskG = 1; |
99 | 99 |
cState.colorMaskB = 1; |
100 | 100 |
cState.colorMaskA = 1; |
101 |
GLES30.glColorMask(true,true,true,true);
|
|
101 |
GLES31.glColorMask(true,true,true,true);
|
|
102 | 102 |
|
103 | 103 |
cState.depthTest = 1; |
104 | 104 |
cState.depthMask = 1; |
105 |
cState.depthFunc = GLES30.GL_LEQUAL;
|
|
106 |
GLES30.glEnable(GLES30.GL_DEPTH_TEST);
|
|
107 |
GLES30.glDepthMask(true);
|
|
108 |
GLES30.glDepthFunc(cState.depthFunc);
|
|
105 |
cState.depthFunc = GLES31.GL_LEQUAL;
|
|
106 |
GLES31.glEnable(GLES31.GL_DEPTH_TEST);
|
|
107 |
GLES31.glDepthMask(true);
|
|
108 |
GLES31.glDepthFunc(cState.depthFunc);
|
|
109 | 109 |
|
110 | 110 |
cState.stencilTest = 0; |
111 | 111 |
cState.stencilMask = STENCIL_MASK; |
112 |
cState.stencilFuncFunc = GLES30.GL_NEVER;
|
|
112 |
cState.stencilFuncFunc = GLES31.GL_NEVER;
|
|
113 | 113 |
cState.stencilFuncRef = 0; |
114 | 114 |
cState.stencilFuncMask = STENCIL_MASK; |
115 |
cState.stencilOpSfail = GLES30.GL_KEEP;
|
|
116 |
cState.stencilOpDpfail = GLES30.GL_KEEP;
|
|
117 |
cState.stencilOpDppass = GLES30.GL_KEEP;
|
|
118 |
GLES30.glDisable(GLES30.GL_STENCIL_TEST);
|
|
119 |
GLES30.glStencilMask(cState.stencilMask);
|
|
115 |
cState.stencilOpSfail = GLES31.GL_KEEP;
|
|
116 |
cState.stencilOpDpfail = GLES31.GL_KEEP;
|
|
117 |
cState.stencilOpDppass = GLES31.GL_KEEP;
|
|
118 |
GLES31.glDisable(GLES31.GL_STENCIL_TEST);
|
|
119 |
GLES31.glStencilMask(cState.stencilMask);
|
|
120 | 120 |
|
121 | 121 |
cState.blend = 1; |
122 |
cState.blendSrc = GLES30.GL_SRC_ALPHA;
|
|
123 |
cState.blendDst = GLES30.GL_ONE_MINUS_SRC_ALPHA;
|
|
124 |
GLES30.glEnable(GLES30.GL_BLEND);
|
|
125 |
GLES30.glBlendFunc(cState.blendSrc,cState.blendDst);
|
|
122 |
cState.blendSrc = GLES31.GL_SRC_ALPHA;
|
|
123 |
cState.blendDst = GLES31.GL_ONE_MINUS_SRC_ALPHA;
|
|
124 |
GLES31.glEnable(GLES31.GL_BLEND);
|
|
125 |
GLES31.glBlendFunc(cState.blendSrc,cState.blendDst);
|
|
126 | 126 |
} |
127 | 127 |
|
128 | 128 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
140 | 140 |
cState.colorMaskG = 1; |
141 | 141 |
cState.colorMaskB = 1; |
142 | 142 |
cState.colorMaskA = 1; |
143 |
GLES30.glColorMask(true,true,true,true);
|
|
143 |
GLES31.glColorMask(true,true,true,true);
|
|
144 | 144 |
} |
145 | 145 |
|
146 | 146 |
sState.depthMask = cState.depthMask; |
... | ... | |
148 | 148 |
if( cState.depthMask!=1 ) |
149 | 149 |
{ |
150 | 150 |
cState.depthMask = 1; |
151 |
GLES30.glDepthMask(true);
|
|
151 |
GLES31.glDepthMask(true);
|
|
152 | 152 |
} |
153 | 153 |
|
154 | 154 |
sState.stencilMask = cState.stencilMask; |
... | ... | |
156 | 156 |
if( cState.stencilMask!= STENCIL_MASK ) |
157 | 157 |
{ |
158 | 158 |
cState.stencilMask = STENCIL_MASK; |
159 |
GLES30.glStencilMask(cState.stencilMask);
|
|
159 |
GLES31.glStencilMask(cState.stencilMask);
|
|
160 | 160 |
} |
161 | 161 |
} |
162 | 162 |
|
... | ... | |
170 | 170 |
cState.colorMaskG = sState.colorMaskG; |
171 | 171 |
cState.colorMaskB = sState.colorMaskB; |
172 | 172 |
cState.colorMaskA = sState.colorMaskA; |
173 |
GLES30.glColorMask(cState.colorMaskR==1,cState.colorMaskG==1,cState.colorMaskB==1,cState.colorMaskA==1);
|
|
173 |
GLES31.glColorMask(cState.colorMaskR==1,cState.colorMaskG==1,cState.colorMaskB==1,cState.colorMaskA==1);
|
|
174 | 174 |
} |
175 | 175 |
if( sState.depthMask!=cState.depthMask ) |
176 | 176 |
{ |
177 | 177 |
cState.depthMask = sState.depthMask; |
178 |
GLES30.glDepthMask(cState.depthMask==1);
|
|
178 |
GLES31.glDepthMask(cState.depthMask==1);
|
|
179 | 179 |
} |
180 | 180 |
if( sState.stencilMask!=cState.stencilMask ) |
181 | 181 |
{ |
182 | 182 |
cState.stencilMask = sState.stencilMask; |
183 |
GLES30.glStencilMask(cState.stencilMask);
|
|
183 |
GLES31.glStencilMask(cState.stencilMask);
|
|
184 | 184 |
} |
185 | 185 |
} |
186 | 186 |
|
... | ... | |
188 | 188 |
|
189 | 189 |
static void switchOffDrawing() |
190 | 190 |
{ |
191 |
GLES30.glEnable(GLES30.GL_SCISSOR_TEST);
|
|
192 |
GLES30.glScissor(0,0,0,0);
|
|
191 |
GLES31.glEnable(GLES31.GL_SCISSOR_TEST);
|
|
192 |
GLES31.glScissor(0,0,0,0);
|
|
193 | 193 |
} |
194 | 194 |
|
195 | 195 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
196 | 196 |
|
197 | 197 |
static void restoreDrawing() |
198 | 198 |
{ |
199 |
GLES30.glDisable(GLES30.GL_SCISSOR_TEST);
|
|
199 |
GLES31.glDisable(GLES31.GL_SCISSOR_TEST);
|
|
200 | 200 |
} |
201 | 201 |
|
202 | 202 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
209 | 209 |
{ |
210 | 210 |
cState.stencilTest = 1; |
211 | 211 |
//android.util.Log.d("State", "stencil test on"); |
212 |
GLES30.glEnable(GLES30.GL_STENCIL_TEST);
|
|
212 |
GLES31.glEnable(GLES31.GL_STENCIL_TEST);
|
|
213 | 213 |
} |
214 | 214 |
|
215 | 215 |
sState.stencilFuncFunc = cState.stencilFuncFunc; |
216 | 216 |
sState.stencilFuncRef = cState.stencilFuncRef; |
217 | 217 |
sState.stencilFuncMask = cState.stencilFuncMask; |
218 | 218 |
|
219 |
if( cState.stencilFuncFunc!=GLES30.GL_ALWAYS || cState.stencilFuncRef!=1 || cState.stencilFuncMask!=STENCIL_MASK )
|
|
219 |
if( cState.stencilFuncFunc!=GLES31.GL_ALWAYS || cState.stencilFuncRef!=1 || cState.stencilFuncMask!=STENCIL_MASK )
|
|
220 | 220 |
{ |
221 |
cState.stencilFuncFunc = GLES30.GL_ALWAYS;
|
|
221 |
cState.stencilFuncFunc = GLES31.GL_ALWAYS;
|
|
222 | 222 |
cState.stencilFuncRef = 1; |
223 | 223 |
cState.stencilFuncMask = STENCIL_MASK; |
224 | 224 |
//android.util.Log.d("State", "stencil func on"); |
225 |
GLES30.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
225 |
GLES31.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
226 | 226 |
} |
227 | 227 |
|
228 | 228 |
sState.stencilOpSfail = cState.stencilOpSfail; |
229 | 229 |
sState.stencilOpDpfail= cState.stencilOpDpfail; |
230 | 230 |
sState.stencilOpDppass= cState.stencilOpDppass; |
231 | 231 |
|
232 |
if( cState.stencilOpSfail!=GLES30.GL_KEEP || cState.stencilOpDpfail!=GLES30.GL_KEEP || cState.stencilOpDppass!=GLES30.GL_REPLACE )
|
|
232 |
if( cState.stencilOpSfail!=GLES31.GL_KEEP || cState.stencilOpDpfail!=GLES31.GL_KEEP || cState.stencilOpDppass!=GLES31.GL_REPLACE )
|
|
233 | 233 |
{ |
234 |
cState.stencilOpSfail = GLES30.GL_KEEP;
|
|
235 |
cState.stencilOpDpfail= GLES30.GL_KEEP;
|
|
236 |
cState.stencilOpDppass= GLES30.GL_REPLACE;
|
|
234 |
cState.stencilOpSfail = GLES31.GL_KEEP;
|
|
235 |
cState.stencilOpDpfail= GLES31.GL_KEEP;
|
|
236 |
cState.stencilOpDppass= GLES31.GL_REPLACE;
|
|
237 | 237 |
//android.util.Log.d("State", "stencil op on"); |
238 |
GLES30.glStencilOp(cState.stencilOpSfail,cState.stencilOpDpfail,cState.stencilOpDppass);
|
|
238 |
GLES31.glStencilOp(cState.stencilOpSfail,cState.stencilOpDpfail,cState.stencilOpDppass);
|
|
239 | 239 |
} |
240 | 240 |
|
241 | 241 |
sState.colorMaskR = cState.colorMaskR; |
... | ... | |
250 | 250 |
cState.colorMaskB = 0; |
251 | 251 |
cState.colorMaskA = 0; |
252 | 252 |
//android.util.Log.d("State", "switch off color writing"); |
253 |
GLES30.glColorMask(false,false,false,false);
|
|
253 |
GLES31.glColorMask(false,false,false,false);
|
|
254 | 254 |
} |
255 | 255 |
|
256 | 256 |
sState.depthMask = cState.depthMask; |
... | ... | |
259 | 259 |
{ |
260 | 260 |
cState.depthMask = 1; |
261 | 261 |
//android.util.Log.d("State", "switch on depth writing"); |
262 |
GLES30.glDepthMask(true);
|
|
262 |
GLES31.glDepthMask(true);
|
|
263 | 263 |
} |
264 | 264 |
|
265 | 265 |
sState.stencilMask = cState.stencilMask; |
... | ... | |
268 | 268 |
{ |
269 | 269 |
cState.stencilMask = STENCIL_MASK; |
270 | 270 |
//android.util.Log.d("State", "stencil mask on"); |
271 |
GLES30.glStencilMask(cState.stencilMask);
|
|
271 |
GLES31.glStencilMask(cState.stencilMask);
|
|
272 | 272 |
} |
273 | 273 |
} |
274 | 274 |
|
... | ... | |
282 | 282 |
|
283 | 283 |
if (cState.stencilTest == 0) |
284 | 284 |
{ |
285 |
GLES30.glDisable(GLES30.GL_STENCIL_TEST);
|
|
285 |
GLES31.glDisable(GLES31.GL_STENCIL_TEST);
|
|
286 | 286 |
} |
287 | 287 |
else |
288 | 288 |
{ |
289 |
GLES30.glEnable(GLES30.GL_STENCIL_TEST);
|
|
289 |
GLES31.glEnable(GLES31.GL_STENCIL_TEST);
|
|
290 | 290 |
} |
291 | 291 |
} |
292 | 292 |
if( sState.colorMaskR!=cState.colorMaskR || sState.colorMaskG!=cState.colorMaskG || sState.colorMaskB!=cState.colorMaskB || sState.colorMaskA!=cState.colorMaskA) |
... | ... | |
295 | 295 |
cState.colorMaskG = sState.colorMaskG; |
296 | 296 |
cState.colorMaskB = sState.colorMaskB; |
297 | 297 |
cState.colorMaskA = sState.colorMaskA; |
298 |
GLES30.glColorMask(cState.colorMaskR==1,cState.colorMaskG==1,cState.colorMaskB==1,cState.colorMaskA==1);
|
|
298 |
GLES31.glColorMask(cState.colorMaskR==1,cState.colorMaskG==1,cState.colorMaskB==1,cState.colorMaskA==1);
|
|
299 | 299 |
} |
300 | 300 |
if( sState.depthMask!=cState.depthMask ) |
301 | 301 |
{ |
302 | 302 |
cState.depthMask = sState.depthMask; |
303 |
GLES30.glDepthMask(cState.depthMask==1);
|
|
303 |
GLES31.glDepthMask(cState.depthMask==1);
|
|
304 | 304 |
} |
305 | 305 |
if( sState.stencilMask!=cState.stencilMask ) |
306 | 306 |
{ |
307 | 307 |
cState.stencilMask = sState.stencilMask; |
308 |
GLES30.glStencilMask(cState.stencilMask);
|
|
308 |
GLES31.glStencilMask(cState.stencilMask);
|
|
309 | 309 |
} |
310 | 310 |
} |
311 | 311 |
|
... | ... | |
322 | 322 |
if( cState.stencilTest!=1 ) |
323 | 323 |
{ |
324 | 324 |
cState.stencilTest = 1; |
325 |
GLES30.glEnable(GLES30.GL_STENCIL_TEST);
|
|
325 |
GLES31.glEnable(GLES31.GL_STENCIL_TEST);
|
|
326 | 326 |
} |
327 | 327 |
|
328 | 328 |
sState.stencilFuncFunc = cState.stencilFuncFunc; |
329 | 329 |
sState.stencilFuncRef = cState.stencilFuncRef; |
330 | 330 |
sState.stencilFuncMask = cState.stencilFuncMask; |
331 | 331 |
|
332 |
if( cState.stencilFuncFunc!=GLES30.GL_EQUAL || cState.stencilFuncRef!=1 || cState.stencilFuncMask!=STENCIL_MASK )
|
|
332 |
if( cState.stencilFuncFunc!=GLES31.GL_EQUAL || cState.stencilFuncRef!=1 || cState.stencilFuncMask!=STENCIL_MASK )
|
|
333 | 333 |
{ |
334 |
cState.stencilFuncFunc = GLES30.GL_EQUAL;
|
|
334 |
cState.stencilFuncFunc = GLES31.GL_EQUAL;
|
|
335 | 335 |
cState.stencilFuncRef = 1; |
336 | 336 |
cState.stencilFuncMask = STENCIL_MASK; |
337 |
GLES30.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
337 |
GLES31.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
338 | 338 |
} |
339 | 339 |
|
340 | 340 |
sState.stencilMask = cState.stencilMask; |
... | ... | |
342 | 342 |
if( cState.stencilMask!= 0x00 ) |
343 | 343 |
{ |
344 | 344 |
cState.stencilMask = 0x00; |
345 |
GLES30.glStencilMask(cState.stencilMask);
|
|
345 |
GLES31.glStencilMask(cState.stencilMask);
|
|
346 | 346 |
} |
347 | 347 |
|
348 | 348 |
sState.depthMask = cState.depthMask; |
... | ... | |
350 | 350 |
if( cState.depthMask!=0 ) |
351 | 351 |
{ |
352 | 352 |
cState.depthMask = 0; |
353 |
GLES30.glDepthMask(false);
|
|
353 |
GLES31.glDepthMask(false);
|
|
354 | 354 |
} |
355 | 355 |
|
356 | 356 |
sState.depthTest = cState.depthTest; |
... | ... | |
358 | 358 |
if( cState.depthTest!=0 ) |
359 | 359 |
{ |
360 | 360 |
cState.depthTest = 0; |
361 |
GLES30.glDisable(GLES30.GL_DEPTH_TEST);
|
|
361 |
GLES31.glDisable(GLES31.GL_DEPTH_TEST);
|
|
362 | 362 |
} |
363 | 363 |
} |
364 | 364 |
|
... | ... | |
376 | 376 |
|
377 | 377 |
if (cState.stencilTest == 0) |
378 | 378 |
{ |
379 |
GLES30.glDisable(GLES30.GL_STENCIL_TEST);
|
|
379 |
GLES31.glDisable(GLES31.GL_STENCIL_TEST);
|
|
380 | 380 |
} |
381 | 381 |
else |
382 | 382 |
{ |
383 |
GLES30.glEnable(GLES30.GL_STENCIL_TEST);
|
|
383 |
GLES31.glEnable(GLES31.GL_STENCIL_TEST);
|
|
384 | 384 |
} |
385 | 385 |
} |
386 | 386 |
if( sState.stencilFuncFunc!=cState.stencilFuncFunc || sState.stencilFuncRef!=cState.stencilFuncRef || sState.stencilFuncMask!=cState.stencilFuncMask ) |
... | ... | |
388 | 388 |
cState.stencilFuncFunc = sState.stencilFuncFunc; |
389 | 389 |
cState.stencilFuncRef = sState.stencilFuncRef ; |
390 | 390 |
cState.stencilFuncMask = sState.stencilFuncMask; |
391 |
GLES30.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
391 |
GLES31.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
392 | 392 |
} |
393 | 393 |
if( sState.stencilMask!=cState.stencilMask ) |
394 | 394 |
{ |
395 | 395 |
cState.stencilMask = sState.stencilMask; |
396 |
GLES30.glStencilMask(cState.stencilMask);
|
|
396 |
GLES31.glStencilMask(cState.stencilMask);
|
|
397 | 397 |
} |
398 | 398 |
if( sState.depthMask!=cState.depthMask ) |
399 | 399 |
{ |
400 | 400 |
cState.depthMask = sState.depthMask; |
401 |
GLES30.glDepthMask(cState.depthMask==1);
|
|
401 |
GLES31.glDepthMask(cState.depthMask==1);
|
|
402 | 402 |
} |
403 | 403 |
if( sState.depthTest!=cState.depthTest ) |
404 | 404 |
{ |
... | ... | |
406 | 406 |
|
407 | 407 |
if (cState.depthTest == 0) |
408 | 408 |
{ |
409 |
GLES30.glDisable(GLES30.GL_DEPTH_TEST);
|
|
409 |
GLES31.glDisable(GLES31.GL_DEPTH_TEST);
|
|
410 | 410 |
} |
411 | 411 |
else |
412 | 412 |
{ |
413 |
GLES30.glEnable(GLES30.GL_DEPTH_TEST);
|
|
413 |
GLES31.glEnable(GLES31.GL_DEPTH_TEST);
|
|
414 | 414 |
} |
415 | 415 |
} |
416 | 416 |
} |
... | ... | |
430 | 430 |
cState.colorMaskG = mState.colorMaskG; |
431 | 431 |
cState.colorMaskB = mState.colorMaskB; |
432 | 432 |
cState.colorMaskA = mState.colorMaskA; |
433 |
GLES30.glColorMask(cState.colorMaskR==1,cState.colorMaskG==1,cState.colorMaskB==1,cState.colorMaskA==1);
|
|
433 |
GLES31.glColorMask(cState.colorMaskR==1,cState.colorMaskG==1,cState.colorMaskB==1,cState.colorMaskA==1);
|
|
434 | 434 |
} |
435 | 435 |
|
436 | 436 |
///////////////////////////////////////////////////// |
... | ... | |
442 | 442 |
if (cState.depthTest == 0) |
443 | 443 |
{ |
444 | 444 |
//android.util.Log.d("State", "disabling depth test"); |
445 |
GLES30.glDisable(GLES30.GL_DEPTH_TEST);
|
|
445 |
GLES31.glDisable(GLES31.GL_DEPTH_TEST);
|
|
446 | 446 |
} |
447 | 447 |
else |
448 | 448 |
{ |
449 | 449 |
//android.util.Log.d("State", "enable depth test"); |
450 |
GLES30.glEnable(GLES30.GL_DEPTH_TEST);
|
|
450 |
GLES31.glEnable(GLES31.GL_DEPTH_TEST);
|
|
451 | 451 |
} |
452 | 452 |
} |
453 | 453 |
|
... | ... | |
457 | 457 |
{ |
458 | 458 |
//android.util.Log.d("State", "setting depth func"); |
459 | 459 |
cState.depthFunc = mState.depthFunc; |
460 |
GLES30.glDepthFunc(cState.depthFunc);
|
|
460 |
GLES31.glDepthFunc(cState.depthFunc);
|
|
461 | 461 |
} |
462 | 462 |
|
463 | 463 |
///////////////////////////////////////////////////// |
... | ... | |
466 | 466 |
{ |
467 | 467 |
//android.util.Log.d("State", "setting depth mask"); |
468 | 468 |
cState.depthMask = mState.depthMask; |
469 |
GLES30.glDepthMask(cState.depthMask==1);
|
|
469 |
GLES31.glDepthMask(cState.depthMask==1);
|
|
470 | 470 |
} |
471 | 471 |
|
472 | 472 |
///////////////////////////////////////////////////// |
... | ... | |
478 | 478 |
if (cState.blend == 0) |
479 | 479 |
{ |
480 | 480 |
//android.util.Log.d("State", "disabling blending"); |
481 |
GLES30.glDisable(GLES30.GL_BLEND);
|
|
481 |
GLES31.glDisable(GLES31.GL_BLEND);
|
|
482 | 482 |
} |
483 | 483 |
else |
484 | 484 |
{ |
485 | 485 |
//android.util.Log.d("State", "enabling blending"); |
486 |
GLES30.glEnable(GLES30.GL_BLEND);
|
|
486 |
GLES31.glEnable(GLES31.GL_BLEND);
|
|
487 | 487 |
} |
488 | 488 |
} |
489 | 489 |
|
... | ... | |
494 | 494 |
//android.util.Log.d("State", "setting blend function"); |
495 | 495 |
cState.blendSrc = mState.blendSrc; |
496 | 496 |
cState.blendDst = mState.blendDst; |
497 |
GLES30.glBlendFunc(cState.blendSrc,cState.blendDst);
|
|
497 |
GLES31.glBlendFunc(cState.blendSrc,cState.blendDst);
|
|
498 | 498 |
} |
499 | 499 |
|
500 | 500 |
///////////////////////////////////////////////////// |
... | ... | |
506 | 506 |
if (cState.stencilTest == 0) |
507 | 507 |
{ |
508 | 508 |
//android.util.Log.d("State", "disabling stencil test"); |
509 |
GLES30.glDisable(GLES30.GL_STENCIL_TEST);
|
|
509 |
GLES31.glDisable(GLES31.GL_STENCIL_TEST);
|
|
510 | 510 |
} |
511 | 511 |
else |
512 | 512 |
{ |
513 | 513 |
//android.util.Log.d("State", "enabling stencil test"); |
514 |
GLES30.glEnable(GLES30.GL_STENCIL_TEST);
|
|
514 |
GLES31.glEnable(GLES31.GL_STENCIL_TEST);
|
|
515 | 515 |
} |
516 | 516 |
} |
517 | 517 |
|
... | ... | |
523 | 523 |
cState.stencilFuncFunc = mState.stencilFuncFunc; |
524 | 524 |
cState.stencilFuncRef = mState.stencilFuncRef ; |
525 | 525 |
cState.stencilFuncMask = mState.stencilFuncMask; |
526 |
GLES30.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
526 |
GLES31.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
527 | 527 |
} |
528 | 528 |
|
529 | 529 |
///////////////////////////////////////////////////// |
... | ... | |
534 | 534 |
cState.stencilOpSfail = mState.stencilOpSfail; |
535 | 535 |
cState.stencilOpDpfail= mState.stencilOpDpfail; |
536 | 536 |
cState.stencilOpDppass= mState.stencilOpDppass; |
537 |
GLES30.glStencilOp(cState.stencilOpSfail,cState.stencilOpDpfail,cState.stencilOpDppass);
|
|
537 |
GLES31.glStencilOp(cState.stencilOpSfail,cState.stencilOpDpfail,cState.stencilOpDppass);
|
|
538 | 538 |
} |
539 | 539 |
|
540 | 540 |
///////////////////////////////////////////////////// |
... | ... | |
543 | 543 |
{ |
544 | 544 |
//android.util.Log.d("State", "setting stencil mask"); |
545 | 545 |
cState.stencilMask = mState.stencilMask; |
546 |
GLES30.glStencilMask(cState.stencilMask);
|
|
546 |
GLES31.glStencilMask(cState.stencilMask);
|
|
547 | 547 |
} |
548 | 548 |
|
549 | 549 |
///////////////////////////////////////////////////// |
... | ... | |
551 | 551 |
if( mClear!=0 ) |
552 | 552 |
{ |
553 | 553 |
//android.util.Log.d("State", "clearing buffer"); |
554 |
GLES30.glClear(mClear);
|
|
554 |
GLES31.glClear(mClear);
|
|
555 | 555 |
} |
556 | 556 |
} |
557 | 557 |
|
... | ... | |
583 | 583 |
|
584 | 584 |
void glEnable(int test) |
585 | 585 |
{ |
586 |
if( test==GLES30.GL_DEPTH_TEST ) mState.depthTest = 1;
|
|
587 |
else if( test==GLES30.GL_STENCIL_TEST ) mState.stencilTest = 1;
|
|
588 |
else if( test==GLES30.GL_BLEND ) mState.blend = 1;
|
|
586 |
if( test==GLES31.GL_DEPTH_TEST ) mState.depthTest = 1;
|
|
587 |
else if( test==GLES31.GL_STENCIL_TEST ) mState.stencilTest = 1;
|
|
588 |
else if( test==GLES31.GL_BLEND ) mState.blend = 1;
|
|
589 | 589 |
} |
590 | 590 |
|
591 | 591 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
592 | 592 |
|
593 | 593 |
void glDisable(int test) |
594 | 594 |
{ |
595 |
if( test==GLES30.GL_DEPTH_TEST ) mState.depthTest = 0;
|
|
596 |
else if( test==GLES30.GL_STENCIL_TEST ) mState.stencilTest = 0;
|
|
597 |
else if( test==GLES30.GL_BLEND ) mState.blend = 0;
|
|
595 |
if( test==GLES31.GL_DEPTH_TEST ) mState.depthTest = 0;
|
|
596 |
else if( test==GLES31.GL_STENCIL_TEST ) mState.stencilTest = 0;
|
|
597 |
else if( test==GLES31.GL_BLEND ) mState.blend = 0;
|
|
598 | 598 |
} |
599 | 599 |
|
600 | 600 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/library/main/DistortedScreen.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
23 | 23 |
|
24 |
import android.app.ActivityManager; |
|
25 |
import android.content.Context; |
|
26 |
import android.content.pm.ConfigurationInfo; |
|
27 | 24 |
import android.graphics.Bitmap; |
28 | 25 |
import android.graphics.Canvas; |
29 | 26 |
import android.graphics.Paint; |
30 |
import android.opengl.GLES30; |
|
31 |
import android.opengl.GLSurfaceView; |
|
27 |
import android.opengl.GLES31; |
|
32 | 28 |
|
33 | 29 |
import org.distorted.library.effect.MatrixEffectMove; |
34 | 30 |
import org.distorted.library.type.Static3D; |
... | ... | |
123 | 119 |
if (fpsTexture.setAsInput()) |
124 | 120 |
{ |
125 | 121 |
setAsOutput(time); |
126 |
GLES30.glColorMask(true,true,true,true);
|
|
127 |
GLES30.glDepthMask(false);
|
|
128 |
GLES30.glDisable(GLES30.GL_STENCIL_TEST);
|
|
129 |
GLES30.glDisable(GLES30.GL_DEPTH_TEST);
|
|
122 |
GLES31.glColorMask(true,true,true,true);
|
|
123 |
GLES31.glDepthMask(false);
|
|
124 |
GLES31.glDisable(GLES31.GL_STENCIL_TEST);
|
|
125 |
GLES31.glDisable(GLES31.GL_DEPTH_TEST);
|
|
130 | 126 |
fpsEffects.drawPriv(fpsW/2.0f, fpsH/2.0f, fpsMesh, this, time, 0); |
131 | 127 |
} |
132 | 128 |
} |
src/main/java/org/distorted/library/main/DistortedTexture.java | ||
---|---|---|
23 | 23 |
import android.graphics.Canvas; |
24 | 24 |
import android.graphics.Matrix; |
25 | 25 |
import android.graphics.Paint; |
26 |
import android.opengl.GLES30;
|
|
26 |
import android.opengl.GLES31;
|
|
27 | 27 |
import android.opengl.GLUtils; |
28 | 28 |
|
29 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
64 | 64 |
if( mColorCreated==NOT_CREATED_YET ) |
65 | 65 |
{ |
66 | 66 |
mColorCreated = CREATED; |
67 |
GLES30.glGenTextures(1, mColorH, 0);
|
|
68 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[0]);
|
|
69 |
GLES30.glTexParameteri ( GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_LINEAR );
|
|
70 |
GLES30.glTexParameteri ( GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR );
|
|
71 |
GLES30.glTexParameteri ( GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_CLAMP_TO_EDGE );
|
|
72 |
GLES30.glTexParameteri ( GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_CLAMP_TO_EDGE );
|
|
73 |
GLUtils.texImage2D(GLES30.GL_TEXTURE_2D, 0, flipBitmap(mBmp), 0);
|
|
67 |
GLES31.glGenTextures(1, mColorH, 0);
|
|
68 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, mColorH[0]);
|
|
69 |
GLES31.glTexParameteri ( GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_MIN_FILTER, GLES31.GL_LINEAR );
|
|
70 |
GLES31.glTexParameteri ( GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_MAG_FILTER, GLES31.GL_LINEAR );
|
|
71 |
GLES31.glTexParameteri ( GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_WRAP_S, GLES31.GL_CLAMP_TO_EDGE );
|
|
72 |
GLES31.glTexParameteri ( GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_WRAP_T, GLES31.GL_CLAMP_TO_EDGE );
|
|
73 |
GLUtils.texImage2D(GLES31.GL_TEXTURE_2D, 0, flipBitmap(mBmp), 0);
|
|
74 | 74 |
} |
75 | 75 |
else |
76 | 76 |
{ |
77 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[0]);
|
|
78 |
GLUtils.texSubImage2D(GLES30.GL_TEXTURE_2D, 0,0,0,flipBitmap(mBmp));
|
|
77 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, mColorH[0]);
|
|
78 |
GLUtils.texSubImage2D(GLES31.GL_TEXTURE_2D, 0,0,0,flipBitmap(mBmp));
|
|
79 | 79 |
} |
80 | 80 |
|
81 | 81 |
mBmp = null; |
... | ... | |
89 | 89 |
{ |
90 | 90 |
if( mColorH[0]>0 ) |
91 | 91 |
{ |
92 |
GLES30.glDeleteTextures(1, mColorH, 0);
|
|
92 |
GLES31.glDeleteTextures(1, mColorH, 0);
|
|
93 | 93 |
mColorH[0] = 0; |
94 | 94 |
mColorCreated = NOT_CREATED_YET; |
95 | 95 |
} |
... | ... | |
139 | 139 |
{ |
140 | 140 |
if( mColorH[0]>0 ) |
141 | 141 |
{ |
142 |
GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
|
|
143 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[0]);
|
|
142 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE0);
|
|
143 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, mColorH[0]);
|
|
144 | 144 |
return true; |
145 | 145 |
} |
146 | 146 |
|
src/main/java/org/distorted/library/main/EffectQueueFragment.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.main; |
21 | 21 |
|
22 |
import android.opengl.GLES30;
|
|
22 |
import android.opengl.GLES31;
|
|
23 | 23 |
|
24 | 24 |
import org.distorted.library.effect.EffectType; |
25 | 25 |
import org.distorted.library.effect.FragmentEffect; |
... | ... | |
46 | 46 |
|
47 | 47 |
static void getUniforms(int mProgramH) |
48 | 48 |
{ |
49 |
mNumEffectsH= GLES30.glGetUniformLocation( mProgramH, "fNumEffects");
|
|
50 |
mNameH = GLES30.glGetUniformLocation( mProgramH, "fName");
|
|
51 |
mUniformsH = GLES30.glGetUniformLocation( mProgramH, "fUniforms");
|
|
49 |
mNumEffectsH= GLES31.glGetUniformLocation( mProgramH, "fNumEffects");
|
|
50 |
mNameH = GLES31.glGetUniformLocation( mProgramH, "fName");
|
|
51 |
mUniformsH = GLES31.glGetUniformLocation( mProgramH, "fUniforms");
|
|
52 | 52 |
} |
53 | 53 |
|
54 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
87 | 87 |
|
88 | 88 |
void send() |
89 | 89 |
{ |
90 |
GLES30.glUniform1i( mNumEffectsH, mNumEffects);
|
|
90 |
GLES31.glUniform1i( mNumEffectsH, mNumEffects);
|
|
91 | 91 |
|
92 | 92 |
if( mNumEffects>0 ) |
93 | 93 |
{ |
94 |
GLES30.glUniform1iv( mNameH , mNumEffects, mName ,0);
|
|
95 |
GLES30.glUniform4fv( mUniformsH,(NUM_UNIFORMS/4)*mNumEffects, mUniforms,0);
|
|
94 |
GLES31.glUniform1iv( mNameH , mNumEffects, mName ,0);
|
|
95 |
GLES31.glUniform4fv( mUniformsH,(NUM_UNIFORMS/4)*mNumEffects, mUniforms,0);
|
|
96 | 96 |
} |
97 | 97 |
} |
98 | 98 |
} |
src/main/java/org/distorted/library/main/EffectQueueMatrix.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.main; |
21 | 21 |
|
22 |
import android.opengl.GLES30;
|
|
22 |
import android.opengl.GLES31;
|
|
23 | 23 |
import android.opengl.Matrix; |
24 | 24 |
|
25 | 25 |
import org.distorted.library.effect.EffectType; |
... | ... | |
103 | 103 |
|
104 | 104 |
static void getUniforms(int mProgramH) |
105 | 105 |
{ |
106 |
mObjDH = GLES30.glGetUniformLocation(mProgramH, "u_objD");
|
|
107 |
mMVPMatrixH= GLES30.glGetUniformLocation(mProgramH, "u_MVPMatrix");
|
|
108 |
mMVMatrixH = GLES30.glGetUniformLocation(mProgramH, "u_MVMatrix");
|
|
106 |
mObjDH = GLES31.glGetUniformLocation(mProgramH, "u_objD");
|
|
107 |
mMVPMatrixH= GLES31.glGetUniformLocation(mProgramH, "u_MVPMatrix");
|
|
108 |
mMVMatrixH = GLES31.glGetUniformLocation(mProgramH, "u_MVMatrix");
|
|
109 | 109 |
} |
110 | 110 |
|
111 | 111 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
158 | 158 |
if( marginInPixels!=0 ) magnify(projection,halfX,halfY,halfZ, marginInPixels); |
159 | 159 |
Matrix.multiplyMM(mMVPMatrix, 0, projection.mProjectionMatrix, 0, mViewMatrix, 0); |
160 | 160 |
|
161 |
GLES30.glUniform3f( mObjDH , halfX, halfY, halfZ);
|
|
162 |
GLES30.glUniformMatrix4fv(mMVMatrixH , 1, false, mViewMatrix, 0);
|
|
163 |
GLES30.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix , 0);
|
|
161 |
GLES31.glUniform3f( mObjDH , halfX, halfY, halfZ);
|
|
162 |
GLES31.glUniformMatrix4fv(mMVMatrixH , 1, false, mViewMatrix, 0);
|
|
163 |
GLES31.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix , 0);
|
|
164 | 164 |
} |
165 | 165 |
} |
src/main/java/org/distorted/library/main/EffectQueueVertex.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.main; |
21 | 21 |
|
22 |
import android.opengl.GLES30;
|
|
22 |
import android.opengl.GLES31;
|
|
23 | 23 |
|
24 | 24 |
import org.distorted.library.effect.EffectType; |
25 | 25 |
import org.distorted.library.effect.VertexEffect; |
... | ... | |
46 | 46 |
|
47 | 47 |
static void getUniforms(int mProgramH) |
48 | 48 |
{ |
49 |
mNumEffectsH= GLES30.glGetUniformLocation( mProgramH, "vNumEffects");
|
|
50 |
mNameH = GLES30.glGetUniformLocation( mProgramH, "vName");
|
|
51 |
mUniformsH = GLES30.glGetUniformLocation( mProgramH, "vUniforms");
|
|
49 |
mNumEffectsH= GLES31.glGetUniformLocation( mProgramH, "vNumEffects");
|
|
50 |
mNameH = GLES31.glGetUniformLocation( mProgramH, "vName");
|
|
51 |
mUniformsH = GLES31.glGetUniformLocation( mProgramH, "vUniforms");
|
|
52 | 52 |
} |
53 | 53 |
|
54 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
88 | 88 |
|
89 | 89 |
void send() |
90 | 90 |
{ |
91 |
GLES30.glUniform1i( mNumEffectsH, mNumEffects);
|
|
91 |
GLES31.glUniform1i( mNumEffectsH, mNumEffects);
|
|
92 | 92 |
|
93 | 93 |
if( mNumEffects>0 ) |
94 | 94 |
{ |
95 |
GLES30.glUniform1iv( mNameH , mNumEffects, mName ,0);
|
|
96 |
GLES30.glUniform4fv( mUniformsH,(NUM_UNIFORMS/4)*mNumEffects, mUniforms,0);
|
|
95 |
GLES31.glUniform1iv( mNameH , mNumEffects, mName ,0);
|
|
96 |
GLES31.glUniform4fv( mUniformsH,(NUM_UNIFORMS/4)*mNumEffects, mUniforms,0);
|
|
97 | 97 |
} |
98 | 98 |
} |
99 | 99 |
} |
src/main/java/org/distorted/library/main/MeshObject.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.main; |
21 | 21 |
|
22 |
import android.opengl.GLES30;
|
|
22 |
import android.opengl.GLES31;
|
|
23 | 23 |
|
24 | 24 |
import java.nio.FloatBuffer; |
25 | 25 |
|
... | ... | |
77 | 77 |
{ |
78 | 78 |
if( mAttVBO[0]<0 ) |
79 | 79 |
{ |
80 |
GLES30.glGenBuffers(1, mAttVBO, 0);
|
|
81 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mAttVBO[0]);
|
|
82 |
GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, numVertices*VERTSIZE, mVertAttribs, GLES30.GL_STATIC_READ);
|
|
83 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0);
|
|
80 |
GLES31.glGenBuffers(1, mAttVBO, 0);
|
|
81 |
GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, mAttVBO[0]);
|
|
82 |
GLES31.glBufferData(GLES31.GL_ARRAY_BUFFER, numVertices*VERTSIZE, mVertAttribs, GLES31.GL_STATIC_READ);
|
|
83 |
GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, 0);
|
|
84 | 84 |
} |
85 | 85 |
if( mAttTFO[0]<0 && Distorted.GLSL >= 300 ) |
86 | 86 |
{ |
87 |
GLES30.glGenBuffers(1, mAttTFO, 0);
|
|
88 |
GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, mAttTFO[0]);
|
|
89 |
GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, numVertices*TFSIZE, null, GLES30.GL_STATIC_READ);
|
|
90 |
GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0);
|
|
87 |
GLES31.glGenBuffers(1, mAttTFO, 0);
|
|
88 |
GLES31.glBindBuffer(GLES31.GL_TRANSFORM_FEEDBACK_BUFFER, mAttTFO[0]);
|
|
89 |
GLES31.glBufferData(GLES31.GL_TRANSFORM_FEEDBACK_BUFFER, numVertices*TFSIZE, null, GLES31.GL_STATIC_READ);
|
|
90 |
GLES31.glBindBuffer(GLES31.GL_TRANSFORM_FEEDBACK_BUFFER, 0);
|
|
91 | 91 |
} |
92 | 92 |
} |
93 | 93 |
|
... | ... | |
98 | 98 |
{ |
99 | 99 |
if( mAttVBO[0]>=0 ) |
100 | 100 |
{ |
101 |
GLES30.glDeleteBuffers(1, mAttVBO, 0);
|
|
101 |
GLES31.glDeleteBuffers(1, mAttVBO, 0);
|
|
102 | 102 |
mAttVBO[0] = -1; |
103 | 103 |
} |
104 | 104 |
if( mAttTFO[0]>=0 ) |
105 | 105 |
{ |
106 |
GLES30.glDeleteBuffers(1, mAttTFO, 0);
|
|
106 |
GLES31.glDeleteBuffers(1, mAttTFO, 0);
|
|
107 | 107 |
mAttTFO[0] = -1; |
108 | 108 |
} |
109 | 109 |
} |
src/main/java/org/distorted/library/program/DistortedProgram.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.program; |
21 | 21 |
|
22 |
import android.opengl.GLES30;
|
|
22 |
import android.opengl.GLES31;
|
|
23 | 23 |
|
24 | 24 |
import java.io.BufferedReader; |
25 | 25 |
import java.io.IOException; |
... | ... | |
54 | 54 |
private int createAndLinkProgram(final int vertexShaderHandle, final int fragmentShaderHandle, final String[] attributes, final String[] feedbackVaryings) |
55 | 55 |
throws LinkingException |
56 | 56 |
{ |
57 |
int programHandle = GLES30.glCreateProgram();
|
|
57 |
int programHandle = GLES31.glCreateProgram();
|
|
58 | 58 |
|
59 | 59 |
if (programHandle != 0) |
60 | 60 |
{ |
61 |
GLES30.glAttachShader(programHandle, vertexShaderHandle);
|
|
62 |
GLES30.glAttachShader(programHandle, fragmentShaderHandle);
|
|
61 |
GLES31.glAttachShader(programHandle, vertexShaderHandle);
|
|
62 |
GLES31.glAttachShader(programHandle, fragmentShaderHandle);
|
|
63 | 63 |
|
64 | 64 |
if( feedbackVaryings!=null ) |
65 | 65 |
{ |
66 |
GLES30.glTransformFeedbackVaryings(programHandle, feedbackVaryings, GLES30.GL_INTERLEAVED_ATTRIBS);
|
|
66 |
GLES31.glTransformFeedbackVaryings(programHandle, feedbackVaryings, GLES31.GL_INTERLEAVED_ATTRIBS);
|
|
67 | 67 |
} |
68 | 68 |
|
69 | 69 |
if (attributes != null) |
... | ... | |
72 | 72 |
|
73 | 73 |
for (int i = 0; i < size; i++) |
74 | 74 |
{ |
75 |
GLES30.glBindAttribLocation(programHandle, i, attributes[i]);
|
|
75 |
GLES31.glBindAttribLocation(programHandle, i, attributes[i]);
|
|
76 | 76 |
} |
77 | 77 |
} |
78 | 78 |
|
79 |
GLES30.glLinkProgram(programHandle);
|
|
79 |
GLES31.glLinkProgram(programHandle);
|
|
80 | 80 |
|
Also available in: Unified diff
Up library requirements to OpenGL ES 3.1 (needed for the upcoming GL_SHADER_STORAGE_BUFFER)