Archive for the 'graphics' Category

First Experiments with OpenGL

July 31, 2009

I got tired of how slow some drawing operations were recently and started to learn OpenGL. I’m rewriting large parts of the game now–about half of the C++ code will be replaced with Scheme, and the other half will be broken out and made a separate part.The game logic itself is fine and does not need to be rewritten. I’m keeping the SVG parser, but making it a separate utility that exports the data into my own format.

The rewrite will solve lots of problems and reduce dependencies on other software: I’m getting rid of Gtk and won’t require Libxml at enduser’s machines anymore. SDL is a new dependency, though.

cairo_vs_opengl

The output quality doesn’t come close to what I got with Cairo, at least not with the naive approach I tried. Maybe I did something wrong. I know it can be solved because Qt, Amanith and various other libraries can render pretty SVG graphics using OpenGL. Maybe they use fragment shaders or some other technique that’s too advanced for someone who started with OpenGL just a few days ago. I’ll get there eventually, but right now I plan to use Cairo to render textures that I can map to rectangles with OpenGL. That should give me both quality and speed, at the cost of texture memory.

The partial rewrite means I won’t have a prototype to show at the end of the summer as I had hoped, but once it’s done I should have a much better foundation and be able to work faster than before. Working with the new code base is already more fun, which may be enough to increase my output after the rewrite, since it could mean I end up putting more hours into the project.