• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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 <GLES2/gl2.h>
18 #include <GLES2/gl2ext.h>
19 
20 #include <utils/Log.h>
21 
22 #include "GLUtils.h"
23 
24 namespace android {
25 namespace uirenderer {
26 
dumpGLErrors()27 bool GLUtils::dumpGLErrors() {
28     bool errorObserved = false;
29     GLenum status = GL_NO_ERROR;
30     while ((status = glGetError()) != GL_NO_ERROR) {
31         errorObserved = true;
32         switch (status) {
33             case GL_INVALID_ENUM:
34                 ALOGE("GL error:  GL_INVALID_ENUM");
35                 break;
36             case GL_INVALID_VALUE:
37                 ALOGE("GL error:  GL_INVALID_VALUE");
38                 break;
39             case GL_INVALID_OPERATION:
40                 ALOGE("GL error:  GL_INVALID_OPERATION");
41                 break;
42             case GL_OUT_OF_MEMORY:
43                 ALOGE("GL error:  Out of memory!");
44                 break;
45             default:
46                 ALOGE("GL error: 0x%x", status);
47         }
48     }
49     return errorObserved;
50 }
51 
getGLFramebufferError()52 const char* GLUtils::getGLFramebufferError() {
53     switch (glCheckFramebufferStatus(GL_FRAMEBUFFER)) {
54         case GL_FRAMEBUFFER_COMPLETE:
55             return "GL_FRAMEBUFFER_COMPLETE";
56         case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
57             return "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
58         case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
59             return "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
60         case GL_FRAMEBUFFER_UNSUPPORTED:
61             return "GL_FRAMEBUFFER_UNSUPPORTED";
62         case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
63             return "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
64         default:
65             return "Unknown error";
66     }
67 }
68 
69 }  // namespace uirenderer
70 }  // namespace android
71