Coder Social home page Coder Social logo

bradparks / monkswf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from talentless/monkswf

3.0 2.0 0.0 22.9 MB

A flash file (SWF) parser and viewer using OpenVG as the backend. Written in C++. (If you are looking for further development of this project contact me here at github)

monkswf's Introduction

MonkSWF -- An SWF Animation Player

Overview

MonkSWF is a SWF (Adobe Flash) animation player. It uses OpenVG as the rendering API. If your platform does not support OpenVG you can use MonkVG.

If you are looking to integrate this with your Cocos2D application there is an excellent article by Luke. Check it out: http://blog.zincroe.com/2011/11/displaying-a-swf-on-the-iphone-with-cocos2d-and-monkswf/

Installation

Use git to clone:

$ git clone [email protected]:micahpearlman/MonkSWF.git

If your platform does not support OpenVG download MonkVG with git:

$ git clone [email protected]:micahpearlman/MonkVG.git

There are currently iOS projects.

TODO: standard *nix Makefiles.

What is implemented

  • Most basic solid fills and strokes.
  • Sprite animations.

TODO

  • Bitmap fills and strokes.
  • Gradient fills and strokes.
  • Font Rendering.
  • Morph Targets.

Simple Example

NOTE: MonkVG will not create a OpenGL context, it is the applications responsibility to create there own OpenGL context. Also, if your application does any other OpenGL rendering it should save off the GL state and then restore before calling any MonkVG or MonkSWF methods.

Initialization:


	#include 
	#include 
	#include 
	
	char* filebuffer;
	int filebuffersize;
	... Load The SWF File into a buffer ...
	MonkSWF::Reader r( filebuffer, filebuffersize );
			
	MonkSWF::SWF* swf = new SWF();
	swf->initialize();
	swf->read( &r );	// read in SWF file

Rendering and Animation

This example shows rendering the root SWF Movie.



	... begin opengl context ...
	
	float deltaTime = calculateDeltaTime();
	if ( deltaTime > 1.0f / swf->getFrameRate() ) {
		frame++;
	}
	if ( frame >= swf->numFrames() ) {	// loop
		frame = 0;
	}
	
	// setup OpenVG
	vgLoadIdentity();
	vgRotate( angle );
	
	swf->drawFrame( frame );

	... end opengl context ...

Alternatively you render a specific sprite in a SWF.


	// get a specific sprite
	MonkSWF::IDefineSpriteTag*	sprite = swf->spriteAt( spriteIdx );
	
	... begin opengl context ...
	
	float deltaTime = calculateDeltaTime();
	if ( deltaTime > 1.0f / swf->getFrameRate() ) {
		frame++;
	}
	if ( frame >= sprite->frameCount() ) {	// loop
		frame = 0;
	}
	
	// setup OpenVG
	vgLoadIdentity();
	vgRotate( angle );
	
	sprite->draw( frame );

	... end opengl context ...

Donate

Donate

Click here to lend your support to: MonkSWF and make a donation at www.pledgie.com !

monkswf's People

Contributors

micahpearlman avatar talentless avatar

Stargazers

 avatar  avatar  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.