Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.

Commit 4afa636

Browse files
committed
add function table
1 parent 29097ce commit 4afa636

File tree

4 files changed

+1320
-19
lines changed

4 files changed

+1320
-19
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ add_subdirectory(external/glslang)
1717
add_subdirectory(external/glfw)
1818

1919
file(GLOB_RECURSE MGL_SOURCES
20+
MGL/spirv_cross_c.cpp
2021
MGL/src/*.c
22+
MGL/src/*.cpp
2123
MGL/src/*.m
22-
MGL/spirv_cross_c.cpp
2324
)
2425
add_library(mgl_static STATIC ${MGL_SOURCES})
2526
target_include_directories(mgl_static PUBLIC

MGL/src/function_table.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <unordered_map>
2+
#include <string>
3+
4+
#include "glcorearb.h"
5+
6+
namespace
7+
{
8+
std::unordered_map<std::string, void*> globalTable;
9+
10+
void initializeTable()
11+
{
12+
globalTable.clear();
13+
globalTable.reserve(1500);
14+
#include "function_table_data.inl"
15+
}
16+
}
17+
18+
extern "C"
19+
{
20+
void MGLfunctionTableInitialize(void)
21+
{
22+
assert(globalTable.empty());
23+
initializeTable();
24+
}
25+
26+
void *MGLfunctionTableFind(const char *name)
27+
{
28+
const std::string n(name);
29+
auto it = globalTable.find(n);
30+
if (it == globalTable.end())
31+
return nullptr;
32+
return it.second;
33+
}
34+
}

0 commit comments

Comments
 (0)