当前位置:网站首页>OpenGL es: (3) EGL, basic steps of EGL drawing, eglsurface, anativewindow
OpenGL es: (3) EGL, basic steps of EGL drawing, eglsurface, anativewindow
2022-07-01 05:49:00 【Xiao Ge】
1. EGL summary
EGL yes OpenGL ES Rendering API And the local window system (native platform window system) An intermediate interface layer between , It is mainly implemented by the system manufacturer .

EGL Provide the following mechanism :
- Communicate with the native window system of the device
- Query the available types and configurations of the drawing surface
- Create drawing surface
- stay OpenGL ES And other graphics rendering API Synchronous rendering between
- Manage rendering resources such as texture maps
- In order to make OpenGL ES Can be drawn on the current device , We need to EGL As OpenGL ES Bridge with equipment .

2. Use EGL The basic steps of drawing

Display(EGLDisplay) It's an abstraction of the actual display device .
Surface(EGLSurface) The memory area used to store images .
FrameBuffer The abstraction of , Include Color Buffer, Stencil Buffer ,Depth Buffer.Context (EGLContext) Storage OpenGL ES Some status information of the drawing .
Use EGL General steps for drawing :
1、 obtain EGL Display object :eglGetDisplay() 2、 Initialization and EGLDisplay Connection between :eglInitialize() 3、 obtain EGLConfig object :eglChooseConfig() 4、 establish EGLContext example :eglCreateContext() 5、 establish EGLSurface example :eglCreateWindowSurface() 6、 Connect EGLContext and EGLSurface:eglMakeCurrent() 7、 Use OpenGL ES API Drawing graphics :gl_*() 8、 Switch front buffer and back buffer Send to show :eglSwapBuffer() 9、 Disconnect and release from EGLSurface The associated EGLContext object :eglRelease() 10、 Delete EGLSurface object 11、 Delete EGLContext object 12、 Termination and EGLDisplay Connection between
standard EGL The data types are as follows :
EGLBoolean —— EGL_TRUE =1, EGL_FALSE=0
EGLint —— int data type
EGLDisplay —— systems display ID Or handle , It can be understood as a front-end display window
EGLConfig —— Surface Of EGL To configure , It can be understood as drawing the target framebuffer Configuration properties of
EGLSurface —— System window or frame buffer Handle , It can be understood as a back-end rendering target window .
EGLContext —— OpenGL ES Graphics context , It represents the OpenGL State machine ; Without it ,OpenGL Instructions have no execution environment .
The following types are more complex , Through examples, we can have a deeper understanding of . What we want to explain here is that the implementation of these types is different on different platforms ,EGL Only abstract standards are provided .
NativeDisplayType—— Native System display type , Identify the physical screen of the device you are developing
NativeWindowType —— Native System window cache type , Identify the system window
NativePixmapType —— Native System frame buffer, It can be used as Framebuffer System image of ( Memory ) data type , This type is only used for off screen rendering .
3. EGLSurface

EGLSurface Can be by EGL Allocated offscreen buffer ( be called “pbuffer”), Or windows assigned by the operating system .EGL window Surface adopt eglCreateWindowSurface() The call is created . This call will “ Window object ” As a parameter , stay Android On , The object can be SurfaceView、SurfaceTexture、SurfaceHolder or Surface, Below all these objects is a BufferQueue. When you make this call ,EGL A new EGLSurface object , And connect it to the BufferQueue The manufacturer's interface . thereafter , Render to the point EGLSurface Causes a buffer to leave the queue 、 Rendering , Then wait in line for the consumer to use .( The term “ window ” Indicates intended use , But please pay attention to , The output does not necessarily appear on the display .)
EGL Locking is not provided / Unlock call , Instead, you issue the draw command , And then call eglSwapBuffers() To submit the current frame . The method name comes from the traditional pre - and post buffer swap , But the actual implementation may be very different .
One Surface Only one at a time EGLSurface relation ( You can only connect one producer to one BufferQueue), But if you destroy this EGLSurface, It will be associated with the BufferQueue disconnect , And allow other content to connect to the BufferQueue.
By changing “ At present ”EGLSurface, The specified thread can be in multiple EGLSurface Switch between . One EGLSurface You can only be in the current state on one thread at a time .
About EGLSurface One of the most common misconceptions is to assume that it is just Surface On the other hand ( Such as SurfaceHolder). It is a related but independent concept . You may not have Surface As a support EGLSurface Draw on , Can also be in the absence of EGL In case of use Surface.EGLSurface Only for GLES Provide a place to draw .
4. ANativeWindow
Open Surface Class to Java Programming language implementation .C/C++ The equivalent term in is ANativeWindow class , from Android NDK Semi open . You can use ANativeWindow_fromSurface() Call from Surface obtain ANativeWindow. Like it Java Language equivalents are the same , You can to ANativeWindow Lock in 、 Rendering in software , And unlock and publish .
To create from native code EGL window Surface, Can be EGLNativeWindowType An instance of is passed to eglCreateWindowSurface().EGLNativeWindowType yes ANativeWindow A synonym for , You are free to switch between them .
Basic “ Native window ” Types are just encapsulation BufferQueue The manufacturer of , This is not surprising .
5. EGLSurface And ANativeWindow The relationship between
OpenGL ES Defines a method for rendering graphics API, But there's no window system defined . In order to make GLES Suitable for all kinds of platforms ,GLES Will be used in conjunction with libraries that know how to create and access windows through the operating system . be used for Android The library of is called EGL. If you want to paint texture polygons , You should use GLES call ; If you want to render on the screen , You should use EGL call .
In the use of GLES Before doing anything , You need to create a GL Context . stay EGL in , This means creating a EGLContext And a EGLSurface.GLES Action applies to current context , This context is accessed through thread local storage , Instead of being passed as a parameter . This means that you must pay attention to which thread the rendering code executes , And the current context on the thread .
Reference link :
边栏推荐
- Dear pie users, I want to confess to you!
- A little assistant for teenagers' physiological health knowledge based on wechat applet (free source code + project introduction + operation introduction + operation screenshot + Thesis)
- 2022.6.30-----leetcode.1175
- In win10 and win11, the scroll direction of Elan touch panel is reversed, and "double finger click to open the right-click menu" and "double finger scroll" are started“
- Trust guessing numbers game
- C language beginner level - realize the minesweeping game
- 论文学习记录随笔 多标签之LIFT
- Leetcode Max rectangle, Max square series 84 85. 221. 1277. 1725. (monotonic stack, dynamic programming)
- OpenGL ES: (2) OpenGL ES 与 EGL、GLSL的关系
- 数据治理:元数据管理实施(第四篇)
猜你喜欢

Continue to learn MySQL

College community management system based on boot+jsp (with source code download link)

FPGA - 7系列 FPGA内部结构之Clocking -01- 时钟架构概述

C language beginner level - realize the minesweeping game

从诺奖知“边缘计算”的未来!

Chip, an empire built on sand!

A little assistant for teenagers' physiological health knowledge based on wechat applet (free source code + project introduction + operation introduction + operation screenshot + Thesis)

Seven major technical updates that developers should pay most attention to on build 2022
![[medical segmentation] u2net](/img/b3/b1d188216310fe1217e360ac56af3b.jpg)
[medical segmentation] u2net

Learn the customization and testing of fpga---ram IP from the bottom structure
随机推荐
OpenGL ES: (5) OpenGL的基本概念、OpenGL ES 在屏幕产生图片的过程、OpenGL管线(pipeline)
Enter an expression (expressed as a string) and find the value of this expression.
分片上传与断点续传
Build 2022 上开发者最应关注的七大方向主要技术更新
Qt编写自定义控件-自绘电池
[medical segmentation] u2net
OpenGL ES: (4) EGL API详解 (转)
C语言初阶——实现扫雷游戏
Continue to learn MySQL
SQL必会题之留存率
MinIO纠错码、分布式MinIO集群搭建及启动
不是你脑子不好用,而是因为你没有找到对的工具
2022.6.30-----leetcode.1175
Through cooperation with the University of international trade, we can increase efficiency for college students
Excel dynamic chart
【知识点总结】卡方分布,t分布,F分布
POL8901 LVDS转MIPI DSI 支持旋转图像处理芯片
First defined here occurs during QT compilation. Causes and Solutions
FPGA - 7系列 FPGA内部结构之Clocking -02- 时钟布线资源
基于LabVIEW的计时器