Navigation:

Java for Android (An OpenGL Framework)


Download AndroidFramework.jar

A .jar contains classes, which are defined in java code like any other java class. You can import a .jar library into an Android Eclipse project by dragging the .jar file onto the libs folder in Eclipse and start using those classes immediately.

The AndroidFramework.jar contains convenience classes such as for drawing sprites and text using OpenGL. You will need to setup a GLSurface and Renderer yourself and once you've done this you can use the GL10 gl instance with the framework classes.

Using TextDrawer:

To use TextDrawer you will need to copy a .ttf font file to the assets folder; I have set it up to use the FantaisieArtistique.ttf font but you can change this to something else.

Download FantaisieArtistique.ttf

Example Code:
TextDrawer TextManager = new TextDrawer();

TextManager.Init(gl, ctx, 14);

public void draw(GL10 gl)
{
	TextManager.DrawText("Hello World!", 10.0f, 10.0f, gl);
}

Sprites

Here is how you would use DrawableObject and sprite to load an image in the assets folder and render it:
Example Code:
Sprite my_sprite;
DrawableObject oMyCharacter;

my_sprite = new Sprite(gl, ctx, "my_img.png");
my_sprite.setOrigin(16.0f, 16.0f);

oMyCharacter = new DrawableObject();
oMyCharacter.setSprite(my_sprite);
oMyCharacter.x = 15.0f;
oMyCharacter.y = 27.0f;

public void draw(GL10 gl)
{
	oMyCharacter.draw(gl);
}

WorldObject

This class implements the android.opengl.GLSurfaceView.Renderer. You can extend this class to create an OpenGL Renderer. It has functions such as public void onDrawFrame(GL10 gl){ that calls the subclass draw(GL10 gl) function to simplify drawing operations.

It provides functions to handle camera movement such as changing the view of the 2d world you have drawn. Or the 3d.
Example Code:
//Change the view
moveCameraAbsolute(20.0f, 20.0f);

public void draw(GL10 gl)
{
	cameraDraw2D(gl);

	//draw sprites.

	//view of sprites is offset by 20.0f,20.0f
}

Conclusion

A very brief overview of the .jar. If you have any questions get in touch.