Coding on the run

I’ve been ‘traveling’ the past week or two, so I’ve been thinking a lot about how to eliminate code.  Thinking shorter thoughts is easier when there’s less code.

One of the areas of consolidation has been matrices.  Or rather, there is the Array2D object.  That’s nice because there’s not much difference between a Matrix, Vector, Point3D, Vector3D, Bitmap, etc.  That’s cool because previously I had these as separate objects, but the code’s getting smaller and smaller.  Also, since I’m using LuaJIT ffi, the array actually contains native types, anything from unsigned char, to PixelRGBA.  This is great fun.

There’s another realization.  I have a “renderer”, which has drawing primitives, like lines, ellipses, rectangles, etc.  Well, since there is now a generic Array object, the renderer can easily operate on any type of Array2D.  So, I can render lines of ascii art, or high resolution 32-bit color.  The renderer is the same, only the actual values in the Array2D are specific.  Again, that’s a great savings because I don’t have to create specific renderers for each occasion.

Lastly, I’ve been doing a lot of work with the core GDI and OpenGL interfaces.  At this point, I no longer need GLFW for my OpenGL connection.  I have a GDIContext and GLContext objects.  The GLContext only needs a GDIContext to get started.  Similarly, since I have my own Window object created within Lua, I can completely control the eventing loop, window creation and the like.  I have created a generic GameWindow, for example, where you can give it a frame rate, and it will guarantee you ‘OnTick()’ method is called at the appropriate frequency.  Meanwhile, you can choose to get your mouse and keyboard events inline as they occur, or dump them off to an asynchronous queue for processing at your leisure.

And it just keeps going like that.  Now it’s time to put the parts all back together and see how that 3D modeling is still working.  Now that there is a much stronger foundation, I am looking forward to more easily integrating many more features.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s