OpenGL Graphics manager almost there

 

The OpenGL Graphics Manager is now usable 😀 It displays games well, and has all the features that the SDL Graphics Manager has (but all the scalers filters), and includes some new features like windows resizing to any size.

It is now able to use GL_NEAREST and GL_LINEAR as filters for scaling the textures. You can switch filter modes with Ctrl-Alt-F hotkey. That is not a great variety of filters, compared to the scalers that uses the SDL Graphics Manager, but they should be hardware accelerated rather than software processed.

It is now able to use GL_NEAREST and GL_LINEAR as filters for scaling the textures. You can switch filter modes with Ctrl-Alt-F hotkey. That is not a great variety of filters, compared to the scalers that uses the SDL Graphics Manager, but they should be hardware accelerated rather than software processed.

I also changed the overlay pixel format to RGBA5551 insteand of a RGBA4444, allowing a better color display. I had some problems working with the alpha channel of the overlay, because OpenGL doesn’t include any function for blitting into a texture when updating it. Also, the SDL Graphics Manger uses a RGB565 format for the overlay, but thanks to its dirty rect system it doesn’t need to use and alpha channel, as it only draws the modified overlay areas. However, I don’t make use of a extensive dirty rect system on OpenGL, so I need to use an alpha channel.

So after some work I finaly decided to nulify the alpha bit from the pixels buffer when updating the texture, and it is working now almost exactly as the SDL Graphics Manager does. The only difference is that it has a bit less for green colors in favor for a bit for alpha.

One of the major changes was redesigning the blitting system. Previously I had a copy of the texture data on each GLTexture, and when updating the texture I also updated the extra data. Then I could use this data for recreating the textures after an OpenGL context change or a filter change. However, functions like lockScreen() and grabOverlay() have to return the original pixel data from that texture, but the copy I had wasn’t the original data, as in most cases it was already converted from a palette format to a RGB/RGBA format. So I decided to remove this extra data from GLTexture, and add inteand some new variables on the graphics manager that would save the original pixel data. Now, when updating the screen or the overlay, the pixel data is saved on those variables, and the a dirty rect is extended with the modified area. When updating the screen the pixel data in its original format is converted to the OpenGL texture format in case they have paletted/clut8 format and the OpenGL texture is updated. For RGBA8888, RGBA5551 and other common RGB/A formats there is no conversion needed, OpenGL will do it already for us.

The other major change is the aspect ratio feature. Its mode can be switched with Ctrl-Alt-A, and it will loop through all aspect ratio modes. The default, aka “Normal”, mode will not conserve the aspect ratio when resizing the screen, it will just stretch the contents to the screen size. The “Conserve” mode, will mantain the current aspect ratio in use. And the “4/3″, “16/9″, and “16/10″ modes will stretch the contents to that size. When resizing the window, or using a fullscreen mode that doesn’t have the current aspect ratio in use, only one dimension of the screen contents will be stretched to the window size, and the other will not fill all the window size. So black stripes will wrap the contents and the aspect ratio will be mantained.

Another addition is Ctrl-Alt-Enter. While Alt-Enter will enter fullscreen with the best available mode (and exit it if already in fullscreen), Ctrl-Alt-Enter will loop through all available fullscreen modes. This enables the user to select what fullscreen mode to use.

Other minor implementations:

  • OSD messages, pretty much like the SDL Graphics Manager style
  • Ctrl-S will save now a bmp screenshot of the current screen
  • Screen shake effect is working

Still, I need to complete some more things before finishing with the OpenGL Graphics Manager:

  • Add options for switching between OpenGL manager and SDL manager
  • Porting to OpenGL ES and testing, most OpenGL code should work for GLES, still I need some testing
  • Code cleanup and documentation