当前位置:网站首页>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 :
边栏推荐
- tese_ Time_ 2h
- SystemVerilog学习-06-类的封装
- 2022.6.30-----leetcode. one thousand one hundred and seventy-five
- bat操作ftp上传下载命令
- Leetcode Max rectangle, Max square series 84 85. 221. 1277. 1725. (monotonic stack, dynamic programming)
- boot+jsp的高校社团管理系统(附源码下载链接)
- 扩展点系列之SmartInstantiationAwareBeanPostProcessor确定执行哪一个构造方法 - 第432篇
- uniapp树形层级选择器
- Xuanyi maintenance manual
- Educational administration management system (free source code)
猜你喜欢
穿越派·派盘 + Mountain Duck = 数据本地管理
喊我们大学生个人云服务特供商
穿越派与贸大合作,为大学生增添效率
Huluer app help
On the first day of the new year, 3000 Apache servers went down
Primary application case of Excel DuPont analyzer
基于微信小程序的青少年生理健康知识小助手(免费获取源码+项目介绍+运行介绍+运行截图+论文)
SystemVerilog学习-10-验证量化和覆盖率
Continuous breakthrough and steady progress -- Review and Prospect of cross platform development technology of mobile terminal
excel高级绘图技巧100讲(一)-用甘特图来展示项目进度情况
随机推荐
论文学习记录随笔 多标签之LIFT
Some errors encountered in MySQL data migration
A little assistant for teenagers' physiological health knowledge based on wechat applet (free source code + project introduction + operation introduction + operation screenshot + Thesis)
HDU - 1024 Max Sum Plus Plus(DP)
Continue to learn MySQL
【笔记】电商订单数据分析实战
HCM 初学 ( 二 ) - 信息类型
Multi table operation - foreign key cascade operation
Advanced cross platform application development (II): uni app practice
【医学分割】u2net
ssm+mysql二手交易网站(论文+源码获取链接)
穿越派与贸大合作,为大学生增添效率
win10、win11中Elan触摸板滚动方向反转、启动“双指点击打开右键菜单“、“双指滚动“
Debug details under pycharm
This is the necessary software for college students 𞓜 knowledge management
芯片,建立在沙粒上的帝国!
从诺奖知“边缘计算”的未来!
Fragment upload and breakpoint resume
葫芦儿 APP 使用帮助
JSON data comparer