From 6dbd0fcce1ede17c8630d1f55c037394c09165b3 Mon Sep 17 00:00:00 2001 From: gered Date: Mon, 14 Oct 2013 16:15:55 -0400 Subject: [PATCH] add debug helper method for rendering wireframe grid planes --- src/com/blarg/gdx/graphics/GraphicsHelpers.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/com/blarg/gdx/graphics/GraphicsHelpers.java b/src/com/blarg/gdx/graphics/GraphicsHelpers.java index b37fd62..5de1f28 100644 --- a/src/com/blarg/gdx/graphics/GraphicsHelpers.java +++ b/src/com/blarg/gdx/graphics/GraphicsHelpers.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.*; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.math.Vector3; public final class GraphicsHelpers { @@ -49,6 +50,19 @@ public final class GraphicsHelpers { shapeRenderer.end(); } + public static void renderGridPlane(ShapeRenderer shapeRenderer, int width, int depth, Matrix4 transform) { + shapeRenderer.begin(ShapeRenderer.ShapeType.Line); + shapeRenderer.setTransformMatrix(transform); + shapeRenderer.setColor(Color.WHITE); + + for (int i = 0; i <= width; ++i) + shapeRenderer.line((float)i, 0.0f, 0.0f, (float)i, 0.0f, (float)depth); + for (int i = 0; i <= depth; ++i) + shapeRenderer.line(0.0f, 0.0f, (float)i, (float)width, 0.0f, (float)i); + + shapeRenderer.end(); + } + /** * Same as {@link Texture#draw}, but also allows drawing the source Pixmap object to an unmanaged Texture object. * Note that doing so will mean that the original texture image data will be restored if the OpenGL context is