| ... | ... |
@@ -2,20 +2,25 @@ |
| 2 | 2 |
|
| 3 | 3 |
A [C++11][]/[OpenGL][] \>=[1.0][] [backend][] library. |
| 4 | 4 |
|
| 5 |
-Currently supported backends: |
|
| 5 |
+Currently supported backends (one from each category listed under |
|
| 6 |
+[Context/Window Toolkits][] on the OpenGL wiki): |
|
| 6 | 7 |
|
| 7 |
-| Name | Category | Define | Include | Class | |
|
| 8 |
-| -- | -- | -- | -- | -- | |
|
| 9 |
-| [GLFW][] | Windowing/input | `GLBACKEND_GLFW` | `glbackend_glfw.hpp` | `BackendGLFW` | |
|
| 10 |
-| [SDL2][] | Multimedia | `GLBACKEND_SDL` | `glbackend_sdl.hpp` | `BackendSDL` | |
|
| 8 |
+| Name | Category | Define | Include | Class | |
|
| 9 |
+| -- | -- | -- | -- | -- | |
|
| 10 |
+| [GLFW][] | Windowing/input | `GLBACKEND_GLFW` | `glbackend_glfw.hpp` | `BackendGLFW` | |
|
| 11 |
+| [SDL2][] | Multimedia | `GLBACKEND_SDL` | `glbackend_sdl.hpp` | `BackendSDL` | |
|
| 12 |
+| [wxWidgets][] | [Widget toolkit][] | `GLBACKEND_WXWIDGETS` | `glbackend_wxwidgets.hpp` | `BackendWxWidgets` | |
|
| 11 | 13 |
|
| 12 | 14 |
[`glbackend`]: https://git.rcrnstn.net/rcrnstn/glbackend |
| 13 | 15 |
[C++11]: https://en.wikipedia.org/wiki/C++11 |
| 14 | 16 |
[OpenGL]: https://en.wikipedia.org/wiki/OpenGL |
| 15 | 17 |
[1.0]: https://en.wikipedia.org/wiki/OpenGL#Version_history |
| 16 | 18 |
[backend]: https://www.khronos.org/opengl/wiki/Related_toolkits_and_APIs#OpenGL_initialization |
| 19 |
+[Context/Window Toolkits]: https://www.khronos.org/opengl/wiki/Related_toolkits_and_APIs#Context/Window_Toolkits |
|
| 17 | 20 |
[GLFW]: https://www.glfw.org |
| 18 | 21 |
[SDL2]: https://www.libsdl.org |
| 22 |
+[wxWidgets]: https://www.wxwidgets.org |
|
| 23 |
+[Widget toolkit]: https://en.wikipedia.org/wiki/Widget_toolkit |
|
| 19 | 24 |
|
| 20 | 25 |
## Usage |
| 21 | 26 |
|
| ... | ... |
@@ -337,12 +342,14 @@ System dependencies that need to be installed: |
| 337 | 342 |
- Private (tests): |
| 338 | 343 |
- [GLFW][] (e.g. [`libglfw3-dev`][]). |
| 339 | 344 |
- [SDL2][] (e.g. [`libsdl2-dev`][]). |
| 345 |
+ - [wxWidgets][] (e.g. [`libwxgtk3.0-gtk3-dev`]). |
|
| 340 | 346 |
|
| 341 | 347 |
[OpenGL Extension Wrangler (GLEW)]: http://glew.sourceforge.net |
| 342 | 348 |
[`libgl1-mesa-dev`]: https://packages.debian.org/search?keywords=libgl1-mesa-dev |
| 343 | 349 |
[`libglew-dev`]: https://packages.debian.org/search?keywords=libglew-dev |
| 344 | 350 |
[`libglfw3-dev`]: https://packages.debian.org/search?keywords=libglfw3-dev |
| 345 | 351 |
[`libsdl2-dev`]: https://packages.debian.org/search?keywords=libsdl2-dev |
| 352 |
+[`libwxgtk3.0-gtk3-dev`]: https://packages.debian.org/search?keywords=libwxgtk3.0-gtk3-dev |
|
| 346 | 353 |
|
| 347 | 354 |
## Build system |
| 348 | 355 |
|
| ... | ... |
@@ -7,6 +7,7 @@ Currently supported backends: |
| 7 | 7 |
| Name | Category | Define | Include | Class | |
| 8 | 8 |
| -- | -- | -- | -- | -- | |
| 9 | 9 |
| [GLFW][] | Windowing/input | `GLBACKEND_GLFW` | `glbackend_glfw.hpp` | `BackendGLFW` | |
| 10 |
+| [SDL2][] | Multimedia | `GLBACKEND_SDL` | `glbackend_sdl.hpp` | `BackendSDL` | |
|
| 10 | 11 |
|
| 11 | 12 |
[`glbackend`]: https://git.rcrnstn.net/rcrnstn/glbackend |
| 12 | 13 |
[C++11]: https://en.wikipedia.org/wiki/C++11 |
| ... | ... |
@@ -14,6 +15,7 @@ Currently supported backends: |
| 14 | 15 |
[1.0]: https://en.wikipedia.org/wiki/OpenGL#Version_history |
| 15 | 16 |
[backend]: https://www.khronos.org/opengl/wiki/Related_toolkits_and_APIs#OpenGL_initialization |
| 16 | 17 |
[GLFW]: https://www.glfw.org |
| 18 |
+[SDL2]: https://www.libsdl.org |
|
| 17 | 19 |
|
| 18 | 20 |
## Usage |
| 19 | 21 |
|
| ... | ... |
@@ -334,11 +336,13 @@ System dependencies that need to be installed: |
| 334 | 336 |
- [OpenGL Extension Wrangler (GLEW)][] (e.g. [`libglew-dev`][]). |
| 335 | 337 |
- Private (tests): |
| 336 | 338 |
- [GLFW][] (e.g. [`libglfw3-dev`][]). |
| 339 |
+ - [SDL2][] (e.g. [`libsdl2-dev`][]). |
|
| 337 | 340 |
|
| 338 | 341 |
[OpenGL Extension Wrangler (GLEW)]: http://glew.sourceforge.net |
| 339 | 342 |
[`libgl1-mesa-dev`]: https://packages.debian.org/search?keywords=libgl1-mesa-dev |
| 340 | 343 |
[`libglew-dev`]: https://packages.debian.org/search?keywords=libglew-dev |
| 341 | 344 |
[`libglfw3-dev`]: https://packages.debian.org/search?keywords=libglfw3-dev |
| 345 |
+[`libsdl2-dev`]: https://packages.debian.org/search?keywords=libsdl2-dev |
|
| 342 | 346 |
|
| 343 | 347 |
## Build system |
| 344 | 348 |
|
| ... | ... |
@@ -4,14 +4,16 @@ A [C++11][]/[OpenGL][] \>=[1.0][] [backend][] library. |
| 4 | 4 |
|
| 5 | 5 |
Currently supported backends: |
| 6 | 6 |
|
| 7 |
-| Name | Category | Define | Include | Class | |
|
| 8 |
-| -- | -- | -- | -- | -- | |
|
| 7 |
+| Name | Category | Define | Include | Class | |
|
| 8 |
+| -- | -- | -- | -- | -- | |
|
| 9 |
+| [GLFW][] | Windowing/input | `GLBACKEND_GLFW` | `glbackend_glfw.hpp` | `BackendGLFW` | |
|
| 9 | 10 |
|
| 10 | 11 |
[`glbackend`]: https://git.rcrnstn.net/rcrnstn/glbackend |
| 11 | 12 |
[C++11]: https://en.wikipedia.org/wiki/C++11 |
| 12 | 13 |
[OpenGL]: https://en.wikipedia.org/wiki/OpenGL |
| 13 | 14 |
[1.0]: https://en.wikipedia.org/wiki/OpenGL#Version_history |
| 14 | 15 |
[backend]: https://www.khronos.org/opengl/wiki/Related_toolkits_and_APIs#OpenGL_initialization |
| 16 |
+[GLFW]: https://www.glfw.org |
|
| 15 | 17 |
|
| 16 | 18 |
## Usage |
| 17 | 19 |
|
| ... | ... |
@@ -330,10 +332,13 @@ System dependencies that need to be installed: |
| 330 | 332 |
- Public (interface): |
| 331 | 333 |
- [OpenGL][] (e.g. [`libgl1-mesa-dev`][]). |
| 332 | 334 |
- [OpenGL Extension Wrangler (GLEW)][] (e.g. [`libglew-dev`][]). |
| 335 |
+- Private (tests): |
|
| 336 |
+ - [GLFW][] (e.g. [`libglfw3-dev`][]). |
|
| 333 | 337 |
|
| 334 | 338 |
[OpenGL Extension Wrangler (GLEW)]: http://glew.sourceforge.net |
| 335 | 339 |
[`libgl1-mesa-dev`]: https://packages.debian.org/search?keywords=libgl1-mesa-dev |
| 336 | 340 |
[`libglew-dev`]: https://packages.debian.org/search?keywords=libglew-dev |
| 341 |
+[`libglfw3-dev`]: https://packages.debian.org/search?keywords=libglfw3-dev |
|
| 337 | 342 |
|
| 338 | 343 |
## Build system |
| 339 | 344 |
|
| ... | ... |
@@ -2,12 +2,327 @@ |
| 2 | 2 |
|
| 3 | 3 |
A [C++11][]/[OpenGL][] \>=[1.0][] [backend][] library. |
| 4 | 4 |
|
| 5 |
+Currently supported backends: |
|
| 6 |
+ |
|
| 7 |
+| Name | Category | Define | Include | Class | |
|
| 8 |
+| -- | -- | -- | -- | -- | |
|
| 9 |
+ |
|
| 5 | 10 |
[`glbackend`]: https://git.rcrnstn.net/rcrnstn/glbackend |
| 6 | 11 |
[C++11]: https://en.wikipedia.org/wiki/C++11 |
| 7 | 12 |
[OpenGL]: https://en.wikipedia.org/wiki/OpenGL |
| 8 | 13 |
[1.0]: https://en.wikipedia.org/wiki/OpenGL#Version_history |
| 9 | 14 |
[backend]: https://www.khronos.org/opengl/wiki/Related_toolkits_and_APIs#OpenGL_initialization |
| 10 | 15 |
|
| 16 |
+## Usage |
|
| 17 |
+ |
|
| 18 |
+### Overview |
|
| 19 |
+ |
|
| 20 |
+```cpp |
|
| 21 |
+#include <glbackend_default.hpp> |
|
| 22 |
+ |
|
| 23 |
+ |
|
| 24 |
+constexpr auto size = GLBackend::Size{640, 480};
|
|
| 25 |
+ |
|
| 26 |
+ |
|
| 27 |
+int main() |
|
| 28 |
+{
|
|
| 29 |
+ // Create. |
|
| 30 |
+ auto backend = GLBackendDefault("Default", size);
|
|
| 31 |
+ |
|
| 32 |
+ // Render loop. |
|
| 33 |
+ backend.callback_render([&]() |
|
| 34 |
+ {
|
|
| 35 |
+ glClearColor(1.0F, 0.0F, 0.0F, 0.5F); |
|
| 36 |
+ glClear(GL_COLOR_BUFFER_BIT); |
|
| 37 |
+ if (backend.key("Enter"))
|
|
| 38 |
+ backend.tga_write("screenshot.tga");
|
|
| 39 |
+ if (backend.key("Escape"))
|
|
| 40 |
+ backend.running(false); |
|
| 41 |
+ }); |
|
| 42 |
+ backend.run(); |
|
| 43 |
+} |
|
| 44 |
+``` |
|
| 45 |
+ |
|
| 46 |
+### Global settings |
|
| 47 |
+ |
|
| 48 |
+#### Errors |
|
| 49 |
+ |
|
| 50 |
+After backend construction (see [Lifetime](#lifetime)) errors are non-fatal and |
|
| 51 |
+are reported to the output configured with |
|
| 52 |
+ |
|
| 53 |
+``` |
|
| 54 |
+using OutputCallback = std::function<void(std::string const & message)>; |
|
| 55 |
+ |
|
| 56 |
+static std::ostream * output_stream(std::ostream * output_stream); |
|
| 57 |
+static OutputCallback output_callback(OutputCallback output_callback); |
|
| 58 |
+``` |
|
| 59 |
+ |
|
| 60 |
+(defaults to `std::cerr` and empty, respectively). The old values are returned. |
|
| 61 |
+ |
|
| 62 |
+If the backend is constructed with `debug = true` (see [Lifetime](#lifetime)) |
|
| 63 |
+and OpenGL \>=4.3 or the extension [`GL_KHR_debug`][] is available, OpenGL |
|
| 64 |
+debug messages with a severity other than `GL_DEBUG_SEVERITY_NOTIFICATION` are |
|
| 65 |
+also reported using the same output. The messages received from the OpenGL |
|
| 66 |
+implementation are modified slightly to remove trailing whitespace and double |
|
| 67 |
+quotes surrounding file names in lines starting with *"path":line*. |
|
| 68 |
+ |
|
| 69 |
+[`GL_KHR_debug`]: https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_debug.txt |
|
| 70 |
+ |
|
| 71 |
+#### File system |
|
| 72 |
+ |
|
| 73 |
+If the value passed to |
|
| 74 |
+ |
|
| 75 |
+``` |
|
| 76 |
+static std::string directory(std::string directory); |
|
| 77 |
+``` |
|
| 78 |
+ |
|
| 79 |
+is non-empty it is prepended, with a separating `"/"`, to all relative paths |
|
| 80 |
+(defined as paths not starting with `"/"`) given as arguments to other |
|
| 81 |
+functions. The old value is returned. |
|
| 82 |
+ |
|
| 83 |
+### Lifetime |
|
| 84 |
+ |
|
| 85 |
+Constructors [`throw`][] [`std::runtime_error`][] on failure, with a `what()` |
|
| 86 |
+describing the error. |
|
| 87 |
+ |
|
| 88 |
+To use a backend, instantiate the appropriate `Backend`-derived class. Several |
|
| 89 |
+objects can be instantiated, using the same or different underlying backends. |
|
| 90 |
+ |
|
| 91 |
+All the provided `Backend`-derived classes' constructors take the following |
|
| 92 |
+arguments, in this order: |
|
| 93 |
+ |
|
| 94 |
+- Window-related: |
|
| 95 |
+ - `std::string const & title`: The window title. |
|
| 96 |
+ - `int width`: The window width. |
|
| 97 |
+ - `int height`: The window height. |
|
| 98 |
+ - `bool fullscreen = false`: Whether or not to create a fullscreen |
|
| 99 |
+ window. |
|
| 100 |
+ - `bool transparent = false`: Whether or not to use the alpha channel of |
|
| 101 |
+ the default framebuffer to blend with the background. If this is |
|
| 102 |
+ enabled, window decorations are disabled and the window is kept on top |
|
| 103 |
+ of other windows. |
|
| 104 |
+- [Context][]-related: |
|
| 105 |
+ - `bool debug = false`: If `false`, creates a [no error][] context. If |
|
| 106 |
+ `true`, creates a [debug context][], and enables [debug output][]. |
|
| 107 |
+ - `int samples = -1`: The number of samples used in |
|
| 108 |
+ [mutlisample][multisampling] anti-aliasing (MSAA) of the default |
|
| 109 |
+ framebuffer (`-1` lets the implementation decide). |
|
| 110 |
+ - `int version_major = -1`: The major version with which the OpenGL |
|
| 111 |
+ [context][] must be compatible (`-1` lets the implementation decide). |
|
| 112 |
+ - `int version_minor = -1`: The minor version with which the OpenGL |
|
| 113 |
+ [context][] must be compatible (`-1` lets the implementation decide). |
|
| 114 |
+ |
|
| 115 |
+The relevant underlying backend is automatically initialized at instantiation. |
|
| 116 |
+If no other code has initialized that backend, it is guaranteed to be |
|
| 117 |
+terminated when the last instance is destroyed. It is backend-specific if the |
|
| 118 |
+backend is terminated even if other code has initialized it. |
|
| 119 |
+ |
|
| 120 |
+The provided `Backend`s create double buffered, 32 bit color (including alpha), |
|
| 121 |
+24 bit depth, 8 bit stencil OpenGL [context][]s. If the requested version is |
|
| 122 |
+\>=3.2 a [forward compatible][] core context is created. |
|
| 123 |
+ |
|
| 124 |
+The `Backend`s are move(-constructible)-only types. |
|
| 125 |
+ |
|
| 126 |
+[`throw`]: https://en.cppreference.com/w/cpp/language/throw |
|
| 127 |
+[`std::runtime_error`]: https://en.cppreference.com/w/cpp/error/runtime_error |
|
| 128 |
+[context]: https://www.khronos.org/opengl/wiki/OpenGL_Context |
|
| 129 |
+[debug context]: https://www.khronos.org/opengl/wiki/Debug_Context |
|
| 130 |
+[debug output]: https://www.khronos.org/opengl/wiki/Debug_Output |
|
| 131 |
+[no error]: https://www.khronos.org/opengl/wiki/OpenGL_Context#No_error_contexts |
|
| 132 |
+[multisampling]: https://www.khronos.org/opengl/wiki/Multisampling |
|
| 133 |
+[forward compatible]: https://www.khronos.org/opengl/wiki/OpenGL_Context#Forward_compatibility |
|
| 134 |
+ |
|
| 135 |
+### Info |
|
| 136 |
+ |
|
| 137 |
+``` |
|
| 138 |
+std::string info() const; |
|
| 139 |
+``` |
|
| 140 |
+ |
|
| 141 |
+returns information about the underlying backend. |
|
| 142 |
+ |
|
| 143 |
+### Context |
|
| 144 |
+ |
|
| 145 |
+Each `Backend` instance has its own OpenGL [context][], which is made current |
|
| 146 |
+at instantiation. If several `Backend`s are used, |
|
| 147 |
+ |
|
| 148 |
+``` |
|
| 149 |
+void current(); |
|
| 150 |
+``` |
|
| 151 |
+ |
|
| 152 |
+can be called to make the context of a specific one current. |
|
| 153 |
+ |
|
| 154 |
+### Render loop |
|
| 155 |
+ |
|
| 156 |
+``` |
|
| 157 |
+void events(); |
|
| 158 |
+``` |
|
| 159 |
+ |
|
| 160 |
+handles events from the underlying backend. |
|
| 161 |
+ |
|
| 162 |
+``` |
|
| 163 |
+void swap(); |
|
| 164 |
+``` |
|
| 165 |
+ |
|
| 166 |
+swaps the OpenGL default framebuffer. |
|
| 167 |
+ |
|
| 168 |
+``` |
|
| 169 |
+bool running() const; |
|
| 170 |
+bool running(bool running); |
|
| 171 |
+``` |
|
| 172 |
+ |
|
| 173 |
+queries and sets, respectively, the window "running" state. |
|
| 174 |
+ |
|
| 175 |
+``` |
|
| 176 |
+float time() const; |
|
| 177 |
+float time(float time); |
|
| 178 |
+``` |
|
| 179 |
+ |
|
| 180 |
+queries and sets, respectively, the current time, in seconds. |
|
| 181 |
+ |
|
| 182 |
+``` |
|
| 183 |
+using Update = std::function<void(float t, float dt, bool final)>; |
|
| 184 |
+using Render = std::function<void()>; |
|
| 185 |
+ |
|
| 186 |
+Backend & update(Update const & update); |
|
| 187 |
+Backend & render(Render const & render); |
|
| 188 |
+``` |
|
| 189 |
+ |
|
| 190 |
+sets the `update` and `render` callbacks, respectively, used by |
|
| 191 |
+ |
|
| 192 |
+``` |
|
| 193 |
+void run(float dt_max = 0.0F); |
|
| 194 |
+``` |
|
| 195 |
+ |
|
| 196 |
+which is a convenience function that uses the member functions and callbacks |
|
| 197 |
+described in this section to implement a render loop. `t` is the current time, |
|
| 198 |
+which is set to `0.0F` at the start of `run`. If `dt_max` is `0.0F`, the |
|
| 199 |
+`update` callback is called once for every frame, with `dt` holding the elapsed |
|
| 200 |
+time. Otherwise, the `update` callback is called as many times as necessary to |
|
| 201 |
+advance through the elapsed time while ensuring `dt` is never larger than |
|
| 202 |
+`dt_max`. `final` is `true` if this is the final update of the frame. `render` |
|
| 203 |
+is called at the end of each frame. Either of the callbacks can be unset. |
|
| 204 |
+ |
|
| 205 |
+### Input and output |
|
| 206 |
+ |
|
| 207 |
+``` |
|
| 208 |
+void lock(bool lock); |
|
| 209 |
+``` |
|
| 210 |
+ |
|
| 211 |
+controls mouse locking. If `true` is passed the mouse is locked, which means it |
|
| 212 |
+is hidden and prevented from leaving the window. Passing `false` restores the |
|
| 213 |
+normal behavior. |
|
| 214 |
+ |
|
| 215 |
+The input (keyboard and mouse) and output (framebuffer) state can be accessed |
|
| 216 |
+in two different ways: registering callbacks and / or polling. The same |
|
| 217 |
+function name is used for both methods (with function overloading). These are |
|
| 218 |
+described below. |
|
| 219 |
+ |
|
| 220 |
+#### Keyboard |
|
| 221 |
+ |
|
| 222 |
+The |
|
| 223 |
+ |
|
| 224 |
+``` |
|
| 225 |
+key |
|
| 226 |
+``` |
|
| 227 |
+ |
|
| 228 |
+*callback / poll* takes as argument a `std::string const & key` and *is called |
|
| 229 |
+when / returns `true` if* that key is pressed. Valid arguments are |
|
| 230 |
+backend-specific but guaranteed to support: |
|
| 231 |
+ |
|
| 232 |
+- `"A"` through `"Z"` |
|
| 233 |
+- `"0"` through `"9"` |
|
| 234 |
+- `"Left"`, `"Right"`, `"Up"`, `"Down"` |
|
| 235 |
+- `"Enter"`, `"Escape"`, `"Tab"`, `"Backspace"` |
|
| 236 |
+- `"Control"`, `"Shift"`, `"Alt"` |
|
| 237 |
+ |
|
| 238 |
+#### Mouse |
|
| 239 |
+ |
|
| 240 |
+The |
|
| 241 |
+ |
|
| 242 |
+``` |
|
| 243 |
+button |
|
| 244 |
+``` |
|
| 245 |
+ |
|
| 246 |
+*callback / poll* takes as argument an `int button` and *is called when / |
|
| 247 |
+returns `true` if* that button is pressed. Valid arguments are backend-specific |
|
| 248 |
+but guaranteed to support `1`, `2`, and `3`. |
|
| 249 |
+ |
|
| 250 |
+The |
|
| 251 |
+ |
|
| 252 |
+``` |
|
| 253 |
+scroll |
|
| 254 |
+``` |
|
| 255 |
+ |
|
| 256 |
+*callback / poll* takes as *argument / returns* `std::array<float, 2> scroll`. |
|
| 257 |
+ |
|
| 258 |
+The |
|
| 259 |
+ |
|
| 260 |
+``` |
|
| 261 |
+position |
|
| 262 |
+``` |
|
| 263 |
+ |
|
| 264 |
+*callback / poll* takes as *argument / returns* `std::array<float, 2> |
|
| 265 |
+position`. |
|
| 266 |
+ |
|
| 267 |
+The |
|
| 268 |
+ |
|
| 269 |
+``` |
|
| 270 |
+move |
|
| 271 |
+``` |
|
| 272 |
+ |
|
| 273 |
+*callback / poll* takes as *argument / returns* `std::array<float, 2> move`. |
|
| 274 |
+ |
|
| 275 |
+#### Framebuffer |
|
| 276 |
+ |
|
| 277 |
+The |
|
| 278 |
+ |
|
| 279 |
+``` |
|
| 280 |
+size |
|
| 281 |
+``` |
|
| 282 |
+ |
|
| 283 |
+*callback / poll* takes as *argument / returns* `std::array<int, 2> size`. |
|
| 284 |
+ |
|
| 285 |
+### Persisting frames |
|
| 286 |
+ |
|
| 287 |
+There is basic support for writing frames to disk, useful for testing or |
|
| 288 |
+screenshot functionality. |
|
| 289 |
+ |
|
| 290 |
+Writing is done with |
|
| 291 |
+ |
|
| 292 |
+``` |
|
| 293 |
+bool frame_tga_write( |
|
| 294 |
+ std::string const & path |
|
| 295 |
+) const; |
|
| 296 |
+``` |
|
| 297 |
+ |
|
| 298 |
+As the name suggests, the frame is written as an uncompressed [BGRA][] |
|
| 299 |
+[Truevision TGA][] image, selected because it is widely supported and has a |
|
| 300 |
+trivial header and data layout. The function returns `true` on success, on |
|
| 301 |
+failure an [error](#errors) is emitted and `false` is returned. |
|
| 302 |
+ |
|
| 303 |
+``` |
|
| 304 |
+bool frame_tga_compare( |
|
| 305 |
+ std::string const & path, |
|
| 306 |
+ bool write_on_failed_read = false |
|
| 307 |
+) const; |
|
| 308 |
+``` |
|
| 309 |
+ |
|
| 310 |
+can be used to compare the current frame to one written previously. Note that a |
|
| 311 |
+general TGA reader is not used; the comparison is done byte for byte, header |
|
| 312 |
+included. If the given `path` cannot be read an [error](#errors) is emitted and |
|
| 313 |
+if `write_on_failed_read` is `true` the current frame is instead written to |
|
| 314 |
+`path`. |
|
| 315 |
+ |
|
| 316 |
+`".tga"` is automatically added to the end of `path`. In addition, `directory` |
|
| 317 |
+is applied if appropriate, see [File system](#file-system). |
|
| 318 |
+ |
|
| 319 |
+No function is provided to read the frame without interacting with the file |
|
| 320 |
+system. If this is required, simply use [`glReadPixels`][]. |
|
| 321 |
+ |
|
| 322 |
+[BGRA]: https://en.wikipedia.org/wiki/RGBA_color_model |
|
| 323 |
+[Truevision TGA]: https://en.wikipedia.org/wiki/Truevision_TGA |
|
| 324 |
+[`glReadPixels`]: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glReadPixels.xhtml |
|
| 325 |
+ |
|
| 11 | 326 |
## Dependencies |
| 12 | 327 |
|
| 13 | 328 |
System dependencies that need to be installed: |
| ... | ... |
@@ -8,6 +8,107 @@ A [C++11][]/[OpenGL][] \>=[1.0][] [backend][] library. |
| 8 | 8 |
[1.0]: https://en.wikipedia.org/wiki/OpenGL#Version_history |
| 9 | 9 |
[backend]: https://www.khronos.org/opengl/wiki/Related_toolkits_and_APIs#OpenGL_initialization |
| 10 | 10 |
|
| 11 |
+## Dependencies |
|
| 12 |
+ |
|
| 13 |
+System dependencies that need to be installed: |
|
| 14 |
+ |
|
| 15 |
+- Public (interface): |
|
| 16 |
+ - [OpenGL][] (e.g. [`libgl1-mesa-dev`][]). |
|
| 17 |
+ - [OpenGL Extension Wrangler (GLEW)][] (e.g. [`libglew-dev`][]). |
|
| 18 |
+ |
|
| 19 |
+[OpenGL Extension Wrangler (GLEW)]: http://glew.sourceforge.net |
|
| 20 |
+[`libgl1-mesa-dev`]: https://packages.debian.org/search?keywords=libgl1-mesa-dev |
|
| 21 |
+[`libglew-dev`]: https://packages.debian.org/search?keywords=libglew-dev |
|
| 22 |
+ |
|
| 23 |
+## Build system |
|
| 24 |
+ |
|
| 25 |
+This project supports [CMake][] and uses [`cmake-common`][]. There are several |
|
| 26 |
+ways to use it in other CMake-based projects: |
|
| 27 |
+ |
|
| 28 |
+- With [`find_package`][]: ([Package][] and) [install][] it on the system. |
|
| 29 |
+ |
|
| 30 |
+- With [`add_subdirectory`][]: Bundle it. |
|
| 31 |
+ |
|
| 32 |
+- With [`FetchContent`][]: Download it as part of the CMake configure step. |
|
| 33 |
+ |
|
| 34 |
+- With [`cmake-common`][]: Use any of the above methods through a simplified |
|
| 35 |
+ interface. |
|
| 36 |
+ |
|
| 37 |
+As usual, use [`add_dependencies`][] or [`target_link_libraries`][] (or |
|
| 38 |
+`cmake-common`'s `DEPENDENCIES_*`) to declare the dependency. |
|
| 39 |
+ |
|
| 40 |
+[CMake]: https://cmake.org |
|
| 41 |
+[`cmake-common`]: https://git.rcrnstn.net/rcrnstn/cmake-common |
|
| 42 |
+[`FetchContent`]: https://cmake.org/cmake/help/v3.14/module/FetchContent.html |
|
| 43 |
+[`add_subdirectory`]: https://cmake.org/cmake/help/v3.14/command/add_subdirectory.html |
|
| 44 |
+[`find_package`]: https://cmake.org/cmake/help/v3.14/command/find_package.html |
|
| 45 |
+[Package]: #Package |
|
| 46 |
+[Install]: #Install |
|
| 47 |
+[`add_dependencies`]: https://cmake.org/cmake/help/v3.14/command/add_dependencies.html |
|
| 48 |
+[`target_link_libraries`]: https://cmake.org/cmake/help/v3.14/command/target_link_libraries.html |
|
| 49 |
+ |
|
| 50 |
+### Configure and generate |
|
| 51 |
+ |
|
| 52 |
+To configure and generate a build tree, use `cmake`: |
|
| 53 |
+ |
|
| 54 |
+```sh |
|
| 55 |
+cmake -B _build |
|
| 56 |
+``` |
|
| 57 |
+ |
|
| 58 |
+To set the build type, pass e.g. `-D`[`CMAKE_BUILD_TYPE`][]`=Release`. |
|
| 59 |
+ |
|
| 60 |
+[`cmake`]: https://cmake.org/cmake/help/v3.14/manual/cmake.1.html#generate-a-project-buildsystem |
|
| 61 |
+[`CMAKE_BUILD_TYPE`]: https://cmake.org/cmake/help/v3.14/variable/CMAKE_BUILD_TYPE.html |
|
| 62 |
+ |
|
| 63 |
+### Build |
|
| 64 |
+ |
|
| 65 |
+To build, use [`cmake --build`][]: |
|
| 66 |
+ |
|
| 67 |
+```sh |
|
| 68 |
+cmake --build _build |
|
| 69 |
+``` |
|
| 70 |
+ |
|
| 71 |
+To disable building tests, pass `-D`[`BUILD_TESTING`][]`=OFF`. |
|
| 72 |
+ |
|
| 73 |
+[`cmake --build`]: https://cmake.org/cmake/help/v3.14/manual/cmake.1.html#build-a-project |
|
| 74 |
+[`BUILD_TESTING`]: https://cmake.org/cmake/help/v3.14/module/CTest.html |
|
| 75 |
+ |
|
| 76 |
+### Test |
|
| 77 |
+ |
|
| 78 |
+To run tests, use [`ctest`][]: |
|
| 79 |
+ |
|
| 80 |
+```sh |
|
| 81 |
+(cd _build && ctest) |
|
| 82 |
+``` |
|
| 83 |
+ |
|
| 84 |
+To show output from failing tests, pass `--output-on-failure`. To show output |
|
| 85 |
+from all tests, pass `--verbose`. |
|
| 86 |
+ |
|
| 87 |
+[`ctest`]: https://cmake.org/cmake/help/v3.14/manual/ctest.1.html |
|
| 88 |
+ |
|
| 89 |
+### Package |
|
| 90 |
+ |
|
| 91 |
+To package, use [`cpack`][]: |
|
| 92 |
+ |
|
| 93 |
+```sh |
|
| 94 |
+(cd _build && cpack) |
|
| 95 |
+``` |
|
| 96 |
+ |
|
| 97 |
+[`cpack`]: https://cmake.org/cmake/help/v3.14/manual/cpack.1.html |
|
| 98 |
+ |
|
| 99 |
+### Install |
|
| 100 |
+ |
|
| 101 |
+To install onto the current system, use [`cmake --install`][]: |
|
| 102 |
+ |
|
| 103 |
+```sh |
|
| 104 |
+cmake --install _build |
|
| 105 |
+``` |
|
| 106 |
+ |
|
| 107 |
+To set the prefix, pass e.g. `-D`[`CMAKE_INSTALL_PREFIX`][]`="$HOME/.local"`. |
|
| 108 |
+ |
|
| 109 |
+[`cmake --install`]: https://cmake.org/cmake/help/v3.14/manual/cmake.1.html#install-a-project |
|
| 110 |
+[`CMAKE_INSTALL_PREFIX`]: https://cmake.org/cmake/help/v3.14/variable/CMAKE_INSTALL_PREFIX.html |
|
| 111 |
+ |
|
| 11 | 112 |
## License |
| 12 | 113 |
|
| 13 | 114 |
Licensed under the [ISC License][] unless otherwise noted, see the |
| ... | ... |
@@ -7,3 +7,11 @@ A [C++11][]/[OpenGL][] \>=[1.0][] [backend][] library. |
| 7 | 7 |
[OpenGL]: https://en.wikipedia.org/wiki/OpenGL |
| 8 | 8 |
[1.0]: https://en.wikipedia.org/wiki/OpenGL#Version_history |
| 9 | 9 |
[backend]: https://www.khronos.org/opengl/wiki/Related_toolkits_and_APIs#OpenGL_initialization |
| 10 |
+ |
|
| 11 |
+## License |
|
| 12 |
+ |
|
| 13 |
+Licensed under the [ISC License][] unless otherwise noted, see the |
|
| 14 |
+[`LICENSE`][] file. |
|
| 15 |
+ |
|
| 16 |
+[ISC License]: https://choosealicense.com/licenses/isc |
|
| 17 |
+[`LICENSE`]: LICENSE |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,9 @@ |
| 1 |
+# [`glbackend`][] |
|
| 2 |
+ |
|
| 3 |
+A [C++11][]/[OpenGL][] \>=[1.0][] [backend][] library. |
|
| 4 |
+ |
|
| 5 |
+[`glbackend`]: https://git.rcrnstn.net/rcrnstn/glbackend |
|
| 6 |
+[C++11]: https://en.wikipedia.org/wiki/C++11 |
|
| 7 |
+[OpenGL]: https://en.wikipedia.org/wiki/OpenGL |
|
| 8 |
+[1.0]: https://en.wikipedia.org/wiki/OpenGL#Version_history |
|
| 9 |
+[backend]: https://www.khronos.org/opengl/wiki/Related_toolkits_and_APIs#OpenGL_initialization |