Project

General

Profile

« Previous | Next » 

Revision 20ee7cc9

Added by Leszek Koltunski over 7 years ago

Bugfix in RenderState

View differences:

src/main/java/org/distorted/library/main/DistortedRenderState.java
121 121

  
122 122
  static void colorDepthStencilOn()
123 123
    {
124
    sState.colorMaskR = cState.colorMaskR;
125
    sState.colorMaskG = cState.colorMaskG;
126
    sState.colorMaskB = cState.colorMaskB;
127
    sState.colorMaskA = cState.colorMaskA;
128

  
124 129
    if( cState.colorMaskR!=1 || cState.colorMaskG!=1 || cState.colorMaskB!=1 || cState.colorMaskA!=1 )
125 130
      {
126
      sState.colorMaskR = cState.colorMaskR;
127
      sState.colorMaskG = cState.colorMaskG;
128
      sState.colorMaskB = cState.colorMaskB;
129
      sState.colorMaskA = cState.colorMaskA;
130 131
      cState.colorMaskR = 1;
131 132
      cState.colorMaskG = 1;
132 133
      cState.colorMaskB = 1;
133 134
      cState.colorMaskA = 1;
134 135
      GLES30.glColorMask(true,true,true,true);
135 136
      }
137

  
138
    sState.depthMask = cState.depthMask;
139

  
136 140
    if( cState.depthMask!=1 )
137 141
      {
138
      sState.depthMask = cState.depthMask;
139 142
      cState.depthMask = 1;
140 143
      GLES30.glDepthMask(true);
141 144
      }
145

  
146
    sState.stencilMask = cState.stencilMask;
147

  
142 148
    if( cState.stencilMask!= STENCIL_MASK )
143 149
      {
144
      sState.stencilMask = cState.stencilMask;
145 150
      cState.stencilMask = STENCIL_MASK;
146 151
      GLES30.glStencilMask(cState.stencilMask);
147 152
      }
148 153
    }
149 154

  
155
///////////////////////////////////////////////////////////////////////////////////////////////////
156

  
157
  static void colorDepthStencilRestore()
158
    {
159
    if( sState.colorMaskR!=cState.colorMaskR || sState.colorMaskG!=cState.colorMaskG || sState.colorMaskB!=cState.colorMaskB || sState.colorMaskA!=cState.colorMaskA)
160
      {
161
      cState.colorMaskR = sState.colorMaskR;
162
      cState.colorMaskG = sState.colorMaskG;
163
      cState.colorMaskB = sState.colorMaskB;
164
      cState.colorMaskA = sState.colorMaskA;
165
      GLES30.glColorMask(cState.colorMaskR==1,cState.colorMaskG==1,cState.colorMaskB==1,cState.colorMaskA==1);
166
      }
167
    if( sState.depthMask!=cState.depthMask )
168
      {
169
      cState.depthMask = sState.depthMask;
170
      GLES30.glDepthMask(cState.depthMask==1);
171
      }
172
    if( sState.stencilMask!=cState.stencilMask )
173
      {
174
      cState.stencilMask = sState.stencilMask;
175
      GLES30.glStencilMask(cState.stencilMask);
176
      }
177
    }
178

  
150 179
///////////////////////////////////////////////////////////////////////////////////////////////////
151 180

  
152 181
  static void switchOffDrawing()
......
166 195

  
167 196
  static void setUpStencilMark()
168 197
    {
198
    sState.stencilTest = cState.stencilTest;
199

  
169 200
    if( cState.stencilTest!=1 )
170 201
      {
171
      sState.stencilTest = cState.stencilTest;
172 202
      cState.stencilTest = 1;
173 203
      //android.util.Log.d("State", "stencil test on");
174 204
      GLES30.glEnable(GLES30.GL_STENCIL_TEST);
175 205
      }
206

  
207
    sState.stencilFuncFunc = cState.stencilFuncFunc;
208
    sState.stencilFuncRef  = cState.stencilFuncRef;
209
    sState.stencilFuncMask = cState.stencilFuncMask;
210

  
176 211
    if( cState.stencilFuncFunc!=GLES30.GL_ALWAYS || cState.stencilFuncRef!=1 || cState.stencilFuncMask!=STENCIL_MASK )
177 212
      {
178
      sState.stencilFuncFunc = cState.stencilFuncFunc;
179
      sState.stencilFuncRef  = cState.stencilFuncRef;
180
      sState.stencilFuncMask = cState.stencilFuncMask;
181 213
      cState.stencilFuncFunc = GLES30.GL_ALWAYS;
182 214
      cState.stencilFuncRef  = 1;
183 215
      cState.stencilFuncMask = STENCIL_MASK;
184 216
      //android.util.Log.d("State", "stencil func on");
185 217
      GLES30.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
186 218
      }
219

  
220
    sState.stencilOpSfail = cState.stencilOpSfail;
221
    sState.stencilOpDpfail= cState.stencilOpDpfail;
222
    sState.stencilOpDppass= cState.stencilOpDppass;
223

  
187 224
    if( cState.stencilOpSfail!=GLES30.GL_KEEP || cState.stencilOpDpfail!=GLES30.GL_KEEP || cState.stencilOpDppass!=GLES30.GL_REPLACE )
188 225
      {
189
      sState.stencilOpSfail = cState.stencilOpSfail;
190
      sState.stencilOpDpfail= cState.stencilOpDpfail;
191
      sState.stencilOpDppass= cState.stencilOpDppass;
192 226
      cState.stencilOpSfail = GLES30.GL_KEEP;
193 227
      cState.stencilOpDpfail= GLES30.GL_KEEP;
194 228
      cState.stencilOpDppass= GLES30.GL_REPLACE;
195 229
      //android.util.Log.d("State", "stencil op on");
196 230
      GLES30.glStencilOp(cState.stencilOpSfail,cState.stencilOpDpfail,cState.stencilOpDppass);
197 231
      }
232

  
233
    sState.colorMaskR = cState.colorMaskR;
234
    sState.colorMaskG = cState.colorMaskG;
235
    sState.colorMaskB = cState.colorMaskB;
236
    sState.colorMaskA = cState.colorMaskA;
237

  
198 238
    if( cState.colorMaskR!=0 || cState.colorMaskG!=0 || cState.colorMaskB!=0 || cState.colorMaskA!=0 )
199 239
      {
200
      sState.colorMaskR = cState.colorMaskR;
201
      sState.colorMaskG = cState.colorMaskG;
202
      sState.colorMaskB = cState.colorMaskB;
203
      sState.colorMaskA = cState.colorMaskA;
204 240
      cState.colorMaskR = 0;
205 241
      cState.colorMaskG = 0;
206 242
      cState.colorMaskB = 0;
......
208 244
      //android.util.Log.d("State", "switch off color writing");
209 245
      GLES30.glColorMask(false,false,false,false);
210 246
      }
247

  
248
    sState.depthMask = cState.depthMask;
249

  
211 250
    if( cState.depthMask!=1 )
212 251
      {
213
      sState.depthMask = cState.depthMask;
214 252
      cState.depthMask = 1;
215 253
      //android.util.Log.d("State", "switch on depth writing");
216 254
      GLES30.glDepthMask(true);
217 255
      }
256

  
257
    sState.stencilMask = cState.stencilMask;
258

  
218 259
    if( cState.stencilMask!= STENCIL_MASK )
219 260
      {
220
      sState.stencilMask = cState.stencilMask;
221 261
      cState.stencilMask = STENCIL_MASK;
222 262
      //android.util.Log.d("State", "stencil mask on");
223 263
      GLES30.glStencilMask(cState.stencilMask);
......
269 309
 */
270 310
  public static void useStencilMark()
271 311
    {
312
    sState.stencilMask = cState.stencilMask;
313

  
272 314
    if( cState.stencilTest!=1 )
273 315
      {
274
      sState.stencilTest = cState.stencilTest;
275 316
      cState.stencilTest = 1;
276 317
      GLES30.glEnable(GLES30.GL_STENCIL_TEST);
277 318
      }
319

  
320
    sState.stencilFuncFunc = cState.stencilFuncFunc;
321
    sState.stencilFuncRef  = cState.stencilFuncRef;
322
    sState.stencilFuncMask = cState.stencilFuncMask;
323

  
278 324
    if( cState.stencilFuncFunc!=GLES30.GL_EQUAL || cState.stencilFuncRef!=1 || cState.stencilFuncMask!=STENCIL_MASK )
279 325
      {
280
      sState.stencilFuncFunc = cState.stencilFuncFunc;
281
      sState.stencilFuncRef  = cState.stencilFuncRef;
282
      sState.stencilFuncMask = cState.stencilFuncMask;
283 326
      cState.stencilFuncFunc = GLES30.GL_EQUAL;
284 327
      cState.stencilFuncRef  = 1;
285 328
      cState.stencilFuncMask = STENCIL_MASK;
286 329
      GLES30.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask);
287 330
      }
331

  
332
    sState.stencilMask = cState.stencilMask;
333

  
288 334
    if( cState.stencilMask!= 0x00 )
289 335
      {
290
      sState.stencilMask = cState.stencilMask;
291 336
      cState.stencilMask = 0x00;
292 337
      GLES30.glStencilMask(cState.stencilMask);
293 338
      }
294
     if( cState.depthMask!=0 )
339

  
340
    sState.depthMask = cState.depthMask;
341

  
342
    if( cState.depthMask!=0 )
295 343
      {
296
      sState.depthMask = cState.depthMask;
297 344
      cState.depthMask = 0;
298 345
      GLES30.glDepthMask(false);
299 346
      }
347

  
348
    sState.depthTest = cState.depthTest;
349

  
300 350
    if( cState.depthTest!=0 )
301 351
      {
302
      sState.depthTest = cState.depthTest;
303 352
      cState.depthTest = 0;
304 353
      GLES30.glDisable(GLES30.GL_DEPTH_TEST);
305 354
      }

Also available in: Unified diff