Revision c834348d
Added by Leszek Koltunski about 7 years ago
src/main/java/org/distorted/library/DistortedRenderState.java | ||
---|---|---|
35 | 35 |
private static int sStencilFuncFunc, sStencilFuncRef, sStencilFuncMask; |
36 | 36 |
private static int sStencilOpSfail, sStencilOpDpfail, sStencilOpDppass; |
37 | 37 |
private static int sDepthFunc; |
38 |
private static int sBlend; |
|
39 |
private static int sBlendSrc, sBlendDst; |
|
38 | 40 |
|
39 | 41 |
private int mColorMaskR, mColorMaskG, mColorMaskB, mColorMaskA; |
40 | 42 |
private int mDepthMask; |
... | ... | |
44 | 46 |
private int mStencilFuncFunc, mStencilFuncRef, mStencilFuncMask; |
45 | 47 |
private int mStencilOpSfail, mStencilOpDpfail, mStencilOpDppass; |
46 | 48 |
private int mDepthFunc; |
49 |
private int mBlend; |
|
50 |
private int mBlendSrc, mBlendDst; |
|
47 | 51 |
|
48 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
53 |
// default: color writes on, depth test and writes on, blending on, stencil off. |
|
49 | 54 |
|
50 | 55 |
DistortedRenderState() |
51 | 56 |
{ |
... | ... | |
53 | 58 |
mColorMaskG = 1; |
54 | 59 |
mColorMaskB = 1; |
55 | 60 |
mColorMaskA = 1; |
56 |
mDepthMask = 1; |
|
57 |
mStencilMask= 0x11111111; |
|
61 |
|
|
58 | 62 |
mDepthTest = 1; |
59 |
mStencilTest= 0; |
|
63 |
mDepthMask = 1; |
|
64 |
mDepthFunc = GLES30.GL_LEQUAL; |
|
60 | 65 |
|
66 |
mBlend = 1; |
|
67 |
mBlendSrc = GLES30.GL_SRC_ALPHA; |
|
68 |
mBlendDst = GLES30.GL_ONE_MINUS_SRC_ALPHA; |
|
69 |
|
|
70 |
mStencilTest = 0; |
|
71 |
mStencilMask = 0x11111111; |
|
61 | 72 |
mStencilFuncFunc = GLES30.GL_NEVER; |
62 | 73 |
mStencilFuncRef = 0; |
63 | 74 |
mStencilFuncMask = 0x11111111; |
64 | 75 |
mStencilOpSfail = GLES30.GL_KEEP; |
65 | 76 |
mStencilOpDpfail = GLES30.GL_KEEP; |
66 | 77 |
mStencilOpDppass = GLES30.GL_KEEP; |
67 |
mDepthFunc = GLES30.GL_LEQUAL; |
|
68 | 78 |
} |
69 | 79 |
|
70 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
81 |
// reset state of everything to 'unknown' |
|
71 | 82 |
|
72 | 83 |
static void reset() |
73 | 84 |
{ |
... | ... | |
75 | 86 |
sColorMaskG = -1; |
76 | 87 |
sColorMaskB = -1; |
77 | 88 |
sColorMaskA = -1; |
78 |
sDepthMask = -1; |
|
79 |
sStencilMask= -1; |
|
89 |
|
|
80 | 90 |
sDepthTest = -1; |
81 |
sStencilTest= -1; |
|
91 |
sDepthMask = -1; |
|
92 |
sDepthFunc = -1; |
|
93 |
|
|
94 |
sBlend = -1; |
|
95 |
sBlendSrc = -1; |
|
96 |
sBlendDst = -1; |
|
82 | 97 |
|
98 |
sStencilTest = -1; |
|
99 |
sStencilMask = -1; |
|
83 | 100 |
sStencilFuncFunc = -1; |
84 | 101 |
sStencilFuncRef = -1; |
85 | 102 |
sStencilFuncMask = -1; |
86 | 103 |
sStencilOpSfail = -1; |
87 | 104 |
sStencilOpDpfail = -1; |
88 | 105 |
sStencilOpDppass = -1; |
89 |
sDepthFunc = -1; |
|
90 | 106 |
} |
91 | 107 |
|
92 | 108 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
124 | 140 |
} |
125 | 141 |
} |
126 | 142 |
|
143 |
if( mBlend!=sBlend ) |
|
144 |
{ |
|
145 |
sBlend = mBlend; |
|
146 |
if( sBlend==0 ) GLES30.glDisable(GLES30.GL_BLEND); |
|
147 |
else |
|
148 |
{ |
|
149 |
GLES30.glEnable(GLES30.GL_BLEND); |
|
150 |
|
|
151 |
if( mBlendSrc!=sBlendSrc || mBlendDst!=sBlendDst ) |
|
152 |
{ |
|
153 |
sBlendSrc = mBlendSrc; |
|
154 |
sBlendDst = mBlendDst; |
|
155 |
GLES30.glBlendFunc(sBlendSrc,sBlendDst); |
|
156 |
} |
|
157 |
} |
|
158 |
} |
|
159 |
|
|
127 | 160 |
if( mStencilTest!=sStencilTest ) |
128 | 161 |
{ |
129 | 162 |
sStencilTest = mStencilTest; |
... | ... | |
187 | 220 |
{ |
188 | 221 |
if( test==GLES30.GL_DEPTH_TEST ) mDepthTest = 1; |
189 | 222 |
else if( test==GLES30.GL_STENCIL_TEST ) mStencilTest = 1; |
223 |
else if( test==GLES30.GL_BLEND ) mBlend = 1; |
|
190 | 224 |
} |
191 | 225 |
|
192 | 226 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
195 | 229 |
{ |
196 | 230 |
if( test==GLES30.GL_DEPTH_TEST ) mDepthTest = 0; |
197 | 231 |
else if( test==GLES30.GL_STENCIL_TEST ) mStencilTest = 0; |
232 |
else if( test==GLES30.GL_BLEND ) mBlend = 0; |
|
198 | 233 |
} |
199 | 234 |
|
200 | 235 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
221 | 256 |
{ |
222 | 257 |
mDepthFunc = func; |
223 | 258 |
} |
259 |
|
|
260 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
261 |
|
|
262 |
void glBlendFunc(int src, int dst) |
|
263 |
{ |
|
264 |
mBlendSrc = src; |
|
265 |
mBlendDst = dst; |
|
266 |
} |
|
267 |
|
|
224 | 268 |
} |
Also available in: Unified diff
Make it possible to render each DistortedNode with adjustable OpeGL state (writeing to Color, Depth,Stencil buffers, DEPTH, STENCIL, BLENDING on.off, etc)