Enable unified driver with all devices

This commit is contained in:
sfan5 2024-02-16 23:24:53 +01:00
parent 19f0f707a6
commit 0a77ef5dc2
3 changed files with 46 additions and 45 deletions

@ -199,8 +199,6 @@ if(ENABLE_OPENGL3)
if (NOT USE_SDL2)
message(FATAL_ERROR "OpenGL 3 driver requires SDL2")
endif()
set(USE_SDLGL ON)
set(USE_SDLGL3 ON)
endif()
if(ENABLE_GLES1)
@ -216,12 +214,8 @@ endif()
if(ENABLE_GLES2)
add_definitions(-D_IRR_COMPILE_WITH_OGLES2_)
set(OPENGLES2_DIRECT_LINK TRUE) # not yet possible to remove this
if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$" OR EMSCRIPTEN)
add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_)
elseif(DEVICE STREQUAL "SDL")
set(USE_SDLGL ON)
set(USE_SDLGLES2 ON)
endif()
endif()
@ -243,10 +237,8 @@ message(STATUS "Device: ${DEVICE}")
message(STATUS "OpenGL: ${ENABLE_OPENGL}")
message(STATUS "OpenGL 3: ${ENABLE_OPENGL3}")
message(STATUS "OpenGL ES: ${ENABLE_GLES1}")
if (USE_SDLGLES2)
if (ENABLE_GLES2)
message(STATUS "OpenGL ES 2: ON (unified)")
elseif (ENABLE_GLES2)
message(STATUS "OpenGL ES 2: ON (legacy)")
else()
message(STATUS "OpenGL ES 2: OFF")
endif()
@ -347,6 +339,8 @@ set(IRRDRVROBJ
mt_opengl_loader.cpp
)
# the two legacy drivers
if(ENABLE_OPENGL)
set(IRRDRVROBJ
${IRRDRVROBJ}
@ -365,6 +359,33 @@ if(ENABLE_GLES1)
)
endif()
# the unified drivers
if(ENABLE_OPENGL3 OR ENABLE_GLES2)
set(IRRDRVROBJ
${IRRDRVROBJ}
OpenGL/Driver.cpp
OpenGL/ExtensionHandler.cpp
OpenGL/FixedPipelineRenderer.cpp
OpenGL/MaterialRenderer.cpp
OpenGL/Renderer2D.cpp
)
endif()
if(ENABLE_OPENGL3)
set(IRRDRVROBJ
${IRRDRVROBJ}
OpenGL3/Driver.cpp
)
endif()
if(ENABLE_GLES2)
set(IRRDRVROBJ
${IRRDRVROBJ}
OpenGLES2/Driver.cpp
)
endif()
set(IRRIMAGEOBJ
CColorConverter.cpp
CImage.cpp
@ -382,37 +403,6 @@ add_library(IRRVIDEOOBJ OBJECT
${IRRIMAGEOBJ}
)
if(USE_SDLGL)
target_sources(IRRVIDEOOBJ PRIVATE
OpenGL/Driver.cpp
OpenGL/ExtensionHandler.cpp
OpenGL/FixedPipelineRenderer.cpp
OpenGL/MaterialRenderer.cpp
OpenGL/Renderer2D.cpp
)
endif()
if(USE_SDLGL3)
target_sources(IRRVIDEOOBJ PRIVATE
OpenGL3/Driver.cpp
)
endif()
if(USE_SDLGLES2)
target_sources(IRRVIDEOOBJ PRIVATE
OpenGLES2/Driver.cpp
)
elseif(ENABLE_GLES2)
target_sources(IRRVIDEOOBJ PRIVATE
COGLES2Driver.cpp
COGLES2ExtensionHandler.cpp
COGLES2FixedPipelineRenderer.cpp
COGLES2MaterialRenderer.cpp
COGLES2Renderer2D.cpp
CWebGL1Driver.cpp
)
endif()
add_library(IRRIOOBJ OBJECT
CFileList.cpp
CFileSystem.cpp
@ -519,7 +509,6 @@ target_link_libraries(IrrlichtMt PRIVATE
"$<$<BOOL:${OPENGL_DIRECT_LINK}>:${OPENGL_LIBRARIES}>"
"$<$<BOOL:${OPENGLES_DIRECT_LINK}>:${OPENGLES_LIBRARY}>"
"$<$<BOOL:${OPENGLES2_DIRECT_LINK}>:${OPENGLES2_LIBRARIES}>"
${EGL_LIBRARY}
"$<$<PLATFORM_ID:Android>:-landroid -llog>"

@ -6,7 +6,7 @@
#ifdef _IRR_COMPILE_WITH_OPENGL_
#if defined(_IRR_WINDOWS_API_)
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define GL_GLEXT_LEGACY 1

@ -5,9 +5,21 @@
#pragma once
#define GL_GLEXT_PROTOTYPES
#include <SDL_video.h>
#include <SDL_opengl.h>
#include "irrTypes.h"
// even though we have mt_opengl.h our driver code still uses GL_* constants
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
#include <GL/gl.h>
#include <GL/glext.h>
#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
#include <OpenGL/gl.h>
// not sure if this works without glext.h?
#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && !defined(_IRR_COMPILE_WITH_X11_DEVICE_)
#include <SDL_video.h>
#include <SDL_opengl.h>
#else
#include <GL/gl.h>
#include <GL/glext.h>
#endif
namespace irr
{