diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-02-16 16:04:32 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-02-16 16:04:32 -0500 |
| commit | ed08b673c50b076042d8f0c49501372168142764 (patch) | |
| tree | 18ecda99942ef11ce4023c3ad4437976f96b75da /src/util.h | |
| parent | 224645d1071c14b4829dbb3ae35870868fcff85a (diff) | |
| download | therapy-ed08b673c50b076042d8f0c49501372168142764.tar.gz therapy-ed08b673c50b076042d8f0c49501372168142764.tar.bz2 therapy-ed08b673c50b076042d8f0c49501372168142764.zip | |
Refactored renderer
Renderer is basically now more C++'y, as it makes more use of classes (a lot of GL types have been wrapped), and the renderer itself is now a class. The monitor mesh is also now indexed. Tweaked the NTSC artifacting after inadvertently fixing a bug with the way the image was loaded.
Diffstat (limited to 'src/util.h')
| -rw-r--r-- | src/util.h | 41 |
1 files changed, 41 insertions, 0 deletions
| diff --git a/src/util.h b/src/util.h new file mode 100644 index 0000000..72cb0d3 --- /dev/null +++ b/src/util.h | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | #ifndef ALGORITHMS_H_1DDC517E | ||
| 2 | #define ALGORITHMS_H_1DDC517E | ||
| 3 | |||
| 4 | #include <fstream> | ||
| 5 | #include <sstream> | ||
| 6 | #include <cstring> | ||
| 7 | |||
| 8 | template< typename ContainerT, typename PredicateT > | ||
| 9 | void erase_if( ContainerT& items, const PredicateT& predicate ) { | ||
| 10 | for( auto it = items.begin(); it != items.end(); ) { | ||
| 11 | if( predicate(*it) ) it = items.erase(it); | ||
| 12 | else ++it; | ||
| 13 | } | ||
| 14 | }; | ||
| 15 | |||
| 16 | struct chlit | ||
| 17 | { | ||
| 18 | chlit(char c) : c_(c) { } | ||
| 19 | char c_; | ||
| 20 | }; | ||
| 21 | |||
| 22 | inline std::istream& operator>>(std::istream& is, chlit x) | ||
| 23 | { | ||
| 24 | char c; | ||
| 25 | if (is >> c && c != x.c_) | ||
| 26 | { | ||
| 27 | is.setstate(std::iostream::failbit); | ||
| 28 | } | ||
| 29 | |||
| 30 | return is; | ||
| 31 | } | ||
| 32 | |||
| 33 | std::string slurp(std::ifstream& in); | ||
| 34 | |||
| 35 | void flipImageData( | ||
| 36 | unsigned char* data, | ||
| 37 | int width, | ||
| 38 | int height, | ||
| 39 | int comps); | ||
| 40 | |||
| 41 | #endif /* end of include guard: ALGORITHMS_H_1DDC517E */ | ||
