Skip to content

Commit 903a43d

Browse files
authored
Revise coding standard and unit-testing. (#4)
* Read xml specs directly via github. * Revise CMakeList behaviour. * Support GL_VERSION_4_6. * Revive EGL and WGL unit-tests. * Utilize CTest for unit-tests. * Refactor EGL & WGL unit-tests. * Regenerate API. * Refactor generator. * Regenerate API. * Fix whitespace.
1 parent c98a43e commit 903a43d

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

+8579
-5958
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
* text=auto
22
*.sh text eol=lf
33
*.sln text eol=crlf
4+
*.csproj text eol=crlf

.gitignore

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1-
/build
1+
build/
2+
bin/
3+
obj/
4+
packages/
5+
Debug/
6+
Release/
7+
TestResults/
8+
MigrationBackup/
9+
ipch/
10+
vs*/
11+
.vs/
12+
*.vcxproj.user
13+
*.sdf
14+
*.suo
15+
*.opendb
16+
*.log

CMakeLists.txt

Lines changed: 101 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,129 @@
1-
cmake_minimum_required (VERSION 3.2)
1+
cmake_minimum_required (VERSION 3.30)
2+
3+
# Enable Hot Reload for MSVC compilers if supported.
4+
if (POLICY CMP0141)
5+
cmake_policy(SET CMP0141 NEW)
6+
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
7+
endif()
28

39
project (wrangle-gl)
410

5-
# test-egl
11+
enable_testing ()
12+
13+
set(CMAKE_CXX_STANDARD 17)
614

715
include_directories ("include")
816

9-
add_executable ("test-egl"
10-
"include/wrangle.h"
17+
if(WIN32)
18+
include(FetchContent)
19+
FetchContent_Declare(
20+
mali_gles_emulator
21+
URL https://developer.arm.com/-/media/Files/downloads/open-gl-es-emulator/3.0.4/Mali_OpenGL_ES_Emulator-v3.0.4-2-g8d905-Windows-64bit.zip?revision=89a52b4d-c891-4abc-be58-50db8c20bff9?product=OpenGL%20ES%20Emulator,64-bit,,Windows,3.0.4
22+
)
23+
FetchContent_MakeAvailable(mali_gles_emulator)
24+
message(STATUS "Fetched mali_gles_emulator to ${mali_gles_emulator_SOURCE_DIR}")
25+
find_file(OPENGL_EGL_LIBRARY
26+
NAMES libEGL.lib
27+
PATHS ${mali_gles_emulator_SOURCE_DIR}
28+
REQUIRED
29+
)
30+
find_file(OPENGL_GLESv2_LIBRARY
31+
NAMES libGLESv2.lib
32+
PATHS ${mali_gles_emulator_SOURCE_DIR}
33+
REQUIRED
34+
)
35+
set(OPENGL_egl_LIBRARY ${OPENGL_EGL_LIBRARY})
36+
set(OPENGL_opengl_LIBRARY ${OPENGL_GLESv2_LIBRARY})
37+
# Runtime dependencies
38+
configure_file ("${mali_gles_emulator_SOURCE_DIR}/libEGL.dll" "${CMAKE_CURRENT_BINARY_DIR}/libEGL.dll" COPYONLY)
39+
configure_file ("${mali_gles_emulator_SOURCE_DIR}/libGLESv2.dll" "${CMAKE_CURRENT_BINARY_DIR}/libGLESv2.dll" COPYONLY)
40+
configure_file ("${mali_gles_emulator_SOURCE_DIR}/libMaliEmulator.dll" "${CMAKE_CURRENT_BINARY_DIR}/libMaliEmulator.dll" COPYONLY)
41+
configure_file ("${mali_gles_emulator_SOURCE_DIR}/log4cplus.dll" "${CMAKE_CURRENT_BINARY_DIR}/log4cplus.dll" COPYONLY)
42+
else()
43+
find_package(OpenGL REQUIRED COMPONENTS EGL)
44+
endif()
45+
46+
# egl_glcore
47+
48+
add_executable (egl_glcore
49+
WIN32
50+
"include/wrangle-gl.h"
1151
"include/wrangle-egl.h"
52+
"src/wrangle-gl.cpp"
1253
"src/wrangle-egl.cpp"
1354
"tests/test-egl.cpp")
1455

15-
target_compile_options ("test-egl"
16-
PUBLIC "-DGLEW_USE_EGL")
56+
target_compile_options (egl_glcore
57+
PUBLIC "-DGLEW_USE_EGL"
58+
PUBLIC "-DGLEW_USE_OPENGL")
1759

18-
if(WIN32)
19-
# https://developer.arm.com/-/media/Files/downloads/open-gl-es-emulator/3.0.4/Mali_OpenGL_ES_Emulator-v3.0.4-2-g8d905-Windows-64bit.zip?revision=89a52b4d-c891-4abc-be58-50db8c20bff9?product=OpenGL%20ES%20Emulator,64-bit,,Windows,3.0.4
20-
#target_link_libraries ("test-egl"
21-
# "${CMAKE_CURRENT_SOURCE_DIR}/khronos/emulator/ARM/libEGL.lib"
22-
# "${CMAKE_CURRENT_SOURCE_DIR}/khronos/emulator/ARM/libGLESv2.lib")
23-
#configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/khronos/emulator/AMD/x86/libEGL.dll" "${CMAKE_CURRENT_BINARY_DIR}/libEGL.dll" COPYONLY)
24-
#configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/khronos/emulator/AMD/x86/libGLESv2.dll" "${CMAKE_CURRENT_BINARY_DIR}/libGLESv2.dll" COPYONLY)
25-
else()
26-
find_package(OpenGL REQUIRED COMPONENTS EGL)
27-
if(NOT OPENGL_FOUND)
28-
message(SEND_ERROR "Error: No OpenGL found.")
29-
endif()
30-
target_link_libraries ("test-egl"
60+
target_link_libraries (egl_glcore
61+
"${OPENGL_egl_LIBRARY}")
62+
63+
add_test(NAME run_egl_glcore COMMAND $<TARGET_FILE:egl_glcore>)
64+
65+
# egl_gles
66+
67+
add_executable (egl_gles
68+
WIN32
69+
"include/wrangle-egl.h"
70+
"include/wrangle-gles.h"
71+
"src/wrangle-egl.cpp"
72+
"src/wrangle-gles.cpp"
73+
"tests/test-egl.cpp")
74+
75+
target_compile_options (egl_gles
76+
PUBLIC "-DGLEW_USE_EGL"
77+
PUBLIC "-DGLEW_USE_OPENGL_ES")
78+
79+
target_link_libraries (egl_gles
3180
"${OPENGL_egl_LIBRARY}"
32-
"${OPENGL_opengl_LIBRARY}"
33-
dl)
81+
"${OPENGL_opengl_LIBRARY}")
82+
83+
if(LINUX)
84+
target_link_libraries (egl_gles dl)
3485
endif()
3586

87+
add_test(NAME run_egl_gles COMMAND $<TARGET_FILE:egl_gles>)
88+
89+
# wgl_glcore (Windows only)
90+
3691
if(WIN32)
37-
set_target_properties("test-egl" PROPERTIES
38-
LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS"
39-
LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS"
40-
LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS"
41-
LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
92+
93+
add_executable (wgl_glcore
94+
WIN32
95+
"include/wrangle-gl.h"
96+
"include/wrangle-wgl.h"
97+
"src/wrangle-gl.cpp"
98+
"src/wrangle-wgl.cpp"
99+
"tests/test-wgl.cpp"
100+
)
101+
102+
target_compile_options (wgl_glcore
103+
PUBLIC "-DGLEW_USE_WGL"
104+
PUBLIC "-DGLEW_USE_OPENGL")
105+
106+
add_test(NAME run_wgl_glcore COMMAND $<TARGET_FILE:wgl_glcore>)
107+
42108
endif()
43109

44-
# test-wgl (Windows only)
110+
# wgl_gles (Windows only)
45111

46112
if(WIN32)
47-
add_executable ("test-wgl"
48-
"include/wrangle.h"
113+
114+
add_executable (wgl_gles
115+
WIN32
49116
"include/wrangle-wgl.h"
50-
"include/wrangle-gl.h"
51117
"include/wrangle-gles.h"
52118
"src/wrangle-wgl.cpp"
53-
"src/wrangle-gl.cpp"
54119
"src/wrangle-gles.cpp"
55-
"tests/test-wgl.cpp")
120+
"tests/test-wgl.cpp"
121+
)
56122

57-
target_compile_options ("test-wgl"
123+
target_compile_options (wgl_gles
58124
PUBLIC "-DGLEW_USE_WGL"
59125
PUBLIC "-DGLEW_USE_OPENGL_ES")
60126

61-
set_target_properties("test-wgl" PROPERTIES
62-
LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS"
63-
LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS"
64-
LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS"
65-
LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
127+
add_test(NAME run_wgl_gles COMMAND $<TARGET_FILE:wgl_gles>)
128+
66129
endif()

0 commit comments

Comments
 (0)