Question

Hi I'm making a game and its basic engine was constructed in LWJGL using GL11. I'm looking into porting it to LibGDX but I'm having issues with rendering.

The game is 2D top down using a grid which moves around in the Box2d world (Grid being a map of blocks), within LWJGL I could simply translate the matrix to the location of the grid, rotate, then draw all the blocks by simply punching in offset positions (avoiding heavy trig use). I've been poking around with LibGDX but I can't find a method to replace glTranslatef or glRotate.

I simply want to know (or be pointed to) a replacement function or class which I can use to render squares with textures. Something like ShapeRenderer but allowing textures (it has translate/rotate).

Any help would be appreciated.

Was it helpful?

Solution

I think you're running into an OpenGL1.1 -> OpenGL ES 2.0 compatibility issue, more than a LWJGL/LibGDX compatibilty issue. The matrix stack was deprecated in OpenGL ES 2.0, so none of the glRotate, glTranslate, etc are part of OpenGL ES after 2.0. See http://en.wikibooks.org/wiki/OpenGL_Programming/Migrating_from_1.x_to_2.x for details.

Anyway, there are at least two ways you can work around this, I think.

  1. Use the Libgdx Matrix classes to do your matrix manipulations.

  2. If your goal is to render textured rectangles, look at Libgdx SpriteBatch. You'll want one of the draw variants that expects the scaling/rotation parameters you want to use. See the SpriteBatch wiki for an overview on how to set it up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top