Better EGL context creation
This commit is contained in:
parent
035c33f960
commit
63517dd4be
@ -213,6 +213,10 @@ define out. */
|
|||||||
|
|
||||||
#define _IRR_COMPILE_WITH_WAYLAND
|
#define _IRR_COMPILE_WITH_WAYLAND
|
||||||
|
|
||||||
|
#ifdef _IRR_COMPILE_WITH_WAYLAND
|
||||||
|
#define _IRR_COMPILE_WITH_EGL_
|
||||||
|
#endif
|
||||||
|
|
||||||
//! Define _IRR_OPENGL_USE_EXTPOINTER_ if the OpenGL renderer should use OpenGL extensions via function pointers.
|
//! Define _IRR_OPENGL_USE_EXTPOINTER_ if the OpenGL renderer should use OpenGL extensions via function pointers.
|
||||||
/** On some systems there is no support for the dynamic extension of OpenGL
|
/** On some systems there is no support for the dynamic extension of OpenGL
|
||||||
via function pointers such that this has to be undef'ed. */
|
via function pointers such that this has to be undef'ed. */
|
||||||
|
@ -28,6 +28,7 @@ extern bool GLContextDebugBit;
|
|||||||
|
|
||||||
#ifdef _IRR_COMPILE_WITH_WAYLAND
|
#ifdef _IRR_COMPILE_WITH_WAYLAND
|
||||||
#include "cirrdevicewayland.h"
|
#include "cirrdevicewayland.h"
|
||||||
|
#include "CContextEGL.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
@ -981,7 +982,7 @@ bool COpenGLDriver::endScene()
|
|||||||
if (DeviceType == EIDT_WAYLAND)
|
if (DeviceType == EIDT_WAYLAND)
|
||||||
{
|
{
|
||||||
wl_display_dispatch_pending(wl_device->display);
|
wl_display_dispatch_pending(wl_device->display);
|
||||||
eglSwapBuffers(wl_device->egl_display, wl_device->egl_surface);
|
wl_device->getEGLContext()->swapBuffers();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ extern bool GLContextDebugBit;
|
|||||||
#include "IGUISpriteBank.h"
|
#include "IGUISpriteBank.h"
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include "CVideoModeList.h"
|
#include "CVideoModeList.h"
|
||||||
|
#include "CContextEGL.h"
|
||||||
|
|
||||||
#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -461,7 +462,8 @@ CIrrDeviceWayland::CIrrDeviceWayland(const SIrrlichtCreationParameters& param)
|
|||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
setDebugName("CIrrDeviceLinux");
|
setDebugName("CIrrDeviceLinux");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
EglContext = NULL;
|
||||||
|
|
||||||
// print version, distribution etc.
|
// print version, distribution etc.
|
||||||
// thx to LynxLuna for pointing me to the uname function
|
// thx to LynxLuna for pointing me to the uname function
|
||||||
@ -530,7 +532,9 @@ CIrrDeviceWayland::~CIrrDeviceWayland()
|
|||||||
wl_registry_destroy(registry);
|
wl_registry_destroy(registry);
|
||||||
wl_display_disconnect(display);
|
wl_display_disconnect(display);
|
||||||
xkb_context_unref(xkbctx);
|
xkb_context_unref(xkbctx);
|
||||||
//TODO : surfaces, egl
|
|
||||||
|
delete EglContext;
|
||||||
|
|
||||||
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
|
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
|
||||||
for (u32 joystick = 0; joystick < ActiveJoysticks.size(); ++joystick)
|
for (u32 joystick = 0; joystick < ActiveJoysticks.size(); ++joystick)
|
||||||
{
|
{
|
||||||
@ -565,50 +569,19 @@ void CIrrDeviceWayland::initEGL()
|
|||||||
{
|
{
|
||||||
egl_window = wl_egl_window_create(surface, Width, Height);
|
egl_window = wl_egl_window_create(surface, Width, Height);
|
||||||
|
|
||||||
egl_display = eglGetDisplay(display);
|
EglContext = new ContextManagerEGL();
|
||||||
if (egl_display == EGL_NO_DISPLAY)
|
|
||||||
{
|
ContextEGLParams egl_params;
|
||||||
os::Printer::log("eglGetDisplay() error", "", ELL_ERROR);
|
egl_params.opengl_api = CEGL_API_OPENGL;
|
||||||
}
|
egl_params.surface_type = CEGL_SURFACE_WINDOW;
|
||||||
if(!eglInitialize(egl_display, NULL, NULL))
|
egl_params.force_legacy_device = CreationParams.ForceLegacyDevice;
|
||||||
{
|
egl_params.with_alpha_channel = CreationParams.WithAlphaChannel;
|
||||||
os::Printer::log("eglInitialize() error", "", ELL_ERROR);
|
egl_params.vsync_enabled = CreationParams.Vsync;
|
||||||
}
|
egl_params.window = egl_window;
|
||||||
|
egl_params.display = display;
|
||||||
int confsize;
|
|
||||||
int attrib[] = {EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
EglContext->init(egl_params);
|
||||||
EGL_RED_SIZE, 4,
|
video::useCoreContext = !EglContext->isLegacyDevice();
|
||||||
EGL_GREEN_SIZE, 4,
|
|
||||||
EGL_BLUE_SIZE, 4,
|
|
||||||
EGL_DEPTH_SIZE, 24,
|
|
||||||
EGL_NONE};
|
|
||||||
EGLConfig eglconf;
|
|
||||||
|
|
||||||
if (!eglChooseConfig(egl_display, attrib, &eglconf, 1, &confsize))
|
|
||||||
{
|
|
||||||
os::Printer::log("eglChooseConfig() error", "", ELL_ERROR);
|
|
||||||
}
|
|
||||||
egl_surface = eglCreateWindowSurface(egl_display, eglconf, egl_window, 0);
|
|
||||||
if (egl_surface == EGL_NO_SURFACE)
|
|
||||||
{
|
|
||||||
os::Printer::log("eglCreateWindowSurface() error", "", ELL_ERROR);
|
|
||||||
}
|
|
||||||
if (!eglBindAPI(EGL_OPENGL_API))
|
|
||||||
{
|
|
||||||
os::Printer::log("eglBindAPI() error", "", ELL_ERROR);
|
|
||||||
}
|
|
||||||
int glattrib[] = {EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGL_CONTEXT_MINOR_VERSION_KHR, 3, EGL_NONE};
|
|
||||||
egl_context = eglCreateContext(egl_display, eglconf, EGL_NO_CONTEXT, glattrib);
|
|
||||||
if (egl_context == EGL_NO_CONTEXT)
|
|
||||||
{
|
|
||||||
os::Printer::log("eglCreateContext() error", "", ELL_ERROR);
|
|
||||||
}
|
|
||||||
if (!eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context))
|
|
||||||
{
|
|
||||||
os::Printer::log("eglMakeCurrent() error", "", ELL_ERROR);
|
|
||||||
}
|
|
||||||
video::useCoreContext = true;
|
|
||||||
eglSwapInterval(egl_display, CreationParams.Vsync ? 1 : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CIrrDeviceWayland::createWindow()
|
bool CIrrDeviceWayland::createWindow()
|
||||||
|
@ -14,12 +14,12 @@
|
|||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
|
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <EGL/egl.h>
|
|
||||||
#include <EGL/eglext.h>
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#define KeySym s32
|
#define KeySym s32
|
||||||
|
|
||||||
|
class ContextManagerEGL;
|
||||||
|
|
||||||
// Note : only supporting shell interface
|
// Note : only supporting shell interface
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
@ -231,6 +231,8 @@ namespace irr
|
|||||||
std::vector<core::dimension2du> Modes;
|
std::vector<core::dimension2du> Modes;
|
||||||
core::dimension2du CurrentModes;
|
core::dimension2du CurrentModes;
|
||||||
|
|
||||||
|
ContextManagerEGL* EglContext;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void signalEvent(const SEvent&);
|
void signalEvent(const SEvent&);
|
||||||
void addMode(const core::dimension2du &mode) { Modes.push_back(mode); }
|
void addMode(const core::dimension2du &mode) { Modes.push_back(mode); }
|
||||||
@ -251,10 +253,9 @@ namespace irr
|
|||||||
wl_surface *surface;
|
wl_surface *surface;
|
||||||
wl_shell_surface *shell_surface;
|
wl_shell_surface *shell_surface;
|
||||||
wl_egl_window *egl_window;
|
wl_egl_window *egl_window;
|
||||||
|
|
||||||
EGLSurface egl_surface;
|
ContextManagerEGL* getEGLContext() {return EglContext;}
|
||||||
EGLDisplay egl_display;
|
|
||||||
EGLContext egl_context;
|
|
||||||
private:
|
private:
|
||||||
// XVisualInfo* visual;
|
// XVisualInfo* visual;
|
||||||
mutable core::stringc Clipboard;
|
mutable core::stringc Clipboard;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user