Jump to content

  • Log In with Google      Sign In   
  • Create Account






Glyphlets

Posted by Jason Z, 10 February 2013 · 623 views

As I alluded to last time around, one of the new features that I have been working on lately is Glyphlets. These little guys are basically an abstraction of an application, and only provide the bare minimum functionality that an app requires. The simplicity of the interface is demonstrated by the Glyphlet header file:
//--------------------------------------------------------------------------------
// This file is a portion of the Hieroglyph 3 Rendering Engine.  It is distributed
// under the MIT License, available in the root of this distribution and 
// at the following URL:
//
// http://www.opensource.org/licenses/mit-license.php
//
// Copyright (c) Jason Zink 
//--------------------------------------------------------------------------------
#ifndef Glyphlet_h
#define Glyphlet_h
//--------------------------------------------------------------------------------
#include "Log.h"
#include "Timer.h"
#include "EventManager.h"
#include "Scene.h"
//--------------------------------------------------------------------------------
namespace Glyph3
{
	class Glyphlet : public IEventListener
	{

	public:

		// The general glyphlet interface is defined by these four functions. 
		// Their individual implementations can perform whatever functionality
		// is needed for a given situation, thus no data members are assumed in
		// this base class.

		virtual void Initialize() = 0;
		virtual void Update( float dt ) = 0;
		virtual void Shutdown() = 0;
		virtual bool HandleEvent( EventPtr pEvent ) = 0;
	};
};
//--------------------------------------------------------------------------------
#endif // Glyphlet_h

While the interface is minimalist, these are only the methods that my framework requires to be able to 'play' a Glyphlet. In fact, the majority of the applications that I have in Hieroglyph 3 are able to be shoehorned into this simple interface. The latest commit to the Hieroglyph 3 repository has added a sample program which does just that - it uses the files from the ParticleStorm sample and creates a Glyphlet out of it. This is mostly accurate - I actually added another subclass that defines Glyphlets that have a single window interface, just to cut down on the amount of copy and paste that is needed to create another mini-application... but the general idea is still the same.

So what does adding a new level of abstraction for an application get me? For one, it means I don't need to create a new application and project for each demo effect or scene that I want to try out. In many respects, it allows me to have a little sandbox to create an app within an app. That sounds a bit silly at first, but it is actually quite an interesting capability. In fact, in the Glyphlets application, I actually created an Actor that can appear in a scene which displays the rendered output from a glyphlet - and then I added another one, allowing for viewing multiple glyphlets within one rendered window. Its fun, and it opens up some interesting possibilities.

To further push the system a bit further, I created a Lua based Glyphlet which uses my new Lua binding technique (its nothing special, but new to me...) to allow for totally customized scripted glyplets. So it seems that I will be able to rapidly iterate over multiple concepts fairly easily.

One thing that the implementation of this interface has demonstrated to me is that I made some unfortunate decisions about the use of Events and my EventManager class early on with Hieroglyph that I will have to correct in the near future. The EventManager was always assumed to be a Singleton up until a few weeks ago, and that doesn't jive when you have multiple 'isolated' instances of an application. So I will be dealing with that, and also trying to streamline and simplify the usage of my material system. I would like to have a cleaner API to use with my scripting system, so I'm trying to cook up some better arrangements for getting things rendered...

Overall, it has been a fun few weeks of development, and I'll be continuing on in the weeks to come!




July 2014 »

S M T W T F S
  12345
6789101112
13141516171819
202122 23 242526
2728293031  

Recent Comments

Recent Comments

PARTNERS