当前位置:网站首页>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 :
边栏推荐
猜你喜欢

穿越派·派盘 + 思源笔记 = 私人笔记本

ssm+mysql二手交易网站(论文+源码获取链接)

论文学习记录随笔 多标签之LIFT

El tooltip in the table realizes line breaking display

Preliminary level of C language -- selected good questions on niuke.com

Ssm+mysql second-hand trading website (thesis + source code access link)

4GB大文件,如何实时远程传输和共享?

MySQL数据迁移遇到的一些错误

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

On the first day of the new year, 3000 Apache servers went down
随机推荐
He struggled day and night to protect his data
不是你脑子不好用,而是因为你没有找到对的工具
【考研高数 自用】高数第一章基础阶段思维导图
Primary application case of Excel DuPont analyzer
Xuanyi maintenance manual
mysql 将毫秒数转为时间字符串
Oracle 序列+触发器
On the first day of the new year, 3000 Apache servers went down
分片上传与断点续传
College community management system based on boot+jsp (with source code download link)
Brief description of activation function
基于LabVIEW的计时器
excel高级绘图技巧100讲(一)-用甘特图来展示项目进度情况
How to add a gourd pie plate
Unity uses SQLite
Summary of common components of applet
我从技术到产品经理的几点体会
First defined here occurs during QT compilation. Causes and Solutions
Orcle创建用户+角色
2022 the 8th China International "Internet +" college student innovation and entrepreneurship competition industry proposition track is open for registration!