利用者:Jwilkins/VFX/GHOST Refactor for EGL

提供: wiki
< 利用者:Jwilkins‎ | VFX
2018年6月29日 (金) 06:08時点におけるYamyam (トーク | 投稿記録)による版 (1版 をインポートしました)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

GHOST Refactor for EGL

Overview

EGL is a cross platform library for initializing an OpenGL or OpenGL ES context.

This introduces the possibility of building Blender to support either the native context initialization library (CGL, WGL, XGL, etc.) or the cross platform EGL. Before the refactor GHOST assumed that the GHOST_Window class always used the native context initialization, but after the refactor a GHOST_Window uses a new class called GHOST_Context to handle GL context specific tasks.

This also provides the groundwork for supporting mobile and modern OpenGL.

EGL is also used instead of XGL by the Wayland compositor.

Building with CMake

Context Options

WITH_GL_CONTEXT_DESKTOP, WITH_GL_CONTEXT_EMBEDDED

These options control what Blender uses to create OpenGL contexts.

WITH_GL_CONTEXT_DESKTOP builds Blender to use the native context creation library:

  • CGL on OSX
  • WGL on Windows
  • XGL on Linux

WITH_GL_CONTEXT_EMBEDDED builds Blender to use EGL regardless of the operating system. Until GLEW is updated upstream with support for EGL the WITH_GLEW_ES option will also be needed in conjunction with this option.

Currently these options are mutually exclusive. You cannot build Blender to support both kinds of context.

Theoretically it would be possible to make this decision at runtime (for say, allowing the embedded game engine renderer to run using an ES context while the rest of Blender continued to use a desktop context), and although that should not be too difficult, that work is put off until later.

Profile Options

WITH_GL_PROFILE_COMPAT, WITH_GL_PROFILE_CORE, WITH_GL_PROFILE_ES20

The profile determines what set of OpenGL functions are available for Blender to use for drawing.

WITH_GL_PROFILE_COMPAT builds Blender with support for legacy OpenGL functions that have been deprecated since version 3.1. This option is deprecated.

WITH_GL_PROFILE_CORE builds Blender with only support for the core functionality of OpenGL version 3.2 and does not rely on any deprecated functions.

WITH_GL_PROFILE_ES20 builds Blender with support for OpenGL ES version 2.0. Until GLEW is updated upstream with support for OpenGL ES the WITH_GLEW_ES option will also be needed in conjunction with this option.

Currently these options are mutually exclusive. You cannot build Blender to support multiple profiles.

Theoretically, Blender could support any combination of these options at the same time and choose between them at runtime. It could even go as far as to use different contexts for different windows at the same time. However, right now I have simply attempted to not do anything that would make this difficult to do in the future.

Other Options

WITH_GLEW_MX

This option is experimental.

WITH_GLEW_MX enables support for multiple GLEW contexts. Contexts with different pixel formats can potentially have different entry points for extension functions. Blender does not actually currently have a case where it requests different pixel formats for different windows(?), but this option is there in case that is needed.

WITH_GLEW_ES

WITH_GLEW_ES causes Blender to use the GLEW in extern/glew-es instead of extern/glew. That version a fork of GLEW that has been extended to support OpenGL ES and EGL. I copied it and fixed a lot of bugs. These changes have not yet been contributed back upstream GLEW, so there is not a way to generate this version of GLEW from source. That should not a big problem until there is a pressing need to upgrade GLEW to a new version.

This option has to be enabled to support EGL contexts or OpenGL ES until the changes have been ported to upstream GLEW.

WITH_GLU

WITH_GLU enables GLU support in GLEW and links the GLU library. This is just here to support legacy code and is deprecated. Enabling it with core or ES profiles will probably blow something up.

EGL and OpenGL ES Libraries

There are many OpenGL ES implementations and none of them are supplied with Blender. In many cases the developer will need to manually supply the paths to the library files.

On Linux the WITH_SYSTEM_GLES will use find_package(GLES) instead of using paths supplied by the user.

The new CMake module in build_files/cmake/modules/FindOpenGLES.cmake locates the development libraries for OpenGL ES on Unix. I have not tested it, but I took it from the Wayland branch on github.

OpenGL ES Implementations

OpenGL ES Library Locations

After installing an OpenGL ES implementation these locations must be specified.

OPENGLES_LIBRARY, OPENGLES_EGL_LIBRARY

The OpenGL ES and EGL link library locations.

OPENGLES_LIBRARY_DLL, OPENGLES_EGL_LIBRARY_DLL

OpenGL ES runtime components do not ship with Windows, so they need to be installed with Blender, so the developer must also supply the paths to the DLLs.

WITH_GL_ANGLE, D3DCOMPILER_DLL

WITH_GL_ANGLE tells Blender that the library being used for OpenGL ES is the ANGLE library from Google. Because this library requires Direct3D in order to work it requires some additional files (namely the D3DCompiler_XX.dll) and some additional setup at runtime.

D3DCOMPILER_DLL Specifies the location of the redistributable D3DCompiler_XX.dll so that it can be installed along with Blender.

Building with Scons

Currently only the CMake build system has been modified to support these changes so Scons should fail.