当前位置:网站首页>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 :
边栏推荐
- SystemVerilog学习-10-验证量化和覆盖率
- Boot + jsp University Community Management System (with source Download Link)
- My experience from technology to product manager
- 导数的左右极限和左右导数的辨析
- OneFlow源码解析:算子签名的自动推断
- Dear pie users, I want to confess to you!
- Beauty of Mathematics - Application of Mathematics
- HCM 初学 ( 三 ) - 快速输入PA70、PA71 浏览员工信息PA10
- Unity uses SQLite
- HDU - 1024 Max Sum Plus Plus(DP)
猜你喜欢

表格中el-tooltip 实现换行展示

【考研高数 武忠祥+880版 自用】高数第二章基础阶段思维导图

Leetcode Max rectangle, Max square series 84 85. 221. 1277. 1725. (monotonic stack, dynamic programming)

How to add a gourd pie plate
SSM的教务管理系统(免费源码获取)

mysql 将毫秒数转为时间字符串
![[medical segmentation] u2net](/img/b3/b1d188216310fe1217e360ac56af3b.jpg)
[medical segmentation] u2net

Advanced cross platform application development (II): uni app practice

Boot + jsp University Community Management System (with source Download Link)

My experience from technology to product manager
随机推荐
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“
Looking for high school student developers with similar interests
Scope data export mat
It's not that you have a bad mind, but that you haven't found the right tool
FPGA - 7系列 FPGA内部结构之Clocking -01- 时钟架构概述
boot+jsp的高校社團管理系統(附源碼下載鏈接)
Geoffrey Hinton:我的五十年深度学习生涯与研究心法
Is it safe for a novice to open a securities account?
OpenGL ES: (4) EGL API详解 (转)
excel动态图表
2022第八届中国国际“互联网+”大学生创新创业大赛产业命题赛道开启报名!
Continuous breakthrough and steady progress -- Review and Prospect of cross platform development technology of mobile terminal
Don't put your notes and videos everywhere!
穿越派与贸大合作,为大学生增添效率
Basic electrician knowledge 100 questions
excel高级绘图技巧100讲(一)-用甘特图来展示项目进度情况
不是你脑子不好用,而是因为你没有找到对的工具
CentOS 7 installed php7.0 using Yum or up2date
Primary application case of Excel DuPont analyzer
基于LabVIEW的计时器