Skip to content

Instantly share code, notes, and snippets.

@xoppa
xoppa / Preprocessor.java
Created November 20, 2015 18:13
Testing a very basic preprocessor
package com.badlogic.gdx.tests.preprocessor;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.StringBuilder;
public class Preprocessor {
private final static boolean isNewline (final char c) {
return c == '\n';
@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;
/**
* @author Xoppa
*/
options
{
JDK_VERSION = "1.6";
static = false;
}
PARSER_BEGIN(GSLParser)
@xoppa
xoppa / GameBoard.java
Last active August 29, 2015 14:27
Pseudo code of a simple RenderableProvider
public class GameBoard implements RenderableProvider {
public static class BoardPiece extends Renderable {
public Matrix4 localTransform = new Matrix4();
}
public Array<BoardPiece> pieces = new Array<BoardPiece>();
public Matrix4 transform = new Matrix4();
@Override
public void getRenderables (Array<Renderable> renderables, Pool<Renderable> pool) {
@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 / ModelCache.java
Last active August 29, 2015 14:19
ModelCache
See https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/g3d/ModelCache.java
@xoppa
xoppa / FlushablePool.java
Created April 3, 2015 18:57
FlushablePool
/** Keeps track of the obtained items and frees them on the call to {@link #flush()}. */
public abstract class FlushablePool<T> extends Pool<T> {
protected Array<T> obtained = new Array<T>();
public FlushablePool () {
}
@Override
public T obtain () {
T result = super.obtain();
@xoppa
xoppa / PathRotationTest.java
Last active August 29, 2015 14:15
Path rotation
/*******************************************************************************
* 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
@xoppa
xoppa / gist:3b841fb52f46e8cdec24
Last active August 29, 2015 14:14
Rolling ball example
/*******************************************************************************
* 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
@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 {