From d8cfc1d8bc57c6b786fb18df96a5f870fa54c7bd Mon Sep 17 00:00:00 2001 From: "David R. MacIver" Date: Tue, 23 May 2017 10:03:42 +0100 Subject: [PATCH 1/4] Add error code to failure to initialize display --- common.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/common.cpp b/common.cpp index 8e8a2e1..00747ed 100644 --- a/common.cpp +++ b/common.cpp @@ -3,6 +3,26 @@ #include +const char *gl_error_to_str(EGLint error){ + switch(error){ + case EGL_SUCCESS: return "EGL_SUCCESS"; + case EGL_NOT_INITIALIZED: return "EGL_NOT_INITIALIZED"; + case EGL_BAD_ACCESS: return "EGL_BAD_ACCESS"; + case EGL_BAD_ALLOC: return "EGL_BAD_ALLOC"; + case EGL_BAD_ATTRIBUTE: return "EGL_BAD_ATTRIBUTE"; + case EGL_BAD_CONTEXT: return "EGL_BAD_CONTEXT"; + case EGL_BAD_CONFIG: return "EGL_BAD_CONFIG"; + case EGL_BAD_CURRENT_SURFACE: return "EGL_BAD_CURRENT_SURFACE"; + case EGL_BAD_DISPLAY: return "EGL_BAD_DISPLAY"; + case EGL_BAD_MATCH: return "EGL_BAD_MATCH"; + case EGL_BAD_PARAMETER: return "EGL_BAD_PARAMETER"; + case EGL_BAD_NATIVE_PIXMAP: return "EGL_BAD_NATIVE_PIXMAP"; + case EGL_BAD_NATIVE_WINDOW: return "EGL_BAD_NATIVE_WINDOW"; + case EGL_CONTEXT_LOST: return "EGL_CONTEXT_LOST"; + default: return "BAD ERROR"; + } +} + bool init_gl( const int width, const int height, @@ -48,7 +68,7 @@ bool init_gl( EGLint minor; if(eglInitialize(display, &major, &minor) == EGL_FALSE) { - std::cerr << "eglInitialize failed." << std::endl; + std::cerr << "eglInitialize failed with " << gl_error_to_str(eglGetError()) << std::endl; return false; } From ffe2673015c346a8e2e751a7371f6707a2ce8f0a Mon Sep 17 00:00:00 2001 From: "David R. MacIver" Date: Tue, 23 May 2017 14:48:25 +0100 Subject: [PATCH 2/4] Fix typos --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 94cd3fc..0c23c85 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Useful flags: Building the project uses CMake. -First you must ensure you have the depdencies. There are scripts in buildscripts +First you must ensure you have the dependencies. There are scripts in buildscripts intended to run on the CI that can also be used to build locally. You can run these as follows: @@ -51,7 +51,7 @@ On Linux or OSX: bash buildscripts/1-install-deps-travis.sh ``` -Alternativly on Ubuntu you can: +Alternatively on Ubuntu you can: ```bash sudo apt-get install libgles2-mesa-dev ``` From 063eb3b144f3581651929674ce40a3e072c09f8e Mon Sep 17 00:00:00 2001 From: "David R. MacIver" Date: Wed, 24 May 2017 10:07:07 +0100 Subject: [PATCH 3/4] Use RAII to always close display at exit. The reason for doing this is that swiftshader debug libraries will fail with an assertion error if you "leak" objects. This lets us run with the debug libraries for more comprehensible errors. --- get_image.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/get_image.cpp b/get_image.cpp index bddf172..0fa5ed3 100644 --- a/get_image.cpp +++ b/get_image.cpp @@ -327,6 +327,22 @@ int setUniforms(const GLuint& program, const std::string& fragment_shader) { return EXIT_SUCCESS; } +class TerminateEGLAtExit{ + EGLDisplay display; + + public: + TerminateEGLAtExit(EGLDisplay); + ~TerminateEGLAtExit(); +}; + +TerminateEGLAtExit::TerminateEGLAtExit(EGLDisplay display){ + this->display = display; +} + +TerminateEGLAtExit::~TerminateEGLAtExit(){ + auto succeeded = eglTerminate(this->display); + assert(succeeded); +} /*---------------------------------------------------------------------------*/ int main(int argc, char* argv[]) { @@ -349,6 +365,8 @@ int main(int argc, char* argv[]) { return EXIT_FAILURE; } + TerminateEGLAtExit cleanup_display = display; + bool persist = false; bool animate = false; bool exit_compile = false; From 936f0d26452d3c52a0b8552be77cc6798f99bcd7 Mon Sep 17 00:00:00 2001 From: "David R. MacIver" Date: Wed, 24 May 2017 10:33:13 +0100 Subject: [PATCH 4/4] Remove warning about comparison of unsigned and signed --- get_image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get_image.cpp b/get_image.cpp index 0fa5ed3..a6f9161 100644 --- a/get_image.cpp +++ b/get_image.cpp @@ -151,7 +151,7 @@ int render( template T *getArray(const json& j) { T *a = new T[j.size()]; - for (int i = 0; i < j.size(); i++) { + for (unsigned int i = 0; i < j.size(); i++) { a[i] = j[i]; } return a;