Skip to content

Commit 94d3e4d

Browse files
committed
Merge branch 'gl-context-refactor'
2 parents 77da1c8 + 2156236 commit 94d3e4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+8280
-262
lines changed

CMakeLists.txt

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ project(duckstation C CXX)
44
# Pull in modules.
55
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules/")
66

7+
# Platform detection.
8+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
9+
set(LINUX TRUE)
10+
set(SUPPORTS_X11 TRUE)
11+
endif()
12+
13+
14+
# Global options.
715
if(NOT ANDROID)
816
option(BUILD_SDL_FRONTEND "Build the SDL frontend" ON)
917
option(BUILD_QT_FRONTEND "Build the Qt frontend" ON)
@@ -12,6 +20,15 @@ if(NOT ANDROID)
1220
endif()
1321

1422

23+
# OpenGL context creation methods.
24+
if(SUPPORTS_X11)
25+
option(USE_X11 "Support X11 window system" ON)
26+
endif()
27+
if(LINUX OR ANDROID)
28+
option(USE_EGL "Support EGL OpenGL context creation" ON)
29+
endif()
30+
31+
1532
# Common include/library directories on Windows.
1633
if(WIN32)
1734
set(SDL2_FOUND TRUE)
@@ -40,12 +57,12 @@ if(NOT ANDROID)
4057
endif()
4158
endif()
4259

43-
if(ANDROID)
60+
if(USE_EGL)
4461
find_package(EGL REQUIRED)
45-
else()
46-
find_package(OpenGL COMPONENTS EGL GLX OpenGL)
4762
endif()
48-
63+
if(USE_X11)
64+
find_package(X11 REQUIRED)
65+
endif()
4966

5067
# Set _DEBUG macro for Debug builds.
5168
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")

dep/glad/CMakeLists.txt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@ set(SRCS
22
src/glad.c
33
)
44

5-
add_library(glad ${SRCS})
5+
# Linking as a static library breaks on macOS, see https://github.com/libigl/libigl/issues/751
6+
if(APPLE)
7+
add_library(glad OBJECT ${SRCS})
8+
else()
9+
add_library(glad ${SRCS})
10+
endif()
11+
612
target_include_directories(glad PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
713
target_include_directories(glad INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
8-
target_link_libraries(glad Threads::Threads "${CMAKE_DL_LIBS}")
14+
target_link_libraries(glad PRIVATE Threads::Threads "${CMAKE_DL_LIBS}")
15+
16+
if(WIN32)
17+
target_sources(glad PRIVATE src/glad_wgl.c)
18+
else()
19+
if(USE_EGL)
20+
target_sources(glad PRIVATE src/glad_egl.c)
21+
target_link_libraries(glad PRIVATE EGL::EGL)
22+
endif()
23+
if(SUPPORTS_X11)
24+
target_sources(glad PRIVATE src/glad_glx.c)
25+
endif()
26+
endif()

dep/glad/glad.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@
3636
</ItemGroup>
3737
<ItemGroup>
3838
<ClCompile Include="src\glad.c" />
39+
<ClCompile Include="src\glad_wgl.c" />
3940
</ItemGroup>
4041
<ItemGroup>
4142
<ClInclude Include="include\glad.h" />
43+
<ClInclude Include="include\glad_wgl.h" />
4244
<ClInclude Include="include\khrplatform.h" />
4345
</ItemGroup>
4446
<PropertyGroup Label="Globals">

dep/glad/glad.vcxproj.filters

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup>
44
<ClCompile Include="src\glad.c" />
5+
<ClCompile Include="src\glad_wgl.c" />
56
</ItemGroup>
67
<ItemGroup>
78
<ClInclude Include="include\khrplatform.h" />
89
<ClInclude Include="include\glad.h" />
10+
<ClInclude Include="include\glad_wgl.h" />
911
</ItemGroup>
1012
</Project>

0 commit comments

Comments
 (0)