Skip to content

Instantly share code, notes, and snippets.

@xoppa
xoppa / Preprocessor.java
Created Nov 20, 2015
Testing a very basic preprocessor
View Preprocessor.java
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 Oct 12, 2015
very basic outline shader
View outline.fragment.glsl
#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;
View gsl.jj
/**
* @author Xoppa
*/
options
{
JDK_VERSION = "1.6";
static = false;
}
PARSER_BEGIN(GSLParser)
@xoppa
xoppa / GameBoard.java
Last active Aug 29, 2015
Pseudo code of a simple RenderableProvider
View GameBoard.java
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 Jul 5, 2015
Shows how to render primitive shapes using Batch, without using ShapeRenderer. Requires at least libGDX 1.6.4 or latest nightly.
View PolygonShapeTest.java
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;
View ModelCache.java
See https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/g3d/ModelCache.java
View FlushablePool.java
/** 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();
View PathRotationTest.java
/*******************************************************************************
* 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 Aug 29, 2015
Rolling ball example
View gist:3b841fb52f46e8cdec24
/*******************************************************************************
* 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
View GL20Adreno20X.java
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 {