Hey all! Been a while since I posted, so I thought I would come back with a little treat. Over the past six months, I have been writing/rewriting a 2D rendering engine using OpenGL, and so far it has come along very well. It is meant to be as unintrusive as possible, leaving you to easily adapt this to work with any existing frameworks you work with. An intended side effect is that this thing is fast, and I mean fast. The entire concept that the engine was built on is that it should be data-driven, so I used XML to provide a method of splitting up huge sheets of sprite frames into separate animations. You could dedicate an entire sheet to a single character and his/her/its relevant animations. I am currently licensing this under the GPLv3, but talk to me if this is too restrictive. We can work something out individually.
Here's how the entire engine works:
1) Cache a resource using Mob2D::API()->AddResource(string file); The file is an XML file that defines the source image, and the animations/frames.
2) Create a handle, or "Mob2DNode" that points to the resource. All of the resources are hashed to strings that are defined in the sprites XML file, so when you call Mob2D::API()->AddNode(string sprite);, that is what you want to put in as an argument. I provided sample definitions in the Mob2DTest/bin/Debug directory. The function returns a copy of the node that is stored internally.
3) Set the animation using Mob2DNode::SetAnimation(string anim); Unset nodes will not be displayed. They default to pointing to an internal "ERROR" animation.
4) Update the handles on an individual basis. If you want to step through the frames, you must call either Mob2DNode::StepFrame(), or Mob2DNode::SetFrame(uint frame); Seems tedious, but this will allow you full control of timings/framerate. You can also call any number of functions on the nodes such as Mob2DNode::Translate(int x, int y); DARSNode::Rotate(float angle); or Mob2DNode::Transform(int x, int y, float angle);
5) Call Mob2D::API()->FinalizeFrame(); This draws all active nodes to the backbuffer, and they won't be displayed until you swap buffers.
There are numerous other functions, but I'll have to generate the documentation to give youall the full rundown. I also added functions that return data to be used to make bounding boxes.
Here's the projects Google code page. I suggest you checkout the code out of the SVN trunk. The tarballs are out of date.
http://code.google.com/p/mob2d
Here's how the entire engine works:
1) Cache a resource using Mob2D::API()->AddResource(string file); The file is an XML file that defines the source image, and the animations/frames.
2) Create a handle, or "Mob2DNode" that points to the resource. All of the resources are hashed to strings that are defined in the sprites XML file, so when you call Mob2D::API()->AddNode(string sprite);, that is what you want to put in as an argument. I provided sample definitions in the Mob2DTest/bin/Debug directory. The function returns a copy of the node that is stored internally.
3) Set the animation using Mob2DNode::SetAnimation(string anim); Unset nodes will not be displayed. They default to pointing to an internal "ERROR" animation.
4) Update the handles on an individual basis. If you want to step through the frames, you must call either Mob2DNode::StepFrame(), or Mob2DNode::SetFrame(uint frame); Seems tedious, but this will allow you full control of timings/framerate. You can also call any number of functions on the nodes such as Mob2DNode::Translate(int x, int y); DARSNode::Rotate(float angle); or Mob2DNode::Transform(int x, int y, float angle);
5) Call Mob2D::API()->FinalizeFrame(); This draws all active nodes to the backbuffer, and they won't be displayed until you swap buffers.
There are numerous other functions, but I'll have to generate the documentation to give youall the full rundown. I also added functions that return data to be used to make bounding boxes.
Here's the projects Google code page. I suggest you checkout the code out of the SVN trunk. The tarballs are out of date.
http://code.google.com/p/mob2d