Skip to content

Instantly share code, notes, and snippets.

package com.badlogic.gdx.tests.g3d;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.ModelBatch;
public class Grid<T extends Grid.GridCell> {
public interface GridCell {
int getX();
int getY();
void setLocation(int x, int y);
}
public interface CellProvider<T extends GridCell> {
T obtainCell();
void releaseCell(T b);
@xoppa
xoppa / gist:7724943
Last active December 29, 2015 20:39
default precompiled
attribute vec3 a_position;
uniform mat4 u_projViewTrans;
attribute vec3 a_normal;
uniform mat3 u_normalMatrix;
varying vec3 v_normal;
uniform mat4 u_worldTrans;
const float u_shininess = 20.0;
varying vec3 v_lightDiffuse;
uniform vec3 u_ambientCubemap[6];
varying vec3 v_lightSpecular;
package com.badlogic.gdx.tests.g3d;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.g3d.Environment;
@xoppa
xoppa / Particle3DTest.java
Created January 14, 2014 18:47
Particle 3D test
package com.badlogic.gdx.tests.g3d;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes;
@xoppa
xoppa / PolygonShapeTest.java
Created July 5, 2015 13:05
Shows how to render primitive shapes using Batch, without using ShapeRenderer. Requires at least libGDX 1.6.4 or latest nightly.
package com.badlogic.gdx.tests.g2d;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
@xoppa
xoppa / GL20Adreno20X.java
Last active May 31, 2017 10:11
adreno gl20
package com.xoppa.gdx.graphics.utils;
import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
public class GL20Adreno20X implements GL20 {
@xoppa
xoppa / gist:8647365
Last active January 9, 2020 06:43
CustomTextureTest.java
public class CustomTextureTest extends GdxTest {
public static class BgTextureUnitAttribute extends IntAttribute{
public static final String Alias = "bgTtextureUnit";
public final static long Type = register(Alias);
public BgTextureUnitAttribute(long type, int textureNum) {
super(type, textureNum);
}
}
public static class BgTextureShader extends DefaultShader {
@xoppa
xoppa / outline.fragment.glsl
Created October 12, 2015 20:42
very basic outline shader
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
const float offset = 1.0 / 128.0;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
@xoppa
xoppa / fragment.glsl
Last active November 9, 2023 21:52
Fragment lighting shader
#ifdef GL_ES
#define LOWP lowp
#define MED mediump
#define HIGH highp
precision mediump float;
#else
#define MED
#define LOWP
#define HIGH
#endif