Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using the libgdx framework, I've figured out how to render a texture to a point sprite. The problem is, it renders the entire texture to the point sprite, where I only want a small part of it (since it's an isometric tile image).

Here's a snippet from some demo code I wrote...

    renderer = new ImmediateModeRenderer();

    tiles =
        TextureWrap.ClampToEdge);, 0.7f, 0.9f, 1);;;






    // render 3 point sprites at various 3d points
    renderer.vertex(-.1f, 0, -.1f);
    renderer.vertex(0, 0, 0);
    renderer.vertex(.1f, 0, .1f);

    // ... more vertices here if needed (one for each sprite) ...

share|improve this question
Update: As a work around, I had to split my texture images into separate files (loaded individually). This adds a bit of loading time, but it's ok with a few images (worried about when I have 100 textures though...). A caveat I didn't foresee is that OpenGL ES (<2.0) requires that images be power of 2, and point sprites must be square! – nbolton Mar 12 '11 at 1:48

With OpenGL ES 1.x, i gess there is no solution. With OpenGL ES 2.x, you can use gl_PointCoord in fragment shader to select a part of your texture.

A typical PointSprite Fragment shader:

#ifdef GL_ES
precision highp float;
uniform sampler2D tex0;

void main() 
    gl_FragColor = texture2D(tex0, gl_PointCoord);

So, you can modify it for 16 square textures in one texture:

    gl_FragColor = texture2D(tex0, gl_PointCoord*0.25+displacement);

One last word, if you are developing for mobile devices, keep you fragment very short and don't use branch.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.