Note: This is slightly a more professional post than the other ones.
So I have started working on my new game/engine, named LOL. This is a convert of Har engine that I might have talked about at some point before. Except that this one is using Tao.OpenGL instead of Managed DX.
A few points of interest in converting:
- There's no need for Tao.DevIL and it's 500 dependent dlls. Use GDI+ to load a bitmap from a file, it loads bmp, jpg, gif, png, and a few other formats, which should satisfy everyone. Converting to an OpenGL texture with alpha channel is easy (though it took some trial and error), lock the bitmap with a PixelFormat.Format32bppArgb, and load it into glTexImage2D with a GL_BGRA_EXT format.
- Graphics.MeasureString and DrawString in GDI+ will never have the same size unless you're using a monospaced font. No matter how much you follow the documentation for fixing overhanging glyphs, they will never be the same. Fortunately in the .NET 2.0 they have added a TextRenderer class (in Windows.Forms) that actually gives you the right answer.
- Deleting textures is a little bit ugly. If you make the textures within a class, the texture is still there remaining on the video memory after the object has been garbage collected. You will have to implement IDisposable interface and override Disposing method to delete the texture. Unfortunately, you will definitly get an access violation error if you try this. Because OpenGL keeps the context on threads, not process, so the dispose method is called from the GC's thread, which makes the texture name invalid in the process. So the way to fix it is to have a texture pool class, and tell it that you want texture name x marked for deleting. Then in your render cycle (from the thread that initialised opengl) you should tell this pool to clear up any pending resources.
I think that's all I have to say for now.