Sunday, October 2, 2011

Writing a 2D Library On Top of OpenGL 3.x Practices

Having straightened out MyGL this weekend to behave far more transparently with the underlying OpenGL state machine (effectively created an object-oriented OpenGL 3.x filter) I now have to take on the challenge of actually writing easy-to-use code bases on top of it. The first issue that I'm going to tackle is two-dimensional rendering. I don't think OpenGL gives 2D enough love by default. You look at an API like DirectX and they've got a custom sprite rendering component that provides accelerated blitting operations right along side traditional 3D rendering techniques. Although it's closed-source I have to imagine that under hood this sprite rendering system is uses much the same hardware techniques as the rest of the API. There's no reason this can't be done with OpenGL, except that OpenGL chooses not to anything like it. My own opinion is that OpenGL is trying to be as low-level and "simple" as it can be, and as a result the idea of an additional layer of indirection from the hardware that a sprite-rendering system would provide doesn't quite feel right.

Tuesday, September 27, 2011

MyGL

Part of The Rewrite Engine is a pseudo-abstraction layer that sits on top of OpenGL called MyGL. I originally wrote it as a fully namespaced library for software rendering within my Computer Graphics 1 course on rasterization theory and implementation. In that original form MyGL was essentially a hybrid of practices found within both Deprecated-OpenGL and DirectX. The overall library was a state machine much as OpenGL, having matrix stacks as well as a dedicated vertex buffer, color specification etc. The DirectX likeness came in the form of Object-Oriented practices being employed to manage this state. Vertices themselves were objects containing various state and helper functions. Colors were specified per-vertex,  model transformations resided with a specific "Model", and the view and projection matrices were part of an encapsulating Camera class that provided additional levels of abstraction and functionality for implementing different cameras.

Friday, September 9, 2011

The Rewrite To End All Rewrites

So I've had this huge problem for the past 5 years or so that I've been writing programs where I just can't close the deal on a piece of code or subsystem to save my life. Whenever I spend a significant amount of time working on a feature, I inevitably go back almost immediately to rewrite the entire thing convinced that it just wasn't right!. This was much more of a problem prior to entering college, when my programming work was comprised of nothing but schedule-less projects that went on for an eternity. Even after school and eventually life made me realize that I couldn't afford to rewrite things 500 times however I still feel that the problem as a whole persists. I've got a few decent projects under my belt (namely my ray-marcher VolTex I've mentioned before or another project from last year that I'm sure I'll write about eventually) and at my current job I can get things done ahead of time, but all in all I think that when the schedule and the project is left entirely up to me I fail to deliver at any reasonable pace due to my previously mentioned hindrance.

Thursday, June 23, 2011

Particles Update

Been a while. Quick outline of what I did since last time:
  • Added math to base processor so that particles can be drawn or expelled from a central gravity well.
  • Finished adding support for custom shaders (no more COMPILING after shader modifications!!)
  • Added more attributes and exposed them to shaders. Currently color is calculated based on particle's age and velocity. Size is likewise.
  • Figured out how to turn on aliased (circular) GL_POINTS
  • Turned on alpha blending
So not too much in all actuality...but it felt like a lot. Bunch'a pictures as well: