1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <stdio.h>
18 #include <EGL/egl.h>
19 #include <GLES3/gl3.h>
20 
21 
getEGLError(void)22 const char *getEGLError(void) {
23     switch (eglGetError()) {
24         case EGL_SUCCESS:
25             return "EGL_SUCCESS";
26         case EGL_NOT_INITIALIZED:
27             return "EGL_NOT_INITIALIZED";
28         case EGL_BAD_ACCESS:
29             return "EGL_BAD_ACCESS";
30         case EGL_BAD_ALLOC:
31             return "EGL_BAD_ALLOC";
32         case EGL_BAD_ATTRIBUTE:
33             return "EGL_BAD_ATTRIBUTE";
34         case EGL_BAD_CONTEXT:
35             return "EGL_BAD_CONTEXT";
36         case EGL_BAD_CONFIG:
37             return "EGL_BAD_CONFIG";
38         case EGL_BAD_CURRENT_SURFACE:
39             return "EGL_BAD_CURRENT_SURFACE";
40         case EGL_BAD_DISPLAY:
41             return "EGL_BAD_DISPLAY";
42         case EGL_BAD_SURFACE:
43             return "EGL_BAD_SURFACE";
44         case EGL_BAD_MATCH:
45             return "EGL_BAD_MATCH";
46         case EGL_BAD_PARAMETER:
47             return "EGL_BAD_PARAMETER";
48         case EGL_BAD_NATIVE_PIXMAP:
49             return "EGL_BAD_NATIVE_PIXMAP";
50         case EGL_BAD_NATIVE_WINDOW:
51             return "EGL_BAD_NATIVE_WINDOW";
52         case EGL_CONTEXT_LOST:
53             return "EGL_CONTEXT_LOST";
54         default:
55             return "Unknown error";
56     }
57 }
58 
59 
getGLFramebufferError(void)60 const char *getGLFramebufferError(void) {
61     switch (glCheckFramebufferStatus(GL_FRAMEBUFFER)) {
62     case GL_FRAMEBUFFER_COMPLETE:
63         return "GL_FRAMEBUFFER_COMPLETE";
64     case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
65         return "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
66     case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
67         return "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
68     case GL_FRAMEBUFFER_UNSUPPORTED:
69         return "GL_FRAMEBUFFER_UNSUPPORTED";
70     case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
71         return "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
72     default:
73         return "Unknown error";
74     }
75 }
76