Bonsai Clean up and additions

posted in Not dead...
Published July 26, 2007
Advertisement
So, I sat down to do the stub application when it dawned on me I hadn't written some functionality into Bonsai I'd meant to add.

The first of these was the Window creation function. Atm it defaults to 800*600, windowed, depth testing enabled and a default clear colour. This is all well and good for testing but not in a real life situaton, so it's been changed so that you can pass a table containing a set of parameters;
- width and height; window size
- depthBuffer; enables depth testing (might rename this)
- fullscreen; enables fulscreen mode
- clearColor; a table containing the new colour to clear to

The latter 3 are optional parameters.

As part of this I found myself pulling more numbers out of tables, so decided to write a couple of aux. functions to wrap that up, making things easier; this lead me to go back and change some older functions to use the new method, cleaning them up somewhat;
// From thislua_getfield(L,-1,"x")float x = lua_tonumber(L,-1);lua_pop(L,-1)// to thisfloat x = getNumberFromTable(L,"x")


number, integer and boolean are supported.

Another function I found myself doing alot was pulling rgb and optionally alpha data from a table as a colour, so this got punted into it's own function as well which directly sets the glColourub().

This writing of aux functions kicked off a need for me to clean up the code; as we are treating the graphics table as an object we need to varify a certain state when we call a function, namely that the object really is a graphics object and that we have a window active to call functions on.

This code is a few lines long and looks pretty ugly at the top of each function, so once again it was punted into it's own function;
// From thisint l_deleteTexture(lua_State* L){	gfxEngineDetails * engine = (gfxEngineDetails*)luaL_checkudata(L,1,BONSAIGFX);	if(NOWINDOW == engine->currentwindow)	{		luaL_error(L,"Attempt to call Graphical Engine Function with no active window");	}			GLuint texid = lua_tointeger(L,-1);	deleteTexture(texid);				return 0;}// To thisint l_deleteTexture(lua_State* L){	gfxEngineDetails * engine = CheckValidGraphicsObject(L);		GLuint texid = lua_tointeger(L,-1);	deleteTexture(texid);				return 0;}


I think that's a bit clearer.

With the introduction of a zbuffer I decide it would make sense to be able to translate on a z-axis. This would have the effect of adding a layered system to the engine. Also, as not all graphical operations need a texture I decided to add a 'setDrawColor' function.

Two more pieces of functionality need to be added, which were in the orignal Java engine; alpha blending modes and alpha testing. This will enable me to handle alpha textures properly, which the inital shoot-em-up game requires to correctly blend things together.

This should be a simple enuff add [smile]
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement

Latest Entries

Advertisement