Giter Club home page Giter Club logo

simple-android-opengl-2d-rendering's Introduction

SpriteMethodTest 1.1

Author: Chris Pruett
Extended by: Costi Muraru

Note: This project is an extension to the project developed by Chris Pruett, 
which can be found here [1]. Feel free to read the README provided.

Basically, what this project aims to do is to offer you a simple class that
can be used to render 2D objects in an OpenGL surface.

I modified a little the project written by Chris Pruett by adding a wrapper
class corresponding to a scene. This allows you to use OpenGL very easily in
order to render 2D objects. You can instantiate this class, add various
sprites and have them drawn on the surface view.


Usage:
public class MainActivity extends Activity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		Scene scene = createScene();
		setContentView(scene.getSurfaceView());
	}

	private Scene createScene() {
		// our OpenGL scene
		GLScene scene = new GLScene(this);

		// can set a nine patch for the background
		scene.setNinePatchBackground(R.drawable.nine_patch_bg);

		// can set a bitmap for the background
		// scene.setBitmapBackground(someBitmap);

		// can set a color for the background
		// scene.setBackgroundColor(new CustomColor(0, 0, 0, 1));

		// create some sprites
		GLSprite sprite = scene.createSprite(getApplicationContext(), R.drawable.skate1);
		// initial position
		sprite.x = 100;
		sprite.y = 200;
		GLSprite sprite2 = scene.createSprite(getApplicationContext(), R.drawable.skate2);
		// initial position
		sprite2.x = 300;
		sprite2.y = 400;

		// add sprites to the scene
		scene.addSprite(sprite, true);
		scene.addSprite(sprite2, true);
		scene.addSprite(sprite.clone(), true);
		scene.addSprite(sprite2.clone(), true);

		// this thread controls the sprites' positions
		scene.setMover(new Mover());
		return scene;
	}
}


[1] http://code.google.com/p/apps-for-android/source/browse/SpriteMethodTest

simple-android-opengl-2d-rendering's People

Contributors

costimuraru avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.