Skip to content

Commit

Permalink
No longer including gl.h globally, renamed own assert.
Browse files Browse the repository at this point in the history
  • Loading branch information
xythobuz committed Mar 26, 2015
1 parent ca1c94a commit 9121091
Show file tree
Hide file tree
Showing 47 changed files with 432 additions and 410 deletions.
49 changes: 27 additions & 22 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,121 +2,126 @@

## OpenRaider (0.1.4) xythobuz <xythobuz@xythobuz.de>

[ 20140318 ]
[ 20150326 ]
* No longer including gl.h globally, now only using gl33.h where needed.
* No longer including all of glm globally, only the vec2/3/4 and mat4x4.
* No longer re-defining our own assert(), now called orAssert().

[ 20150318 ]
* Updated imgui to version 1.36
* Can now display all compiled/linked library versions
* GLFW windowing interface now supports proper text input

[ 20140313 ]
[ 20150313 ]
* Renderer now limits room list size
* Updated Doxyfile template to current Doxygen version
* Improved documentation

## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>

[ 20140312 ]
[ 20150312 ]
* Now including imguifilesystem dependency
* Completely re-wrote Main menu, now reading TOMBPC.DAT scripts
* Main menu is now just a full-screen ImGui window

[ 20140310 ]
[ 20150310 ]
* Tried to fix moveable loading. Fixed TR1 angle parser, but still not working better.

[ 20140309 ]
[ 20150309 ]
* Removed (unused) SSE support script
* Added level loading notification in main menu
* Can now start/stop individual SoundSources
* Added SoundDetail debug UI, improved SoundSources debug UI
* Updated imgui to version 1.35

[ 20140307 ]
[ 20150307 ]
* Can now load all TR3 levels without crashing
* Sound Sources now working, with (more or less) proper 3D Sound
* Fixed bug that caused entities to display the wrong object
* Improved Debug UI
* Updated imgui

[ 20140306 ]
[ 20150306 ]
* Fixed LoaderTR1, can now also open the Unfinished Business levels
* Walk key can now be used to increase free-camera movement speed
* Removed color definitions in global.h
* Font interface now using glm::vec4 float colors
* Hard-coded controller mapping now supports all available ActionEvents
* Fixed TR3 level loading. Only some levels with invalid SoundSources still crash.

[ 20140305 ]
[ 20150305 ]
* SoundAL now has more useful error message output.
* Fixed TR1 color map parsing, now textures have the proper color values.
* Fixed TR1 sound sample parsing. Can now load all TR1 levels without crashing.
* Improved parsing and summaries in binspector level reading script.

[ 20140304 ]
[ 20150304 ]
* Added (more or less working) support for loading TR1 levels
* Updated imgui

[ 20140222 ]
[ 20150222 ]
* Updated imgui to version 1.33

[ 20140219 ]
[ 20150219 ]
* Started implementing ability to render into textures (mainly for debugging)
* Started implementing camera movement room tracking
* Started implementing camera look-at target overlay UI

[ 20140213 ]
[ 20150213 ]
* The menu can be navigated using a controller
* Vertical camera rotation is now also clamped when using a controller
* Worked on rendering SkeletalModels, not yet working correctly
* Implemented level loader for TR3, but tries to access invalid textiles

[ 20140211 ]
[ 20150211 ]
* Updated imgui to version 1.32
* Included some SDL game controller configurations
* Camera movement speed is now clamped when moving in multiple directions
* Slightly increased controller dead-zone, now 0.2

[ 20140204 ]
[ 20150204 ]
* Return of textile, animated textile and sprite viewer, in TextureManager

[ 20140203 ]
[ 20150203 ]
* Updated imgui to newest version, supporting Images
* Texture viewer is back, using imgui Images

[ 20140124 ]
[ 20150124 ]
* Started working on Entity system.

[ 20140118 ]
[ 20150118 ]
* Added ability to visualize font _outline_.
* Updated imgui to newest version, now with its own TTF support.
* Fixed drawing of camera view frustum.
* Added support for imgui/SDLs IME text input rectangle.

[ 20140117 ]
[ 20150117 ]
* Updated imgui, fix for Logging to Clipboard included.
* Sprites and SpriteSequences are now stored independently in World.
* Added support for Room Sprites displaying.
* Can now toggle display of Room geometry, models and sprites.
* Room list is now displayed in reverse. This _fixes_ some transparency issues.
* Fixed a bug that sometimes caused distorted Screenshots.

[ 20140111 ]
[ 20150111 ]
* Enabled back face culling --> triangles now oriented correctly
* Game is now completely static
* Shaders drawGL methods can now be given a specific Shader instance.
* Log now manages different log levels. Console displays them colored.
* Console can now log to the TTY, the clipboard or a file.
* Added system clipboard support for imgui in both WindowSDL and WindowGLFW.

[ 20140109 ]
[ 20150109 ]
* Display of Bounding Boxes can be individually toggled for Rooms/StaticMeshes
* Tightened imgui Style and changed colors to match the _OpenRaider-blue_

[ 20140108 ]
[ 20150108 ]
* FPS and Camera position now displayed in imgui Overlay
* Removed many unnecessary includes
* Camera now using combination of quaternion and X/Y angle.
* Fixes strange bug that sometimes rotated Camera on Z Axis.

[ 20140107 ]
[ 20150107 ]
* Fixed problems with FontTTFs Glyph Baseline
* No longer using wrong assert() when glm is included
* Updated imgui, now Version 1.20
Expand Down
5 changes: 1 addition & 4 deletions cmake/travis_script_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.5"; fi
#curl -L https://github.com/hpicgs/glbinding/archive/${GLBVER}.tar.gz | tar xzf -
#cd glbinding-${GLBVER#v}

# Hacky fix to allow building glbinding with clang on Linux
#sed -i 's/ -Werror/ /g' cmake/PlatformLinuxGCC.cmake

# Try fix in glbinding master
# Need to use master until a fixed version is released
git clone https://github.com/hpicgs/glbinding.git
cd glbinding

Expand Down
8 changes: 4 additions & 4 deletions include/RoomData.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class BoundingBox {
}

glm::vec3 getCorner(int i) {
assertGreaterThanEqual(i, 0);
assertLessThan(i, 8);
orAssertGreaterThanEqual(i, 0);
orAssertLessThan(i, 8);
return corner[i];
}

Expand Down Expand Up @@ -84,8 +84,8 @@ class Portal {
glm::vec3 getNormal() { return normal; }

glm::vec3 getVertex(int i) {
assertGreaterThanEqual(i, 0);
assertLessThan(i, 4);
orAssertGreaterThanEqual(i, 0);
orAssertLessThan(i, 4);
return vert[i];
}

Expand Down
81 changes: 35 additions & 46 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,21 @@ typedef enum {
unknownKey // Should always be at the end
} KeyboardButton;

// Globally include OpenGL header
#include <glbinding/gl/gl.h>
#include <glbinding/Binding.h>
using namespace gl;

/*! \fixme Is there a better way to handle this?
* We wan't to use our own assert(). Unfortunately, glm includes
* cassert in its headers. So we need to define NDEBUG here.
* To avoid a conflict, our flag is now called NODEBUG instead.
*/
#define NDEBUG
#include <glm/glm.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <glm/mat4x4.hpp>

// If available, use our own assert that prints the call stack
#if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS)

#ifndef NODEBUG
#ifndef NDEBUG

#include <iostream>
#include <execinfo.h>

template<typename T, typename U>
[[noreturn]] void assertEqualImplementation(const char* exp, T a, U b, const char* file, int line,
[[noreturn]] void orAssertImplementation(const char* exp, T a, U b, const char* file, int line,
const char* str = nullptr) {
const unsigned int maxSize = 128;
void* callstack[maxSize];
Expand All @@ -108,85 +100,82 @@ template<typename T, typename U>
abort();
}

// Evaluating x or y could have side-effects
// So we only do it once!

#define assert(x) { \
#define orAssert(x) { \
auto assertEvalTemp = x; \
if (!assertEvalTemp) \
assertEqualImplementation(#x, assertEvalTemp, true, __FILE__, __LINE__); \
orAssertImplementation(#x, assertEvalTemp, true, __FILE__, __LINE__); \
}

#define assertEqual(x, y) { \
#define orAssertEqual(x, y) { \
auto assertEvalTemp = x; \
auto assertEvalTemp2 = y; \
if (assertEvalTemp != assertEvalTemp2) \
assertEqualImplementation(#x " == " #y, assertEvalTemp, assertEvalTemp2, \
orAssertImplementation(#x " == " #y, assertEvalTemp, assertEvalTemp2, \
__FILE__, __LINE__, "!="); \
}

#define assertNotEqual(x, y) { \
#define orAssertNotEqual(x, y) { \
auto assertEvalTemp = x; \
auto assertEvalTemp2 = y; \
if (assertEvalTemp == assertEvalTemp2) \
assertEqualImplementation(#x " != " #y, assertEvalTemp, assertEvalTemp2, \
orAssertImplementation(#x " != " #y, assertEvalTemp, assertEvalTemp2, \
__FILE__, __LINE__, "=="); \
}

#define assertLessThan(x, y) { \
#define orAssertLessThan(x, y) { \
auto assertEvalTemp = x; \
auto assertEvalTemp2 = y; \
if (assertEvalTemp >= assertEvalTemp2) \
assertEqualImplementation(#x " < " #y, assertEvalTemp, assertEvalTemp2, \
orAssertImplementation(#x " < " #y, assertEvalTemp, assertEvalTemp2, \
__FILE__, __LINE__, ">="); \
}

#define assertLessThanEqual(x, y) { \
#define orAssertLessThanEqual(x, y) { \
auto assertEvalTemp = x; \
auto assertEvalTemp2 = y; \
if (assertEvalTemp > assertEvalTemp2) \
assertEqualImplementation(#x " <= " #y, assertEvalTemp, assertEvalTemp2, \
orAssertImplementation(#x " <= " #y, assertEvalTemp, assertEvalTemp2, \
__FILE__, __LINE__, ">"); \
}

#define assertGreaterThan(x, y) { \
#define orAssertGreaterThan(x, y) { \
auto assertEvalTemp = x; \
auto assertEvalTemp2 = y; \
if (assertEvalTemp <= assertEvalTemp2) \
assertEqualImplementation(#x " > " #y, assertEvalTemp, assertEvalTemp2, \
orAssertImplementation(#x " > " #y, assertEvalTemp, assertEvalTemp2, \
__FILE__, __LINE__, "<="); \
}

#define assertGreaterThanEqual(x, y) { \
#define orAssertGreaterThanEqual(x, y) { \
auto assertEvalTemp = x; \
auto assertEvalTemp2 = y; \
if (assertEvalTemp < assertEvalTemp2) \
assertEqualImplementation(#x " >= " #y, assertEvalTemp, assertEvalTemp2, \
orAssertImplementation(#x " >= " #y, assertEvalTemp, assertEvalTemp2, \
__FILE__, __LINE__, "<"); \
}

#else // NODEBUG
#else // NDEBUG

#define assert(x)
#define assertEqual(x, y)
#define assertNotEqual(x, y)
#define assertLessThan(x, y)
#define assertLessThanEqual(x, y)
#define assertGreaterThan(x, y)
#define assertGreaterThanEqual(x, y)
#define orAssert(x)
#define orAssertEqual(x, y)
#define orAssertNotEqual(x, y)
#define orAssertLessThan(x, y)
#define orAssertLessThanEqual(x, y)
#define orAssertGreaterThan(x, y)
#define orAssertGreaterThanEqual(x, y)

#endif // NODEBUG
#endif // NDEBUG

#else // EXECINFO

// Fall back to the default C assert
#include <cassert>
#define assertEqual(x, y) assert((x) == (y))
#define assertNotEqual(x, y) assert((x) != (y))
#define assertLessThan(x, y) assert((x) < (y))
#define assertLessThanEqual(x, y) assert((x) <= (y))
#define assertGreaterThan(x, y) assert((x) > (y))
#define assertGreaterThanEqual(x, y) assert((x) >= (y))
#define orAssertEqual(x, y) assert((x) == (y))
#define orAssertNotEqual(x, y) assert((x) != (y))
#define orAssertLessThan(x, y) assert((x) < (y))
#define orAssertLessThanEqual(x, y) assert((x) <= (y))
#define orAssertGreaterThan(x, y) assert((x) > (y))
#define orAssertGreaterThanEqual(x, y) assert((x) >= (y))

#endif // EXECINFO

Expand Down
1 change: 1 addition & 0 deletions include/loader/Loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Loader {
static LoaderVersion checkFile(std::string f);
static std::unique_ptr<Loader> createLoader(std::string f);

virtual ~Loader();
virtual int load(std::string f) = 0;

protected:
Expand Down
10 changes: 6 additions & 4 deletions include/system/Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include "TextureManager.h"

#include <glbinding/gl/gl33.h>

class ShaderBuffer {
public:
ShaderBuffer() : created(false), buffer(0), boundSize(0) { }
Expand All @@ -28,7 +30,7 @@ class ShaderBuffer {
void bindBuffer(int location, int size);
void unbind(int location);

unsigned int getBuffer() { assert(created); return buffer; }
unsigned int getBuffer() { orAssert(created); return buffer; }
int getSize() { return boundSize; }

private:
Expand Down Expand Up @@ -74,7 +76,7 @@ class Shader {
static void set2DState(bool on, bool depth = true);

static void drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, glm::vec4 color, unsigned int texture,
TextureStorage store = TextureStorage::SYSTEM, GLenum = GL_TRIANGLES,
TextureStorage store = TextureStorage::SYSTEM, gl::GLenum = gl::GL_TRIANGLES,
ShaderTexture* target = nullptr, Shader& shader = textShader);

static void drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, unsigned int texture, glm::mat4 MVP,
Expand All @@ -86,10 +88,10 @@ class Shader {
Shader& shader = textureShader);

static void drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, glm::mat4 MVP,
GLenum mode = GL_TRIANGLES, ShaderTexture* target = nullptr,
gl::GLenum mode = gl::GL_TRIANGLES, ShaderTexture* target = nullptr,
Shader& shader = colorShader);
static void drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, ShaderBuffer& indices,
glm::mat4 MVP, GLenum mode = GL_TRIANGLES, ShaderTexture* target = nullptr,
glm::mat4 MVP, gl::GLenum mode = gl::GL_TRIANGLES, ShaderTexture* target = nullptr,
Shader& shader = colorShader);

static std::string getVersion(bool linked);
Expand Down
2 changes: 1 addition & 1 deletion include/system/SoundAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SoundAL {
static int loadBuffer(unsigned char* buffer, unsigned int length);

static int numSources(bool atListener);
static int addSource(int buffer, float volume, bool atListener, bool loop);
static int addSource(int buffer, float vol, bool atListener, bool loop);

static int sourceAt(int source, glm::vec3 pos);
static void listenAt(glm::vec3 pos, glm::vec3 at, glm::vec3 up);
Expand Down
2 changes: 1 addition & 1 deletion include/system/WindowGLFW.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <string>
#include <glm/gtc/type_precision.hpp>

class GLFWwindow;
struct GLFWwindow;

class WindowGLFW {
public:
Expand Down
Loading

0 comments on commit 9121091

Please sign in to comment.