Skip to content

Instantly share code, notes, and snippets.

@koara-local
Last active March 7, 2017 10:02
Show Gist options
  • Save koara-local/02330c77ac76371ccdd0ca9215fe31cc to your computer and use it in GitHub Desktop.
Save koara-local/02330c77ac76371ccdd0ca9215fe31cc to your computer and use it in GitHub Desktop.
EGLの使い方(PlantUML)
// Copyright 2017 Kohei Arao
// https://opensource.org/licenses/MIT
@startuml
title EGLの使い方
| バックエンド |
start
:初期化処理;
note right
X11, Wayland, FBなど
end note
|#AntiqueWhite| EGL |
:eglGetDisplay;
:eglInitialize;
:eglBindAPI;
:eglGetConfig;
:eglChooseConfig;
:eglCreateContext;
note right
EGLContextの作成
end note
:eglCreateWindowSurface;
note right
NativeWindow(バックエンドで作成したバッファ領域)からEGLSurfaceの作成
end note
:eglMakeCurrent;
note right
作成したEGLContext, EGLSurfaceの有効化
end note
:eglSwapInterval;
note right
(オプション)SwapIntervalを変更したいときのみ
V-Syncが何回呼ばれた場合にSwapするかの設定値。0だと非同期になる。
end note
| 描画API |
:描画初期化処理;
note right
・OpenGL
・OpenGLES1.x/2.x/3.x
・OpenVG
など
(VulkanではWSI(Window System Interface)
に置き換わるらしい)
end note
|#AntiqueWhite| EGL |
repeat
partition "描画処理" {
:eglMakeCurrent;
note right
(オプション)描画対象のEGLContextまたはEGLSurfaceを切り替える場合
end note
| 描画API |
:バッファ描画処理;
|#AntiqueWhite| EGL |
:eglSwapBuffers;
}
repeat while (描画終了?) is (継続)
| 描画API |
:描画終了処理;
|#AntiqueWhite| EGL |
:eglMakeCurrent;
note right
EGLContext, EGLSurfaceの紐付け解除
(EGL_NO_CONTEXT, EGL_NO_SURFACEを指定)
end note
:eglDestroySurface;
:eglDestroyContext;
:eglTerminate;
note right
ライブラリの場合は基本的に呼んではいけない
(EGLDisplayに紐づく全てのリソースが解放されるため)
end note
:eglReleaseThread;
note right
メインスレッドで動作するライブラリの場合は呼んではいけない
(スレッドに関するリソース(eglGetErrorで取れるリソース等)が解放されるため)
eglTerminateでエラーが返るケースが有るため、
eglTerminateを呼ぶ場合は、eglTerminateの後に実行する
end note
| バックエンド |
:バックエンド終了処理;
stop
@enduml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment