4 Hugues Ross - Blog: DFEngine Update 1
Hugues Ross


DFEngine Update 1

Note: From now on, I think I'm going to try and add more code examples to these updates. Not only will these help add more interesting content to my update posts, they may come in handy for any aspiring programmers out there. For now, code is marked with green text. I'll try and see if I can come up with a better solution soon.


  • Started working on a UI toolkit
  • Added a window class that can hold UI components
  • Added a viewport class that can act as an in-game view
  • Made UI widget positions/sizes be based on their containers
  • Made UI widgets dictate whether or not to fill their containers when extra space is available
  • Added a basic tweening engine
  • Started rewriting the Entity Component System code
  • Got basic keyboard/mouse input working

Oh boy, guys! Here comes the new engine! And this time, I've actually made sure to back up my codebase so I don't lose everything again!


One exciting new feature I've added to the engine is the ability to have multiple views! This will let me do quite a few nice things, such as adding minimaps and split-screen multiplayer. Surprisingly, adding viewports with opengl was much easier than expected. All you have to do is call glViewport to specify the position/size of the view, run some transformations based on the view's position, rotation, and scale, then redraw the scene. Here's an example:

glClear(GL_DEPTH_BUFFER_BIT); //Setup the viewport for drawing
glViewport (view x position, view y position - view y size, view x size, view y size);

glOrtho(0, 1, 1, 0, -1, 1);
glPushMatrix(); //Apply view transforms
glTranslatef(ingame camera x positioningame camera y positioningame camera z position);
glRotatef(ingame camera x-axis rotation, 1, 0, 0);
glRotatef(ingame camera y-axis rotation, 0, 1, 0);
glRotatef(ingame camera z-axis rotation, 0, 0, 1);
glScalef(ingame camera x scaleingame camera y scaleingame camera z scale);


As you can see, it's quite simple. I'm sure there are better ways to handle the rotation, but I don't know it right now.
(Note that I'm still working with old opengl code, as my graphics drivers are pretty terrible. Thus, this might not be the correct solution for opengl 3+.)

I also gave it beautifully smooth zoom feature, which brings me to...


While I was at it, I also decided to experiment with tweening. I believe the term originated with animation, and referred to adding frames in between keyframes. In games, it refers to taking some numerical amount, like the position or color of an object, and changing it smoothly over a certain length of time rather than just setting it to its new value. It took quite some time to make, but I think it'll really help make my games look better. Unfortunately, the effect can't really be shown with just a screenshot, so I may have to try and make some progress videos.

Component System:

This is pretty similar what I had in the last version of this engine, and it's a bit boring, so I'll spare you the details. That said, one new thing I added was a better way of handling the retrieval of data from objects. I'm still not happy with it, but it works. Lastly, pretty much any data that an object's components are hanging on to can be tweened now.

Finally, I've started working on a new (and much improved) font system, but it's still far from finished. More on that next week, hopefully.

No comments: