1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef NATIVEXCOMPONENT_EGLCONST_H 17 #define NATIVEXCOMPONENT_EGLCONST_H 18 #include <EGL/egl.h> 19 #include <EGL/eglext.h> 20 #include <GLES3/gl3.h> 21 22 const unsigned int LOG_PRINT_DOMAIN = 0xFF00; 23 24 /** 25 * Program error. 26 */ 27 const GLuint PROGRAM_ERROR = 0; 28 29 /** 30 * Position error. 31 */ 32 const GLint POSITION_ERROR = -1; 33 34 /** 35 * Default x position. 36 */ 37 const int DEFAULT_X_POSITION = 0; 38 39 /** 40 * Default y position. 41 */ 42 const int DEFAULT_Y_POSITION = 0; 43 44 /** 45 * Gl red default. 46 */ 47 const GLfloat GL_RED_DEFAULT = 0.0; 48 49 /** 50 * Gl green default. 51 */ 52 const GLfloat GL_GREEN_DEFAULT = 0.0; 53 54 /** 55 * Gl blue default. 56 */ 57 const GLfloat GL_BLUE_DEFAULT = 0.0; 58 59 /** 60 * Gl alpha default. 61 */ 62 const GLfloat GL_ALPHA_DEFAULT = 1.0; 63 64 /** 65 * Pointer size. 66 */ 67 const GLint POINTER_SIZE = 2; 68 69 /** 70 * Triangle fan size. 71 */ 72 const GLsizei TRIANGLE_FAN_SIZE = 4; 73 74 /** 75 * Fifty percent. 76 */ 77 const float FIFTY_PERCENT = 0.5; 78 79 /** 80 * Position handle name. 81 */ 82 const char POSITION_NAME[] = "a_position"; 83 84 /** 85 * numeric value 0. 86 */ 87 const int NUM_0 = 0; 88 89 /** 90 * numeric value 4. 91 */ 92 const int NUM_4 = 4; 93 94 /** 95 * Background color #f4f4f4. 96 */ 97 const GLfloat BACKGROUND_COLOR[] = {244.0f / 255, 244.0f / 255, 244.0f / 255, 1.0f}; 98 99 /** 100 * Background color #ffffff00. 101 */ 102 const GLfloat TRANSPARENT_COLOR[] = {255.0f / 255, 255.0f / 255, 255.0f / 255, 0.0f}; 103 104 /** 105 * Draw color #7E8FFB. 106 */ 107 const GLfloat DRAW_COLOR[] = {126.0f / 255, 143.0f / 255, 251.0f / 255, 1.0f}; 108 109 /** 110 * Change color #92D6CC. 111 */ 112 const GLfloat CHANGE_COLOR[] = {146.0f / 255, 214.0f / 255, 204.0f / 255, 1.0f}; 113 114 /** 115 * Background area. 116 */ 117 const GLfloat BACKGROUND_RECTANGLE_VERTICES[] = {-1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f}; 118 119 const EGLint ATTRIB_LIST[] = { 120 // Key,value. 121 EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, 122 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 123 // End. 124 EGL_NONE}; 125 126 const EGLint CONTEXT_ATTRIBS[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; 127 128 /** 129 * Vertex shader. 130 */ 131 const char VERTEX_SHADER[] = "#version 300 es\n" 132 "layout(location = 0) in vec4 a_position;\n" 133 "layout(location = 1) in vec4 a_color; \n" 134 "out vec4 v_color; \n" 135 "void main() \n" 136 "{ \n" 137 " gl_Position = a_position; \n" 138 " v_color = a_color; \n" 139 "} \n"; 140 141 /** 142 * Fragment shader. 143 */ 144 const char FRAGMENT_SHADER[] = "#version 300 es\n" 145 "precision mediump float; \n" 146 "in vec4 v_color; \n" 147 "out vec4 fragColor; \n" 148 "void main() \n" 149 "{ \n" 150 " fragColor = v_color; \n" 151 "} \n"; 152 #endif // NATIVEXCOMPONENT_EGLCONST_H 153