4.07.2012

OOP vs. State Machine vs. VM

I noticed that my render concept bears similarities to a little virtual machine. I added goto and a conditional jump so that line command indices can be inserted via buffers and so on. So you don't need to call and fill new stuff and can utilize the command string itself. I don't exactly know what to do with it right now but it probably fulfills it role a some point.

I mean just think about: a VM is quite sponsive and a fixed code written with for it is just like a shade executed on graphics cards, just done via the CPU. I'll probably put in all commands and things into it because it simplifies the whole writing of it. I'm already having buffers I can set (which funtion like repeating read-only memory slots) and everything else is just calculating and calling. I might add some more specialized commands for future stuff. Since I can, for example, also add shaders to the pipeline, this might become an interesting way to assemble them. Yeah, wouldn't require any calculation functionality, but for pure cpu calculations, I could also add commands for normalizing sets of vectors and other common minor tasks you'd need to do before starting the renderer and so on. I could also abuse shaders in the pipe line to execute those commands and flush the cycle once to get them back. Mostly interesting indeed if you ask me.

Anyway, I've yet to properly experiment with shaders, their compilation and so on. The biggest concern so far really is the base itself. Calling OpenGL or SDL is just copy and past - API usage after all. Therefore, I'll at first focus on all the basic 2D stuff, experiment with compiled OpenGL display lists and shaders, end the last bits of the matrix code and then implement all desired OpenGL features. If everything plays well, I'll have some nice little graphics engine combining everything in a more comftable and effective way. I'm just wondering whether this will work as good as if with a custom code witout this layer. More direct is usually less latency, so it'd be slower on one site but it does the same as with a typical performance loop, so it's that of a big latency added. Logical thinking tells me that this stuff can't be worse than a custom loop for standar stuff like sending a bunch of polygons and rendering it. It's just looping after all - no need care making the optimal case more optimal as it is.

No comments: