All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.badlogic.gdx.graphics.g3d.decals.DefaultGroupStrategy Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright 2011 See AUTHORS file.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

package com.badlogic.gdx.graphics.g3d.decals;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.utils.Array;

/** 

* Minimalistic grouping strategy that splits decals into opaque and transparent ones enabling and disabling blending as needed. * Opaque decals are rendered first (decal color is ignored in opacity check).
* Use this strategy only if the vast majority of your decals are opaque and the few transparent ones are unlikely to overlap. *

*

* Can produce invisible artifacts when transparent decals overlap each other. *

*

* States (* = any, EV = entry value - same as value before flush):
*

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
expectsexits on
glDepthMasktrueEV
GL_DEPTH_TESTenabledEV
glDepthFuncGL_LESS | GL_LEQUALEV
GL_BLENDdisabledEV | disabled
glBlendFunc**
GL_TEXTURE_2D*disabled
*

*/ public class DefaultGroupStrategy implements GroupStrategy { private static final int GROUP_OPAQUE = 0; private static final int GROUP_BLEND = 1; @Override public int decideGroup (Decal decal) { return decal.getMaterial().isOpaque() ? GROUP_OPAQUE : GROUP_BLEND; } @Override public void beforeGroup (int group, Array contents) { if (group == GROUP_BLEND) { Gdx.gl10.glEnable(GL10.GL_BLEND); } } @Override public void afterGroup (int group) { if (group == GROUP_BLEND) { Gdx.gl10.glDisable(GL10.GL_BLEND); } } @Override public void beforeGroups () { Gdx.gl10.glEnable(GL10.GL_TEXTURE_2D); } @Override public void afterGroups () { Gdx.gl10.glDisable(GL10.GL_TEXTURE_2D); } @Override public ShaderProgram getGroupShader (int group) { return null; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy