mirror of
https://github.com/minetest/minetest.git
synced 2024-12-22 22:22:23 +01:00
Non-SDL: Add opengl3 support
This commit is contained in:
parent
87ac32edea
commit
4838eb2f7d
@ -38,7 +38,7 @@
|
||||
#include "CEGLManager.h"
|
||||
#endif
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_OPENGL_)
|
||||
#if defined(_IRR_COMPILE_WITH_GLX_MANAGER_)
|
||||
#include "CGLXManager.h"
|
||||
#endif
|
||||
|
||||
@ -69,24 +69,6 @@
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
IVideoDriver *createOpenGLDriver(const irr::SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager);
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
IVideoDriver *createOGLES2Driver(const irr::SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager);
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WEBGL1_
|
||||
IVideoDriver *createWebGL1Driver(const irr::SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager);
|
||||
#endif
|
||||
}
|
||||
} // end namespace irr
|
||||
|
||||
namespace
|
||||
{
|
||||
Atom X_ATOM_CLIPBOARD;
|
||||
@ -397,10 +379,11 @@ bool CIrrDeviceLinux::createWindow()
|
||||
if (WMCheck != None)
|
||||
HasNetWM = true;
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_OPENGL_)
|
||||
#if defined(_IRR_COMPILE_WITH_GLX_MANAGER_)
|
||||
// don't use the XVisual with OpenGL, because it ignores all requested
|
||||
// properties of the CreationParams
|
||||
if (CreationParams.DriverType == video::EDT_OPENGL) {
|
||||
if (CreationParams.DriverType == video::EDT_OPENGL
|
||||
|| CreationParams.DriverType == video::EDT_OPENGL3) {
|
||||
video::SExposedVideoData data;
|
||||
data.OpenGLLinux.X11Display = XDisplay;
|
||||
ContextManager = new video::CGLXManager(CreationParams, data, Screennr);
|
||||
@ -539,51 +522,54 @@ void CIrrDeviceLinux::createDriver()
|
||||
switch (CreationParams.DriverType) {
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
case video::EDT_OPENGL:
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
video::SExposedVideoData data;
|
||||
data.OpenGLLinux.X11Window = XWindow;
|
||||
data.OpenGLLinux.X11Display = XDisplay;
|
||||
|
||||
ContextManager->initialize(CreationParams, data);
|
||||
|
||||
#endif
|
||||
VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, ContextManager);
|
||||
}
|
||||
#else
|
||||
os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
|
||||
break;
|
||||
case video::EDT_OPENGL3:
|
||||
{
|
||||
#ifdef ENABLE_OPENGL3
|
||||
video::SExposedVideoData data;
|
||||
data.OpenGLLinux.X11Window = XWindow;
|
||||
data.OpenGLLinux.X11Display = XDisplay;
|
||||
|
||||
ContextManager->initialize(CreationParams, data);
|
||||
#endif
|
||||
VideoDriver = video::createOpenGL3Driver(CreationParams, FileSystem, ContextManager);
|
||||
}
|
||||
break;
|
||||
case video::EDT_OGLES2:
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
video::SExposedVideoData data;
|
||||
data.OpenGLLinux.X11Window = XWindow;
|
||||
data.OpenGLLinux.X11Display = XDisplay;
|
||||
|
||||
ContextManager = new video::CEGLManager();
|
||||
ContextManager->initialize(CreationParams, data);
|
||||
|
||||
#endif
|
||||
VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, ContextManager);
|
||||
}
|
||||
#else
|
||||
os::Printer::log("No OpenGL-ES2 support compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
break;
|
||||
case video::EDT_WEBGL1:
|
||||
#ifdef _IRR_COMPILE_WITH_WEBGL1_
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_WEBGL1_
|
||||
video::SExposedVideoData data;
|
||||
data.OpenGLLinux.X11Window = XWindow;
|
||||
data.OpenGLLinux.X11Display = XDisplay;
|
||||
|
||||
ContextManager = new video::CEGLManager();
|
||||
ContextManager->initialize(CreationParams, data);
|
||||
|
||||
#endif
|
||||
VideoDriver = video::createWebGL1Driver(CreationParams, FileSystem, ContextManager);
|
||||
}
|
||||
#else
|
||||
os::Printer::log("No WebGL1 support compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
break;
|
||||
case video::EDT_NULL:
|
||||
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
|
||||
@ -591,7 +577,7 @@ void CIrrDeviceLinux::createDriver()
|
||||
default:
|
||||
os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR);
|
||||
break;
|
||||
#else
|
||||
#else // no X11
|
||||
case video::EDT_NULL:
|
||||
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
|
||||
break;
|
||||
|
@ -433,14 +433,6 @@ long GetDictionaryLong(CFDictionaryRef theDict, const void *key)
|
||||
return value;
|
||||
}
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
IVideoDriver *createOpenGLDriver(const SIrrlichtCreationParameters ¶m, io::IFileSystem *io, IContextManager *contextManager);
|
||||
}
|
||||
} // end namespace irr
|
||||
|
||||
static bool firstLaunch = true;
|
||||
|
||||
@implementation CIrrDelegateOSX {
|
||||
@ -721,6 +713,7 @@ void CIrrDeviceMacOSX::createDriver()
|
||||
#endif
|
||||
break;
|
||||
|
||||
case video::EDT_OPENGL3:
|
||||
case video::EDT_OGLES2:
|
||||
os::Printer::log("This driver is not available on OSX.", ELL_ERROR);
|
||||
break;
|
||||
|
@ -29,53 +29,6 @@
|
||||
|
||||
static int SDLDeviceInstances = 0;
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
IVideoDriver *createOpenGLDriver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager);
|
||||
#else
|
||||
static IVideoDriver *createOpenGLDriver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager)
|
||||
{
|
||||
os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_OPENGL3
|
||||
IVideoDriver *createOpenGL3Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager);
|
||||
#else
|
||||
static IVideoDriver *createOpenGL3Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager)
|
||||
{
|
||||
os::Printer::log("No OpenGL 3 support compiled in.", ELL_ERROR);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
IVideoDriver *createOGLES2Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager);
|
||||
#else
|
||||
static IVideoDriver *createOGLES2Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager)
|
||||
{
|
||||
os::Printer::log("No OpenGL ES 2 support compiled in.", ELL_ERROR);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WEBGL1_
|
||||
IVideoDriver *createWebGL1Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager);
|
||||
#else
|
||||
static IVideoDriver *createWebGL1Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager)
|
||||
{
|
||||
os::Printer::log("No WebGL 1 support compiled in.", ELL_ERROR);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
} // end namespace video
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
namespace irr
|
||||
{
|
||||
#ifdef _IRR_EMSCRIPTEN_PLATFORM_
|
||||
|
@ -17,6 +17,42 @@
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
#ifndef _IRR_COMPILE_WITH_OPENGL_
|
||||
IVideoDriver *createOpenGLDriver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager)
|
||||
{
|
||||
os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_OPENGL3
|
||||
IVideoDriver *createOpenGL3Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager)
|
||||
{
|
||||
os::Printer::log("No OpenGL 3 support compiled in.", ELL_ERROR);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _IRR_COMPILE_WITH_OGLES2_
|
||||
IVideoDriver *createOGLES2Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager)
|
||||
{
|
||||
os::Printer::log("No OpenGL ES 2 support compiled in.", ELL_ERROR);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _IRR_COMPILE_WITH_WEBGL1_
|
||||
IVideoDriver *createWebGL1Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager)
|
||||
{
|
||||
os::Printer::log("No WebGL 1 support compiled in.", ELL_ERROR);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceStub::CIrrDeviceStub(const SIrrlichtCreationParameters ¶ms) :
|
||||
IrrlichtDevice(), VideoDriver(0), GUIEnvironment(0), SceneManager(0),
|
||||
|
@ -33,7 +33,15 @@ IFileSystem *createFileSystem();
|
||||
|
||||
namespace video
|
||||
{
|
||||
IVideoDriver *createNullDriver(io::IFileSystem *io, const core::dimension2d<u32> &screenSize);
|
||||
IVideoDriver *createNullDriver(io::IFileSystem *io, const core::dimension2d<u32> &screenSize);
|
||||
|
||||
IVideoDriver *createOpenGLDriver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager);
|
||||
|
||||
IVideoDriver *createOpenGL3Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager);
|
||||
|
||||
IVideoDriver *createOGLES2Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager);
|
||||
|
||||
IVideoDriver *createWebGL1Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager);
|
||||
}
|
||||
|
||||
//! Stub for an Irrlicht Device implementation
|
||||
|
@ -34,24 +34,10 @@
|
||||
#include "CEGLManager.h"
|
||||
#endif
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_OPENGL_)
|
||||
#if defined(_IRR_COMPILE_WITH_WGL_MANAGER_)
|
||||
#include "CWGLManager.h"
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
IVideoDriver *createOpenGLDriver(const irr::SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager);
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
IVideoDriver *createOGLES2Driver(const irr::SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager);
|
||||
#endif
|
||||
}
|
||||
} // end namespace irr
|
||||
|
||||
namespace irr
|
||||
{
|
||||
struct SJoystickWin32Control
|
||||
@ -880,14 +866,23 @@ void CIrrDeviceWin32::createDriver()
|
||||
|
||||
ContextManager = new video::CWGLManager();
|
||||
ContextManager->initialize(CreationParams, video::SExposedVideoData(HWnd));
|
||||
|
||||
#endif
|
||||
VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, ContextManager);
|
||||
|
||||
if (!VideoDriver)
|
||||
os::Printer::log("Could not create OpenGL driver.", ELL_ERROR);
|
||||
#else
|
||||
os::Printer::log("OpenGL driver was not compiled in.", ELL_ERROR);
|
||||
break;
|
||||
case video::EDT_OPENGL3:
|
||||
#ifdef ENABLE_OPENGL3
|
||||
switchToFullScreen();
|
||||
|
||||
ContextManager = new video::CWGLManager();
|
||||
ContextManager->initialize(CreationParams, video::SExposedVideoData(HWnd));
|
||||
#endif
|
||||
VideoDriver = video::createOpenGL3Driver(CreationParams, FileSystem, ContextManager);
|
||||
|
||||
if (!VideoDriver)
|
||||
os::Printer::log("Could not create OpenGL 3 driver.", ELL_ERROR);
|
||||
break;
|
||||
case video::EDT_OGLES2:
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
@ -895,14 +890,11 @@ void CIrrDeviceWin32::createDriver()
|
||||
|
||||
ContextManager = new video::CEGLManager();
|
||||
ContextManager->initialize(CreationParams, video::SExposedVideoData(HWnd));
|
||||
|
||||
#endif
|
||||
VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, ContextManager);
|
||||
|
||||
if (!VideoDriver)
|
||||
os::Printer::log("Could not create OpenGL-ES2 driver.", ELL_ERROR);
|
||||
#else
|
||||
os::Printer::log("OpenGL-ES2 driver was not compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
break;
|
||||
case video::EDT_WEBGL1:
|
||||
os::Printer::log("WebGL1 driver not supported on Win32 device.", ELL_ERROR);
|
||||
|
@ -123,10 +123,10 @@ if(USE_SDL2)
|
||||
if(NOT ANDROID)
|
||||
set(DEFAULT_OPENGL3 TRUE)
|
||||
endif()
|
||||
option(ENABLE_OPENGL3 "Enable OpenGL 3+" ${DEFAULT_OPENGL3})
|
||||
else()
|
||||
set(ENABLE_OPENGL3 FALSE)
|
||||
set(DEFAULT_OPENGL3 FALSE)
|
||||
endif()
|
||||
option(ENABLE_OPENGL3 "Enable OpenGL 3+" ${DEFAULT_OPENGL3})
|
||||
|
||||
if(ANDROID OR EMSCRIPTEN)
|
||||
set(ENABLE_OPENGL FALSE)
|
||||
@ -152,9 +152,11 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_OPENGL)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_OPENGL_)
|
||||
set(OPENGL_DIRECT_LINK TRUE) # driver relies on this
|
||||
if(ENABLE_OPENGL OR (ENABLE_OPENGL3 AND NOT USE_SDL2))
|
||||
if(ENABLE_OPENGL)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_OPENGL_)
|
||||
set(OPENGL_DIRECT_LINK TRUE) # driver relies on this
|
||||
endif()
|
||||
if(DEVICE STREQUAL "WINDOWS")
|
||||
add_definitions(-D_IRR_COMPILE_WITH_WGL_MANAGER_)
|
||||
elseif(DEVICE STREQUAL "X11")
|
||||
@ -165,7 +167,11 @@ if(ENABLE_OPENGL)
|
||||
endif()
|
||||
|
||||
if(ENABLE_OPENGL3)
|
||||
if (NOT USE_SDL2)
|
||||
if(DEVICE STREQUAL "WINDOWS")
|
||||
# supported
|
||||
elseif(DEVICE STREQUAL "X11")
|
||||
# supported
|
||||
elseif (NOT USE_SDL2)
|
||||
message(FATAL_ERROR "OpenGL 3 driver requires SDL2")
|
||||
endif()
|
||||
endif()
|
||||
|
@ -3239,19 +3239,9 @@ COpenGLCacheHandler *COpenGLDriver::getCacheHandler() const
|
||||
return CacheHandler;
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_OPENGL_
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
IVideoDriver *createOpenGLDriver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager)
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
COpenGLDriver *ogl = new COpenGLDriver(params, io, contextManager);
|
||||
|
||||
if (!ogl->initDriver()) {
|
||||
@ -3260,10 +3250,8 @@ IVideoDriver *createOpenGLDriver(const SIrrlichtCreationParameters ¶ms, io::
|
||||
}
|
||||
|
||||
return ogl;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
#endif // opengl
|
||||
|
@ -226,8 +226,8 @@ void COpenGL3DriverBase::initVersion()
|
||||
printVersion();
|
||||
|
||||
// print renderer information
|
||||
VendorName = GL.GetString(GL_VENDOR);
|
||||
os::Printer::log("Vendor", VendorName.c_str(), ELL_INFORMATION);
|
||||
VendorName = GL.GetString(GL_RENDERER);
|
||||
os::Printer::log("Renderer", VendorName.c_str(), ELL_INFORMATION);
|
||||
|
||||
Version = getVersionFromOpenGL();
|
||||
}
|
||||
|
@ -34,8 +34,14 @@ OpenGLVersion COpenGL3Driver::getVersionFromOpenGL() const
|
||||
|
||||
void COpenGL3Driver::initFeatures()
|
||||
{
|
||||
assert(Version.Spec == OpenGLSpec::Compat);
|
||||
assert(isVersionAtLeast(3, 2));
|
||||
if (Version.Spec != OpenGLSpec::Compat) {
|
||||
os::Printer::log("OpenGL 3 driver requires Compatibility Mode", ELL_ERROR);
|
||||
throw std::exception();
|
||||
}
|
||||
if (!isVersionAtLeast(3, 2)) {
|
||||
os::Printer::log("OpenGL 3 driver requires OpenGL >= 3.2 ", ELL_ERROR);
|
||||
throw std::exception();
|
||||
}
|
||||
initExtensions();
|
||||
|
||||
TextureFormats[ECF_A1R5G5B5] = {GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV}; // WARNING: may not be renderable
|
||||
|
Loading…
Reference in New Issue
Block a user