Gwork: 0.3.0Dev |
Gwork is divided into layers (see source):
platform
- Provides a common API to the supported platform.gwork
- The GUI API, which contains no target specific code.test
- A test of each control type, used in the samples.samples
- Some examples for demonstration and testing.The project generator creates libraries for platform and gwork, which you can then link to your project. You can see an example of how to do this in the samples. There is one for each of the targets supported. Cmake is used to generate project files for your chosen build environment.
You are free to implement your own platform, or modify the samples for your use case. The GUI controls can be shared between all platforms supported.
There are two ways in which you can use the project file generation:
If you are not familiar with cmake:
Some useful links for using Cmake:
It is best to build the project in subdirectory of the main project, e.g. in a directory called "build". You might make multiple versions of the project for different options or targets this way (e.g. "build_sdl2", "build_allegro5", etc).
You can see all of the project generators that cmake provides by typing:
To generate project files for Visual Studio 2015, 64-bit, with an Allegro5 renderer use:
You'll then have some project files (i.e. a solution and vcproj files). You can use these how you'd use a normal setup for Visual Studio. Or, just change the generator (-G) and the renderer (-DRENDER_*) to whatever you need.
Windows has no standard installation locations, or they keep moving (e.g. DirectX). The cmake "package finders" don't always find what they are looking for. You may have to run cmake once (e.g. like the above), see what errors are reported, and then either run it again with the variables specified, or edit the CMakeCache.txt. Or you can use the cmake-gui to do the same. It is likely you will have to manually specify where the SDK you require is installed.
To generate project files:
To generate project files:
Gwork currently supports the following rendering targets. You can choose these by defining a variable when you run cmake to generate the project files, i.e. -DRENDER_<TARGET>=ON
, e.g. :-
-DRENDER_ALLEGRO5=ON
-DRENDER_DIRECTX11=ON
-DRENDER_NULL=ON
-DRENDER_OPENGL=ON
-DRENDER_OPENGL_CORE=ON
-DRENDER_SDL2=ON
-DRENDER_SFML2=ON
-DRENDER_SW=ON
. This is a standalone software GUI renderer. Writes to texture.Some tests and a sample are included for each target by default. These can be turned off using:
-DBUILD_TEST=OFF
-DBUILD_SAMPLE=OFF
You should compile and run the sample before using Gwork in your own project to make sure that everything is working correctly.
The null render target is used for testing. It does not compile or link against any target API, hence "null". It can be used to generate the Gwork memory usage stats. If you are having problems compiling your project against your chosen target you could try compiling against null to see if the problem is related to Gwork or the target API.
find_package(SFML 2 COMPONENTS system window graphics REQUIRED)
.-DUSE_GLFW=OFF
. GLFW is required for sample. If off, you will have to write your own input controller, check Gwk::Input::GLFW
for example.An example cmake project is supplied below.
This assumes that you have the directory structure: