Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use <a href="http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html" rel="nofollow">the <code>ShapeRenderer</code> API</a> to draw simple, solid-color shapes with Libgdx.</p> <p>The code you've given is a reasonable way to draw solid color polygons too. Its much more flexible than <code>ShapeRenderer</code>, but is a good bit more complicated. You'll need to use <code>glColor4f</code> to set the color, or add a <code>Usage.Color</code> attribute to each vertex. See <a href="https://code.google.com/p/libgdx-users/source/browse/demos-3-tier-main/src/com/gdxuser/demos/SubMeshColorTest.java?r=789be290e6a786b47ea1801205db7b29dddc9c8e" rel="nofollow">the SubMeshColorTest example</a> for more details on the first approach and <a href="https://code.google.com/p/libgdx/wiki/MeshColorTexture" rel="nofollow">the MeshColorTexture example</a> for details on the second approach.</p> <p>Another option to think about is using sprite textures. If you're only interested in simple solid colors objects, you can use very simple 1x1 textures of a single color and let the system stretch that across the sprite. Much of Libgdx and the underlying hardware are really optimized for rendering textures, so you may find it easier to use even if you're not really taking advantage of the texture contents. (You can even use a 1x1 white texture, and then use a <a href="http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/SpriteBatch.html" rel="nofollow"><code>SpriteBatch</code></a> with <a href="http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/SpriteBatch.html#setColor%28com.badlogic.gdx.graphics.Color%29" rel="nofollow"><code>setColor</code></a> and <a href="http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/SpriteBatch.html#draw%28com.badlogic.gdx.graphics.Texture,%20float,%20float,%20float,%20float%29" rel="nofollow"><code>draw()</code></a> to draw different color rectangles easily.)</p> <p>You can also mix and match the various approaches, too.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload