Giter Club home page Giter Club logo

rend-ios's Introduction

Rend - A lightweight OpenGL ES 2.0 framework for iOS

Author: Anton Holmquist | http://antonholmquist.com

Rend is a very lightweight OpenGL ES 2.0 framework designed for pure rendering and to be easily integrated with UIKit.

Why another framework?

Rend is similar in some senses to Cocos2d/3d, but it's lighter and very flexible which may suit some kind of projects better. If you're writing a game you should probably look at Cocos or Unity, but if you want to create a rendering or interface component to be integrated into your UIKit-based project, this framework may be well suited!

Background

When I was looking for a framework I looked at three existing options, Cocos2d, Cocos3d and Unity. None of those seemed perfect for my needs. Cocos2d obviously doesn’t have very good 3D support, Cocos3d didn't have shader support, and Unity seemed too bloated and hard to integrate with UIKit.

The full story can be found in this blog post.

Example usage

The first thing to do is to create a view where we can draw our content.

REGLView *view = [[REGLView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];

Next, we create a scene that acts as a root node in our scene graph hierarchy. All content should be added as children to this node.

REScene *scene = [[REScene alloc] init];

Next, we create a director that is responsible for managing drawing and connecting the view and scene:

REDirector *director = [[REDirector alloc] init];
director.view = view;
director.scene = scene;

We also need to attach a camera to our scene. The camera requires some configuration so we place it at (0,0,1) facing at origo. This framework uses math functions from Cocos3d which is why you see the CC3 prefix.

RECamera *camera = [[RECamera alloc] initWithProjection:kRECameraProjectionPerspective];
camera.position = CC3VectorMake(0, 0, 1);
camera.upDirection = CC3VectorMake(0, 1, 0);
camera.lookDirection = CC3VectorMake(0, 0, -1);
camera.frustumLeft = -1;
camera.frustumRight = 1;
camera.frustumBottom = -1;
camera.frustumTop = 1;
camera.frustumNear = 0.5;
camera.frustumFar = 2;

Finally, we add a sprite to our scene, positioning it at origo and setting width and height to 1.0. We also need to select a texture from the app bundle and add the node to our scene.

RESprite *sprite = [[RESprite alloc] init];
sprite.positon = CC3VectorMake(0.0, 0.0, 0.0);
sprite.size = CC3VectorMake(1.0, 1.0, 0.0);
sprite.texture = [RETexture2D textureNamed:@"test.png"];
[scene addChild:sprite];

Now everything is set up. The only thing left is to make the director run.

director.running = YES;

So that's a very basic example on how to draw a sprite. There are some more advanced examples provided with the repository.

rend-ios's People

Contributors

antonholmquist avatar

Watchers

 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.