SDL
From qtnode
Note : This code is not really clean. The SDL parts should be moved.
Contents |
Introduction
A few month ago I started designing a game. As I love the facilities Qt provides (slots & signals, the Graphics View...), I wanted to use it for designing the game. So, I started to code the game and soon I found a few limitations to Qt :
- It is not possible to change the resolution of the screen
- It is difficult to have fullscreen display under Windows, Linux and MacOS
As I knew SDL had such features, I thought that maybe I could mix Qt and SDL in order to have Signals & Slots, resolution management and fullscreen display.
The principle
What is needed :
- a main loop that will refresh the display, manage events...
- functions to display things on the screen
In order to be able to use QTimer and Qt classes, I needed to use the Qt main loop, what I did with the : QCoreApplication class.
The files
You can download the zip from here : File:Qt SDL.zip
main.cpp : It creates a QCoreApplication instance, initializes the main class GameEngine, and starts running the main loop.
qGameEngine : Initialize SDL. Calls the drawing methods.
Compiling the application
Read the README file in the archive.