Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Enable unified driver with all devices
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Feb 16, 2024
1 parent 0281696 commit f4a989e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 45 deletions.
71 changes: 30 additions & 41 deletions source/Irrlicht/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()

Expand All @@ -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()
Expand Down Expand Up @@ -347,6 +339,8 @@ set(IRRDRVROBJ
mt_opengl_loader.cpp
)

# the two legacy drivers

if(ENABLE_OPENGL)
set(IRRDRVROBJ
${IRRDRVROBJ}
Expand All @@ -366,25 +360,11 @@ if(ENABLE_GLES1)
)
endif()

set(IRRIMAGEOBJ
CColorConverter.cpp
CImage.cpp
CImageLoaderBMP.cpp
CImageLoaderJPG.cpp
CImageLoaderPNG.cpp
CImageLoaderTGA.cpp
CImageWriterJPG.cpp
CImageWriterPNG.cpp
)

add_library(IRRVIDEOOBJ OBJECT
CFPSCounter.cpp
${IRRDRVROBJ}
${IRRIMAGEOBJ}
)
# the unified drivers

if(USE_SDLGL)
target_sources(IRRVIDEOOBJ PRIVATE
if(ENABLE_OPENGL3 OR ENABLE_GLES2)
set(IRRDRVROBJ
${IRRDRVROBJ}
OpenGL/Driver.cpp
OpenGL/ExtensionHandler.cpp
OpenGL/FixedPipelineRenderer.cpp
Expand All @@ -393,27 +373,37 @@ if(USE_SDLGL)
)
endif()

if(USE_SDLGL3)
target_sources(IRRVIDEOOBJ PRIVATE
if(ENABLE_OPENGL3)
set(IRRDRVROBJ
${IRRDRVROBJ}
OpenGL3/Driver.cpp
)
endif()

if(USE_SDLGLES2)
target_sources(IRRVIDEOOBJ PRIVATE
if(ENABLE_GLES2)
set(IRRDRVROBJ
${IRRDRVROBJ}
OpenGLES2/Driver.cpp
)
elseif(ENABLE_GLES2)
target_sources(IRRVIDEOOBJ PRIVATE
COGLES2Driver.cpp
COGLES2ExtensionHandler.cpp
COGLES2FixedPipelineRenderer.cpp
COGLES2MaterialRenderer.cpp
COGLES2Renderer2D.cpp
CWebGL1Driver.cpp
)
endif()

set(IRRIMAGEOBJ
CColorConverter.cpp
CImage.cpp
CImageLoaderBMP.cpp
CImageLoaderJPG.cpp
CImageLoaderPNG.cpp
CImageLoaderTGA.cpp
CImageWriterJPG.cpp
CImageWriterPNG.cpp
)

add_library(IRRVIDEOOBJ OBJECT
CFPSCounter.cpp
${IRRDRVROBJ}
${IRRIMAGEOBJ}
)

add_library(IRRIOOBJ OBJECT
CFileList.cpp
CFileSystem.cpp
Expand Down Expand Up @@ -520,7 +510,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>"
Expand Down
2 changes: 1 addition & 1 deletion source/Irrlicht/COpenGLCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 15 additions & 3 deletions source/Irrlicht/OpenGL/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit f4a989e

Please sign in to comment.