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_EGLRENDER_H 17 #define NATIVEXCOMPONENT_EGLRENDER_H 18 19 #include "EGLConst.h" 20 #include <EGL/egl.h> 21 #include <EGL/eglext.h> 22 #include <EGL/eglplatform.h> 23 #include <GLES3/gl3.h> 24 #include <string> 25 26 class EGLRender { 27 public: 28 bool SetUpEGLContext(void *window); 29 void SetEGLWindowSize(int width, int height); 30 void DrawStar(bool drawColor); 31 void DestroySurface(); 32 void Clear(); 33 34 std::string xcomponentId; 35 EGLNativeWindowType eglWindow_; 36 37 EGLDisplay eglDisplay_ = EGL_NO_DISPLAY; 38 EGLConfig eglConfig_ = EGL_NO_CONFIG_KHR; 39 EGLSurface eglSurface_ = EGL_NO_SURFACE; 40 EGLContext eglContext_ = EGL_NO_CONTEXT; 41 GLuint program_; 42 int width_ = 0; 43 int height_ = 0; 44 45 private: 46 GLint PrepareDraw(); 47 bool ExecuteDraw(GLint position, const GLfloat *color, const GLfloat shapeVertices[]); 48 }; 49 #endif // NATIVEXCOMPONENT_EGLRENDER_H 50