Skip to content

Commit

Permalink
Merge branch 'master' of github.com:graphicsfuzz/get-image-egl
Browse files Browse the repository at this point in the history
  • Loading branch information
hevrard committed Apr 11, 2018
2 parents 5d091b1 + 936f0d2 commit 55c756f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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
```
Expand Down
22 changes: 21 additions & 1 deletion common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@

#include <iostream>

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,
Expand Down Expand Up @@ -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;
}

Expand Down
20 changes: 19 additions & 1 deletion get_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ int render(
template<typename T>
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;
Expand Down Expand Up @@ -332,6 +332,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[]) {
Expand All @@ -354,6 +370,8 @@ int main(int argc, char* argv[]) {
return EXIT_FAILURE;
}

TerminateEGLAtExit cleanup_display = display;

bool persist = false;
bool animate = false;
bool exit_compile = false;
Expand Down

0 comments on commit 55c756f

Please sign in to comment.