Revision b7074bc6
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/library/main/InternalRenderState.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.main; |
21 | 21 |
|
22 |
import android.opengl.GLES31;
|
|
22 |
import android.opengl.GLES30;
|
|
23 | 23 |
|
24 | 24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
25 | 25 |
/** |
... | ... | |
71 | 71 |
|
72 | 72 |
mState.depthTest = 1; |
73 | 73 |
mState.depthMask = 1; |
74 |
mState.depthFunc = GLES31.GL_LEQUAL;
|
|
74 |
mState.depthFunc = GLES30.GL_LEQUAL;
|
|
75 | 75 |
|
76 | 76 |
mState.blend = 1; |
77 |
mState.blendSrc = GLES31.GL_SRC_ALPHA;
|
|
78 |
mState.blendDst = GLES31.GL_ONE_MINUS_SRC_ALPHA;
|
|
77 |
mState.blendSrc = GLES30.GL_SRC_ALPHA;
|
|
78 |
mState.blendDst = GLES30.GL_ONE_MINUS_SRC_ALPHA;
|
|
79 | 79 |
|
80 | 80 |
mState.stencilTest = 0; |
81 | 81 |
mState.stencilMask = STENCIL_MASK; |
82 |
mState.stencilFuncFunc = GLES31.GL_NEVER;
|
|
82 |
mState.stencilFuncFunc = GLES30.GL_NEVER;
|
|
83 | 83 |
mState.stencilFuncRef = 0; |
84 | 84 |
mState.stencilFuncMask = STENCIL_MASK; |
85 |
mState.stencilOpSfail = GLES31.GL_KEEP;
|
|
86 |
mState.stencilOpDpfail = GLES31.GL_KEEP;
|
|
87 |
mState.stencilOpDppass = GLES31.GL_KEEP;
|
|
85 |
mState.stencilOpSfail = GLES30.GL_KEEP;
|
|
86 |
mState.stencilOpDpfail = GLES30.GL_KEEP;
|
|
87 |
mState.stencilOpDppass = GLES30.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 |
GLES31.glColorMask(true,true,true,true);
|
|
101 |
GLES30.glColorMask(true,true,true,true);
|
|
102 | 102 |
|
103 | 103 |
cState.depthTest = 1; |
104 | 104 |
cState.depthMask = 1; |
105 |
cState.depthFunc = GLES31.GL_LEQUAL;
|
|
106 |
GLES31.glEnable(GLES31.GL_DEPTH_TEST);
|
|
107 |
GLES31.glDepthMask(true);
|
|
108 |
GLES31.glDepthFunc(cState.depthFunc);
|
|
105 |
cState.depthFunc = GLES30.GL_LEQUAL;
|
|
106 |
GLES30.glEnable(GLES30.GL_DEPTH_TEST);
|
|
107 |
GLES30.glDepthMask(true);
|
|
108 |
GLES30.glDepthFunc(cState.depthFunc);
|
|
109 | 109 |
|
110 | 110 |
cState.stencilTest = 0; |
111 | 111 |
cState.stencilMask = STENCIL_MASK; |
112 |
cState.stencilFuncFunc = GLES31.GL_NEVER;
|
|
112 |
cState.stencilFuncFunc = GLES30.GL_NEVER;
|
|
113 | 113 |
cState.stencilFuncRef = 0; |
114 | 114 |
cState.stencilFuncMask = STENCIL_MASK; |
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);
|
|
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);
|
|
120 | 120 |
|
121 | 121 |
cState.blend = 1; |
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);
|
|
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);
|
|
126 | 126 |
} |
127 | 127 |
|
128 | 128 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
140 | 140 |
cState.colorMaskG = 1; |
141 | 141 |
cState.colorMaskB = 1; |
142 | 142 |
cState.colorMaskA = 1; |
143 |
GLES31.glColorMask(true,true,true,true);
|
|
143 |
GLES30.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 |
GLES31.glDepthMask(true);
|
|
151 |
GLES30.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 |
GLES31.glStencilMask(cState.stencilMask);
|
|
159 |
GLES30.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 |
GLES31.glColorMask(cState.colorMaskR==1,cState.colorMaskG==1,cState.colorMaskB==1,cState.colorMaskA==1);
|
|
173 |
GLES30.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 |
GLES31.glDepthMask(cState.depthMask==1);
|
|
178 |
GLES30.glDepthMask(cState.depthMask==1);
|
|
179 | 179 |
} |
180 | 180 |
if( sState.stencilMask!=cState.stencilMask ) |
181 | 181 |
{ |
182 | 182 |
cState.stencilMask = sState.stencilMask; |
183 |
GLES31.glStencilMask(cState.stencilMask);
|
|
183 |
GLES30.glStencilMask(cState.stencilMask);
|
|
184 | 184 |
} |
185 | 185 |
} |
186 | 186 |
|
... | ... | |
193 | 193 |
if (cState.blend != 0) |
194 | 194 |
{ |
195 | 195 |
cState.blend = 0; |
196 |
GLES31.glDisable(GLES31.GL_BLEND);
|
|
196 |
GLES30.glDisable(GLES30.GL_BLEND);
|
|
197 | 197 |
} |
198 | 198 |
} |
199 | 199 |
|
... | ... | |
207 | 207 |
|
208 | 208 |
if (cState.blend == 0) |
209 | 209 |
{ |
210 |
GLES31.glDisable(GLES31.GL_BLEND);
|
|
210 |
GLES30.glDisable(GLES30.GL_BLEND);
|
|
211 | 211 |
} |
212 | 212 |
else |
213 | 213 |
{ |
214 |
GLES31.glEnable(GLES31.GL_BLEND);
|
|
214 |
GLES30.glEnable(GLES30.GL_BLEND);
|
|
215 | 215 |
} |
216 | 216 |
} |
217 | 217 |
} |
... | ... | |
225 | 225 |
if (cState.depthTest != 1) |
226 | 226 |
{ |
227 | 227 |
cState.depthTest = 1; |
228 |
GLES31.glEnable(GLES31.GL_DEPTH_TEST);
|
|
228 |
GLES30.glEnable(GLES30.GL_DEPTH_TEST);
|
|
229 | 229 |
} |
230 | 230 |
} |
231 | 231 |
|
... | ... | |
239 | 239 |
|
240 | 240 |
if (cState.depthTest == 0) |
241 | 241 |
{ |
242 |
GLES31.glDisable(GLES31.GL_DEPTH_TEST);
|
|
242 |
GLES30.glDisable(GLES30.GL_DEPTH_TEST);
|
|
243 | 243 |
} |
244 | 244 |
else |
245 | 245 |
{ |
246 |
GLES31.glEnable(GLES31.GL_DEPTH_TEST);
|
|
246 |
GLES30.glEnable(GLES30.GL_DEPTH_TEST);
|
|
247 | 247 |
} |
248 | 248 |
} |
249 | 249 |
} |
... | ... | |
252 | 252 |
|
253 | 253 |
static void switchOffDrawing() |
254 | 254 |
{ |
255 |
GLES31.glEnable(GLES31.GL_SCISSOR_TEST);
|
|
256 |
GLES31.glScissor(0,0,0,0);
|
|
255 |
GLES30.glEnable(GLES30.GL_SCISSOR_TEST);
|
|
256 |
GLES30.glScissor(0,0,0,0);
|
|
257 | 257 |
} |
258 | 258 |
|
259 | 259 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
260 | 260 |
|
261 | 261 |
static void restoreDrawing() |
262 | 262 |
{ |
263 |
GLES31.glDisable(GLES31.GL_SCISSOR_TEST);
|
|
263 |
GLES30.glDisable(GLES30.GL_SCISSOR_TEST);
|
|
264 | 264 |
} |
265 | 265 |
|
266 | 266 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
273 | 273 |
{ |
274 | 274 |
cState.stencilTest = 0; |
275 | 275 |
//android.util.Log.d("State", "stencil test off"); |
276 |
GLES31.glDisable(GLES31.GL_STENCIL_TEST);
|
|
276 |
GLES30.glDisable(GLES30.GL_STENCIL_TEST);
|
|
277 | 277 |
} |
278 | 278 |
|
279 | 279 |
sState.depthTest = cState.depthTest; |
... | ... | |
282 | 282 |
{ |
283 | 283 |
cState.depthTest = 0; |
284 | 284 |
//android.util.Log.d("State", "depth test off"); |
285 |
GLES31.glDisable(GLES31.GL_DEPTH_TEST);
|
|
285 |
GLES30.glDisable(GLES30.GL_DEPTH_TEST);
|
|
286 | 286 |
} |
287 | 287 |
|
288 | 288 |
sState.colorMaskR = cState.colorMaskR; |
... | ... | |
297 | 297 |
cState.colorMaskB = 0; |
298 | 298 |
cState.colorMaskA = 0; |
299 | 299 |
//android.util.Log.d("State", "switch off color writing"); |
300 |
GLES31.glColorMask(false,false,false,false);
|
|
300 |
GLES30.glColorMask(false,false,false,false);
|
|
301 | 301 |
} |
302 | 302 |
|
303 | 303 |
sState.depthMask = cState.depthMask; |
... | ... | |
306 | 306 |
{ |
307 | 307 |
cState.depthMask = 0; |
308 | 308 |
//android.util.Log.d("State", "switch off depth writing"); |
309 |
GLES31.glDepthMask(false);
|
|
309 |
GLES30.glDepthMask(false);
|
|
310 | 310 |
} |
311 | 311 |
|
312 | 312 |
sState.stencilMask = cState.stencilMask; |
... | ... | |
315 | 315 |
{ |
316 | 316 |
cState.stencilMask = 0x00; |
317 | 317 |
//android.util.Log.d("State", "stencil mask off"); |
318 |
GLES31.glStencilMask(cState.stencilMask);
|
|
318 |
GLES30.glStencilMask(cState.stencilMask);
|
|
319 | 319 |
} |
320 | 320 |
} |
321 | 321 |
|
... | ... | |
329 | 329 |
{ |
330 | 330 |
cState.stencilTest = 0; |
331 | 331 |
//android.util.Log.d("State", "stencil test off"); |
332 |
GLES31.glDisable(GLES31.GL_STENCIL_TEST);
|
|
332 |
GLES30.glDisable(GLES30.GL_STENCIL_TEST);
|
|
333 | 333 |
} |
334 | 334 |
|
335 | 335 |
sState.depthTest = cState.depthTest; |
... | ... | |
338 | 338 |
{ |
339 | 339 |
cState.depthTest = 0; |
340 | 340 |
//android.util.Log.d("State", "depth test off"); |
341 |
GLES31.glDisable(GLES31.GL_DEPTH_TEST);
|
|
341 |
GLES30.glDisable(GLES30.GL_DEPTH_TEST);
|
|
342 | 342 |
} |
343 | 343 |
|
344 | 344 |
sState.colorMaskR = cState.colorMaskR; |
... | ... | |
353 | 353 |
cState.colorMaskB = 1; |
354 | 354 |
cState.colorMaskA = 1; |
355 | 355 |
//android.util.Log.d("State", "switch on color writing"); |
356 |
GLES31.glColorMask(true,true,true,true);
|
|
356 |
GLES30.glColorMask(true,true,true,true);
|
|
357 | 357 |
} |
358 | 358 |
|
359 | 359 |
sState.depthMask = cState.depthMask; |
... | ... | |
362 | 362 |
{ |
363 | 363 |
cState.depthMask = 1; |
364 | 364 |
//android.util.Log.d("State", "switch on depth writing"); |
365 |
GLES31.glDepthMask(true);
|
|
365 |
GLES30.glDepthMask(true);
|
|
366 | 366 |
} |
367 | 367 |
|
368 | 368 |
sState.stencilMask = cState.stencilMask; |
... | ... | |
371 | 371 |
{ |
372 | 372 |
cState.stencilMask = 0x00; |
373 | 373 |
//android.util.Log.d("State", "stencil mask off"); |
374 |
GLES31.glStencilMask(cState.stencilMask);
|
|
374 |
GLES30.glStencilMask(cState.stencilMask);
|
|
375 | 375 |
} |
376 | 376 |
} |
377 | 377 |
|
... | ... | |
385 | 385 |
|
386 | 386 |
if (cState.stencilTest == 0) |
387 | 387 |
{ |
388 |
GLES31.glDisable(GLES31.GL_STENCIL_TEST);
|
|
388 |
GLES30.glDisable(GLES30.GL_STENCIL_TEST);
|
|
389 | 389 |
} |
390 | 390 |
else |
391 | 391 |
{ |
392 |
GLES31.glEnable(GLES31.GL_STENCIL_TEST);
|
|
392 |
GLES30.glEnable(GLES30.GL_STENCIL_TEST);
|
|
393 | 393 |
} |
394 | 394 |
} |
395 | 395 |
if( sState.depthTest!=cState.depthTest ) |
... | ... | |
398 | 398 |
|
399 | 399 |
if (cState.depthTest == 0) |
400 | 400 |
{ |
401 |
GLES31.glDisable(GLES31.GL_DEPTH_TEST);
|
|
401 |
GLES30.glDisable(GLES30.GL_DEPTH_TEST);
|
|
402 | 402 |
} |
403 | 403 |
else |
404 | 404 |
{ |
405 |
GLES31.glEnable(GLES31.GL_DEPTH_TEST);
|
|
405 |
GLES30.glEnable(GLES30.GL_DEPTH_TEST);
|
|
406 | 406 |
} |
407 | 407 |
} |
408 | 408 |
if( sState.colorMaskR!=cState.colorMaskR || sState.colorMaskG!=cState.colorMaskG || sState.colorMaskB!=cState.colorMaskB || sState.colorMaskA!=cState.colorMaskA) |
... | ... | |
411 | 411 |
cState.colorMaskG = sState.colorMaskG; |
412 | 412 |
cState.colorMaskB = sState.colorMaskB; |
413 | 413 |
cState.colorMaskA = sState.colorMaskA; |
414 |
GLES31.glColorMask(cState.colorMaskR==1,cState.colorMaskG==1,cState.colorMaskB==1,cState.colorMaskA==1);
|
|
414 |
GLES30.glColorMask(cState.colorMaskR==1,cState.colorMaskG==1,cState.colorMaskB==1,cState.colorMaskA==1);
|
|
415 | 415 |
} |
416 | 416 |
if( sState.depthMask!=cState.depthMask ) |
417 | 417 |
{ |
418 | 418 |
cState.depthMask = sState.depthMask; |
419 |
GLES31.glDepthMask(cState.depthMask==1);
|
|
419 |
GLES30.glDepthMask(cState.depthMask==1);
|
|
420 | 420 |
} |
421 | 421 |
if( sState.stencilMask!=cState.stencilMask ) |
422 | 422 |
{ |
423 | 423 |
cState.stencilMask = sState.stencilMask; |
424 |
GLES31.glStencilMask(cState.stencilMask);
|
|
424 |
GLES30.glStencilMask(cState.stencilMask);
|
|
425 | 425 |
} |
426 | 426 |
} |
427 | 427 |
|
... | ... | |
435 | 435 |
{ |
436 | 436 |
cState.stencilTest = 1; |
437 | 437 |
//android.util.Log.d("State", "stencil test on"); |
438 |
GLES31.glEnable(GLES31.GL_STENCIL_TEST);
|
|
438 |
GLES30.glEnable(GLES30.GL_STENCIL_TEST);
|
|
439 | 439 |
} |
440 | 440 |
|
441 | 441 |
sState.stencilFuncFunc = cState.stencilFuncFunc; |
442 | 442 |
sState.stencilFuncRef = cState.stencilFuncRef; |
443 | 443 |
sState.stencilFuncMask = cState.stencilFuncMask; |
444 | 444 |
|
445 |
if( cState.stencilFuncFunc!=GLES31.GL_ALWAYS || cState.stencilFuncRef!=1 || cState.stencilFuncMask!=STENCIL_MASK )
|
|
445 |
if( cState.stencilFuncFunc!=GLES30.GL_ALWAYS || cState.stencilFuncRef!=1 || cState.stencilFuncMask!=STENCIL_MASK )
|
|
446 | 446 |
{ |
447 |
cState.stencilFuncFunc = GLES31.GL_ALWAYS;
|
|
447 |
cState.stencilFuncFunc = GLES30.GL_ALWAYS;
|
|
448 | 448 |
cState.stencilFuncRef = 1; |
449 | 449 |
cState.stencilFuncMask = STENCIL_MASK; |
450 | 450 |
//android.util.Log.d("State", "stencil func on"); |
451 |
GLES31.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
451 |
GLES30.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
452 | 452 |
} |
453 | 453 |
|
454 | 454 |
sState.stencilOpSfail = cState.stencilOpSfail; |
455 | 455 |
sState.stencilOpDpfail= cState.stencilOpDpfail; |
456 | 456 |
sState.stencilOpDppass= cState.stencilOpDppass; |
457 | 457 |
|
458 |
if( cState.stencilOpSfail!=GLES31.GL_KEEP || cState.stencilOpDpfail!=GLES31.GL_KEEP || cState.stencilOpDppass!=GLES31.GL_REPLACE )
|
|
458 |
if( cState.stencilOpSfail!=GLES30.GL_KEEP || cState.stencilOpDpfail!=GLES30.GL_KEEP || cState.stencilOpDppass!=GLES30.GL_REPLACE )
|
|
459 | 459 |
{ |
460 |
cState.stencilOpSfail = GLES31.GL_KEEP;
|
|
461 |
cState.stencilOpDpfail= GLES31.GL_KEEP;
|
|
462 |
cState.stencilOpDppass= GLES31.GL_REPLACE;
|
|
460 |
cState.stencilOpSfail = GLES30.GL_KEEP;
|
|
461 |
cState.stencilOpDpfail= GLES30.GL_KEEP;
|
|
462 |
cState.stencilOpDppass= GLES30.GL_REPLACE;
|
|
463 | 463 |
//android.util.Log.d("State", "stencil op on"); |
464 |
GLES31.glStencilOp(cState.stencilOpSfail,cState.stencilOpDpfail,cState.stencilOpDppass);
|
|
464 |
GLES30.glStencilOp(cState.stencilOpSfail,cState.stencilOpDpfail,cState.stencilOpDppass);
|
|
465 | 465 |
} |
466 | 466 |
|
467 | 467 |
sState.colorMaskR = cState.colorMaskR; |
... | ... | |
478 | 478 |
cState.colorMaskB = clr; |
479 | 479 |
cState.colorMaskA = clr; |
480 | 480 |
//android.util.Log.d("State", "switch off color writing"); |
481 |
GLES31.glColorMask(color,color,color,color);
|
|
481 |
GLES30.glColorMask(color,color,color,color);
|
|
482 | 482 |
} |
483 | 483 |
|
484 | 484 |
sState.depthMask = cState.depthMask; |
... | ... | |
487 | 487 |
{ |
488 | 488 |
cState.depthMask = 1; |
489 | 489 |
//android.util.Log.d("State", "switch on depth writing"); |
490 |
GLES31.glDepthMask(true);
|
|
490 |
GLES30.glDepthMask(true);
|
|
491 | 491 |
} |
492 | 492 |
|
493 | 493 |
sState.stencilMask = cState.stencilMask; |
... | ... | |
496 | 496 |
{ |
497 | 497 |
cState.stencilMask = STENCIL_MASK; |
498 | 498 |
//android.util.Log.d("State", "stencil mask on"); |
499 |
GLES31.glStencilMask(cState.stencilMask);
|
|
499 |
GLES30.glStencilMask(cState.stencilMask);
|
|
500 | 500 |
} |
501 | 501 |
} |
502 | 502 |
|
... | ... | |
510 | 510 |
|
511 | 511 |
if (cState.stencilTest == 0) |
512 | 512 |
{ |
513 |
GLES31.glDisable(GLES31.GL_STENCIL_TEST);
|
|
513 |
GLES30.glDisable(GLES30.GL_STENCIL_TEST);
|
|
514 | 514 |
} |
515 | 515 |
else |
516 | 516 |
{ |
517 |
GLES31.glEnable(GLES31.GL_STENCIL_TEST);
|
|
517 |
GLES30.glEnable(GLES30.GL_STENCIL_TEST);
|
|
518 | 518 |
} |
519 | 519 |
} |
520 | 520 |
if( sState.colorMaskR!=cState.colorMaskR || sState.colorMaskG!=cState.colorMaskG || sState.colorMaskB!=cState.colorMaskB || sState.colorMaskA!=cState.colorMaskA) |
... | ... | |
523 | 523 |
cState.colorMaskG = sState.colorMaskG; |
524 | 524 |
cState.colorMaskB = sState.colorMaskB; |
525 | 525 |
cState.colorMaskA = sState.colorMaskA; |
526 |
GLES31.glColorMask(cState.colorMaskR==1,cState.colorMaskG==1,cState.colorMaskB==1,cState.colorMaskA==1);
|
|
526 |
GLES30.glColorMask(cState.colorMaskR==1,cState.colorMaskG==1,cState.colorMaskB==1,cState.colorMaskA==1);
|
|
527 | 527 |
} |
528 | 528 |
if( sState.depthMask!=cState.depthMask ) |
529 | 529 |
{ |
530 | 530 |
cState.depthMask = sState.depthMask; |
531 |
GLES31.glDepthMask(cState.depthMask==1);
|
|
531 |
GLES30.glDepthMask(cState.depthMask==1);
|
|
532 | 532 |
} |
533 | 533 |
if( sState.stencilMask!=cState.stencilMask ) |
534 | 534 |
{ |
535 | 535 |
cState.stencilMask = sState.stencilMask; |
536 |
GLES31.glStencilMask(cState.stencilMask);
|
|
536 |
GLES30.glStencilMask(cState.stencilMask);
|
|
537 | 537 |
} |
538 | 538 |
} |
539 | 539 |
|
... | ... | |
550 | 550 |
if( cState.stencilTest!=1 ) |
551 | 551 |
{ |
552 | 552 |
cState.stencilTest = 1; |
553 |
GLES31.glEnable(GLES31.GL_STENCIL_TEST);
|
|
553 |
GLES30.glEnable(GLES30.GL_STENCIL_TEST);
|
|
554 | 554 |
} |
555 | 555 |
|
556 | 556 |
sState.stencilFuncFunc = cState.stencilFuncFunc; |
557 | 557 |
sState.stencilFuncRef = cState.stencilFuncRef; |
558 | 558 |
sState.stencilFuncMask = cState.stencilFuncMask; |
559 | 559 |
|
560 |
if( cState.stencilFuncFunc!=GLES31.GL_EQUAL || cState.stencilFuncRef!=1 || cState.stencilFuncMask!=STENCIL_MASK )
|
|
560 |
if( cState.stencilFuncFunc!=GLES30.GL_EQUAL || cState.stencilFuncRef!=1 || cState.stencilFuncMask!=STENCIL_MASK )
|
|
561 | 561 |
{ |
562 |
cState.stencilFuncFunc = GLES31.GL_EQUAL;
|
|
562 |
cState.stencilFuncFunc = GLES30.GL_EQUAL;
|
|
563 | 563 |
cState.stencilFuncRef = 1; |
564 | 564 |
cState.stencilFuncMask = STENCIL_MASK; |
565 |
GLES31.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
565 |
GLES30.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
566 | 566 |
} |
567 | 567 |
|
568 | 568 |
sState.stencilMask = cState.stencilMask; |
... | ... | |
570 | 570 |
if( cState.stencilMask!= 0x00 ) |
571 | 571 |
{ |
572 | 572 |
cState.stencilMask = 0x00; |
573 |
GLES31.glStencilMask(cState.stencilMask);
|
|
573 |
GLES30.glStencilMask(cState.stencilMask);
|
|
574 | 574 |
} |
575 | 575 |
|
576 | 576 |
sState.depthMask = cState.depthMask; |
... | ... | |
578 | 578 |
if( cState.depthMask!=0 ) |
579 | 579 |
{ |
580 | 580 |
cState.depthMask = 0; |
581 |
GLES31.glDepthMask(false);
|
|
581 |
GLES30.glDepthMask(false);
|
|
582 | 582 |
} |
583 | 583 |
|
584 | 584 |
sState.depthTest = cState.depthTest; |
... | ... | |
586 | 586 |
if( cState.depthTest!=0 ) |
587 | 587 |
{ |
588 | 588 |
cState.depthTest = 0; |
589 |
GLES31.glDisable(GLES31.GL_DEPTH_TEST);
|
|
589 |
GLES30.glDisable(GLES30.GL_DEPTH_TEST);
|
|
590 | 590 |
} |
591 | 591 |
} |
592 | 592 |
|
... | ... | |
604 | 604 |
|
605 | 605 |
if (cState.stencilTest == 0) |
606 | 606 |
{ |
607 |
GLES31.glDisable(GLES31.GL_STENCIL_TEST);
|
|
607 |
GLES30.glDisable(GLES30.GL_STENCIL_TEST);
|
|
608 | 608 |
} |
609 | 609 |
else |
610 | 610 |
{ |
611 |
GLES31.glEnable(GLES31.GL_STENCIL_TEST);
|
|
611 |
GLES30.glEnable(GLES30.GL_STENCIL_TEST);
|
|
612 | 612 |
} |
613 | 613 |
} |
614 | 614 |
if( sState.stencilFuncFunc!=cState.stencilFuncFunc || sState.stencilFuncRef!=cState.stencilFuncRef || sState.stencilFuncMask!=cState.stencilFuncMask ) |
... | ... | |
616 | 616 |
cState.stencilFuncFunc = sState.stencilFuncFunc; |
617 | 617 |
cState.stencilFuncRef = sState.stencilFuncRef ; |
618 | 618 |
cState.stencilFuncMask = sState.stencilFuncMask; |
619 |
GLES31.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
619 |
GLES30.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
620 | 620 |
} |
621 | 621 |
if( sState.stencilMask!=cState.stencilMask ) |
622 | 622 |
{ |
623 | 623 |
cState.stencilMask = sState.stencilMask; |
624 |
GLES31.glStencilMask(cState.stencilMask);
|
|
624 |
GLES30.glStencilMask(cState.stencilMask);
|
|
625 | 625 |
} |
626 | 626 |
if( sState.depthMask!=cState.depthMask ) |
627 | 627 |
{ |
628 | 628 |
cState.depthMask = sState.depthMask; |
629 |
GLES31.glDepthMask(cState.depthMask==1);
|
|
629 |
GLES30.glDepthMask(cState.depthMask==1);
|
|
630 | 630 |
} |
631 | 631 |
if( sState.depthTest!=cState.depthTest ) |
632 | 632 |
{ |
... | ... | |
634 | 634 |
|
635 | 635 |
if (cState.depthTest == 0) |
636 | 636 |
{ |
637 |
GLES31.glDisable(GLES31.GL_DEPTH_TEST);
|
|
637 |
GLES30.glDisable(GLES30.GL_DEPTH_TEST);
|
|
638 | 638 |
} |
639 | 639 |
else |
640 | 640 |
{ |
641 |
GLES31.glEnable(GLES31.GL_DEPTH_TEST);
|
|
641 |
GLES30.glEnable(GLES30.GL_DEPTH_TEST);
|
|
642 | 642 |
} |
643 | 643 |
} |
644 | 644 |
} |
... | ... | |
658 | 658 |
cState.colorMaskG = mState.colorMaskG; |
659 | 659 |
cState.colorMaskB = mState.colorMaskB; |
660 | 660 |
cState.colorMaskA = mState.colorMaskA; |
661 |
GLES31.glColorMask(cState.colorMaskR==1,cState.colorMaskG==1,cState.colorMaskB==1,cState.colorMaskA==1);
|
|
661 |
GLES30.glColorMask(cState.colorMaskR==1,cState.colorMaskG==1,cState.colorMaskB==1,cState.colorMaskA==1);
|
|
662 | 662 |
} |
663 | 663 |
|
664 | 664 |
///////////////////////////////////////////////////// |
... | ... | |
670 | 670 |
if (cState.depthTest == 0) |
671 | 671 |
{ |
672 | 672 |
//android.util.Log.d("State", "disabling depth test"); |
673 |
GLES31.glDisable(GLES31.GL_DEPTH_TEST);
|
|
673 |
GLES30.glDisable(GLES30.GL_DEPTH_TEST);
|
|
674 | 674 |
} |
675 | 675 |
else |
676 | 676 |
{ |
677 | 677 |
//android.util.Log.d("State", "enable depth test"); |
678 |
GLES31.glEnable(GLES31.GL_DEPTH_TEST);
|
|
678 |
GLES30.glEnable(GLES30.GL_DEPTH_TEST);
|
|
679 | 679 |
} |
680 | 680 |
} |
681 | 681 |
|
... | ... | |
685 | 685 |
{ |
686 | 686 |
//android.util.Log.d("State", "setting depth func"); |
687 | 687 |
cState.depthFunc = mState.depthFunc; |
688 |
GLES31.glDepthFunc(cState.depthFunc);
|
|
688 |
GLES30.glDepthFunc(cState.depthFunc);
|
|
689 | 689 |
} |
690 | 690 |
|
691 | 691 |
///////////////////////////////////////////////////// |
... | ... | |
694 | 694 |
{ |
695 | 695 |
//android.util.Log.d("State", "setting depth mask"); |
696 | 696 |
cState.depthMask = mState.depthMask; |
697 |
GLES31.glDepthMask(cState.depthMask==1);
|
|
697 |
GLES30.glDepthMask(cState.depthMask==1);
|
|
698 | 698 |
} |
699 | 699 |
|
700 | 700 |
///////////////////////////////////////////////////// |
... | ... | |
706 | 706 |
if (cState.blend == 0) |
707 | 707 |
{ |
708 | 708 |
//android.util.Log.d("State", "disabling blending"); |
709 |
GLES31.glDisable(GLES31.GL_BLEND);
|
|
709 |
GLES30.glDisable(GLES30.GL_BLEND);
|
|
710 | 710 |
} |
711 | 711 |
else |
712 | 712 |
{ |
713 | 713 |
//android.util.Log.d("State", "enabling blending"); |
714 |
GLES31.glEnable(GLES31.GL_BLEND);
|
|
714 |
GLES30.glEnable(GLES30.GL_BLEND);
|
|
715 | 715 |
} |
716 | 716 |
} |
717 | 717 |
|
... | ... | |
722 | 722 |
//android.util.Log.d("State", "setting blend function"); |
723 | 723 |
cState.blendSrc = mState.blendSrc; |
724 | 724 |
cState.blendDst = mState.blendDst; |
725 |
GLES31.glBlendFunc(cState.blendSrc,cState.blendDst);
|
|
725 |
GLES30.glBlendFunc(cState.blendSrc,cState.blendDst);
|
|
726 | 726 |
} |
727 | 727 |
|
728 | 728 |
///////////////////////////////////////////////////// |
... | ... | |
734 | 734 |
if (cState.stencilTest == 0) |
735 | 735 |
{ |
736 | 736 |
//android.util.Log.d("State", "disabling stencil test"); |
737 |
GLES31.glDisable(GLES31.GL_STENCIL_TEST);
|
|
737 |
GLES30.glDisable(GLES30.GL_STENCIL_TEST);
|
|
738 | 738 |
} |
739 | 739 |
else |
740 | 740 |
{ |
741 | 741 |
//android.util.Log.d("State", "enabling stencil test"); |
742 |
GLES31.glEnable(GLES31.GL_STENCIL_TEST);
|
|
742 |
GLES30.glEnable(GLES30.GL_STENCIL_TEST);
|
|
743 | 743 |
} |
744 | 744 |
} |
745 | 745 |
|
... | ... | |
751 | 751 |
cState.stencilFuncFunc = mState.stencilFuncFunc; |
752 | 752 |
cState.stencilFuncRef = mState.stencilFuncRef ; |
753 | 753 |
cState.stencilFuncMask = mState.stencilFuncMask; |
754 |
GLES31.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
754 |
GLES30.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
|
|
755 | 755 |
} |
756 | 756 |
|
757 | 757 |
///////////////////////////////////////////////////// |
... | ... | |
762 | 762 |
cState.stencilOpSfail = mState.stencilOpSfail; |
763 | 763 |
cState.stencilOpDpfail= mState.stencilOpDpfail; |
764 | 764 |
cState.stencilOpDppass= mState.stencilOpDppass; |
765 |
GLES31.glStencilOp(cState.stencilOpSfail,cState.stencilOpDpfail,cState.stencilOpDppass);
|
|
765 |
GLES30.glStencilOp(cState.stencilOpSfail,cState.stencilOpDpfail,cState.stencilOpDppass);
|
|
766 | 766 |
} |
767 | 767 |
|
768 | 768 |
///////////////////////////////////////////////////// |
... | ... | |
771 | 771 |
{ |
772 | 772 |
//android.util.Log.d("State", "setting stencil mask"); |
773 | 773 |
cState.stencilMask = mState.stencilMask; |
774 |
GLES31.glStencilMask(cState.stencilMask);
|
|
774 |
GLES30.glStencilMask(cState.stencilMask);
|
|
775 | 775 |
} |
776 | 776 |
|
777 | 777 |
///////////////////////////////////////////////////// |
... | ... | |
779 | 779 |
if( mClear!=0 ) |
780 | 780 |
{ |
781 | 781 |
//android.util.Log.d("State", "clearing buffer"); |
782 |
GLES31.glClear(mClear);
|
|
782 |
GLES30.glClear(mClear);
|
|
783 | 783 |
} |
784 | 784 |
} |
785 | 785 |
|
... | ... | |
811 | 811 |
|
812 | 812 |
void glEnable(int test) |
813 | 813 |
{ |
814 |
if( test==GLES31.GL_DEPTH_TEST ) mState.depthTest = 1;
|
|
815 |
else if( test==GLES31.GL_STENCIL_TEST ) mState.stencilTest = 1;
|
|
816 |
else if( test==GLES31.GL_BLEND ) mState.blend = 1;
|
|
814 |
if( test==GLES30.GL_DEPTH_TEST ) mState.depthTest = 1;
|
|
815 |
else if( test==GLES30.GL_STENCIL_TEST ) mState.stencilTest = 1;
|
|
816 |
else if( test==GLES30.GL_BLEND ) mState.blend = 1;
|
|
817 | 817 |
} |
818 | 818 |
|
819 | 819 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
820 | 820 |
|
821 | 821 |
void glDisable(int test) |
822 | 822 |
{ |
823 |
if( test==GLES31.GL_DEPTH_TEST ) mState.depthTest = 0;
|
|
824 |
else if( test==GLES31.GL_STENCIL_TEST ) mState.stencilTest = 0;
|
|
825 |
else if( test==GLES31.GL_BLEND ) mState.blend = 0;
|
|
823 |
if( test==GLES30.GL_DEPTH_TEST ) mState.depthTest = 0;
|
|
824 |
else if( test==GLES30.GL_STENCIL_TEST ) mState.stencilTest = 0;
|
|
825 |
else if( test==GLES30.GL_BLEND ) mState.blend = 0;
|
|
826 | 826 |
} |
827 | 827 |
|
828 | 828 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Lower requirements - now only OpenGL ES 3.0 is required; if running on such platform, OIT part of the API ( which is the only one which actually requires 3.1) is switched off.