Skip to content

Commit 7fc1741

Browse files
author
Alex D
committed
progress of writing webgl wrapper
1 parent e0df926 commit 7fc1741

File tree

5 files changed

+55
-30
lines changed

5 files changed

+55
-30
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Win32",
5+
"includePath": [
6+
"${workspaceFolder}/**"
7+
],
8+
"defines": [
9+
"_DEBUG",
10+
"UNICODE",
11+
"_UNICODE"
12+
],
13+
"windowsSdkVersion": "10.0.17763.0",
14+
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe",
15+
"cStandard": "c11",
16+
"cppStandard": "c++17",
17+
"intelliSenseMode": "msvc-x64"
18+
}
19+
],
20+
"version": 4
21+
}

experiments/WebGLAdapter/gl.c

+20-17
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,34 @@
1010
#endif
1111

1212
#ifdef _WIN32
13-
# define LIBRARY_API extern __declspec(dllexport)
13+
#define LIBRARY_API extern __declspec(dllexport)
1414
#elif
15-
# define LIBRARY_API static
15+
#define LIBRARY_API static
1616
#endif
1717

1818
#ifdef __cplusplus
19-
extern "C" {
19+
extern "C"
20+
{
2021
#endif
2122

22-
static int createBuffer() {
23-
GLuint val;
24-
glGenBuffers(1, &val);
25-
return val;
26-
}
23+
static int createBuffer()
24+
{
25+
GLuint val;
26+
glGenBuffers(1, &val);
27+
return val;
28+
}
2729

28-
static const struct luaL_Reg webgl[] = {
29-
{"createBuffer", createBuffer},
30-
{NULL, NULL} /* sentinel */
31-
};
30+
static const struct luaL_Reg webgl[] = {
31+
{"createBuffer", createBuffer},
32+
{NULL, NULL} /* sentinel */
33+
};
3234

33-
//name of this function is not flexible
34-
LIBRARY_API int luaopen_webgl(lua_State *L) {
35-
luaL_newlib(L, webgl);
36-
return 1;
37-
}
35+
//name of this function is not flexible
36+
LIBRARY_API int luaopen_webgl(lua_State *L)
37+
{
38+
luaL_newlib(L, webgl);
39+
return 1;
40+
}
3841

3942
#ifdef __cplusplus
4043
}

experiments/experiments.code-workspace

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
{
88
"name": "JSLib",
99
"path": "./jslib"
10+
},
11+
{
12+
"name": "WebGL Lua adapter",
13+
"path": "./WebGLAdapter"
1014
}
1115
],
1216
"settings": {}

thirdparty/lua-build/CMakeLists.txt

+10-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ SET(CWARNSCPP "-Wextra -Wshadow -Wsign-compare -Wundef -Wwrite-strings -Wredunda
88
SET(CWARNSC "-Wdeclaration-after-statement -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wc++-compat -Wold-style-definition")
99

1010
if (MSVC)
11-
SET(MYCFLAGS "/DLUA_USE_WINDOWS")
11+
#SET(MYCFLAGS "/DLUA_USE_WINDOWS")
12+
SET(MYCFLAGS "${MYCFLAGS} /DLUA_BUILD_AS_DLL")
1213

1314
SET(BUILD_ARCH "win32")
1415
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /Zi /EHsc /DDEBUG /wd4250 /wd4200 /wd4291 /wd4996 /wd4800 /MP8 /bigobj ${MYCFLAGS}")
@@ -61,17 +62,17 @@ file(GLOB LUAC_SRC
6162
"${PROJECT_SOURCE_DIR}/../lua/src/luac.c"
6263
)
6364

64-
get_filename_component(full_path_lbitlib_c ${PROJECT_SOURCE_DIR}/../lua/src/lbitlib.c ABSOLUTE)
65-
list(REMOVE_ITEM CORE_SRC "${full_path_lbitlib_c}")
66-
get_filename_component(full_path_lua_c ${PROJECT_SOURCE_DIR}/../lua/src/lua.c ABSOLUTE)
67-
list(REMOVE_ITEM CORE_SRC "${full_path_lua_c}")
68-
get_filename_component(full_path_luac_c ${PROJECT_SOURCE_DIR}/../lua/src/luac.c ABSOLUTE)
69-
list(REMOVE_ITEM CORE_SRC "${full_path_luac_c}")
65+
list(REMOVE_ITEM CORE_SRC "${PROJECT_SOURCE_DIR}/../lua/src/lbitlib.c")
66+
list(REMOVE_ITEM CORE_SRC "${PROJECT_SOURCE_DIR}/../lua/src/lua.c")
67+
list(REMOVE_ITEM CORE_SRC "${PROJECT_SOURCE_DIR}/../lua/src/luac.c")
68+
69+
add_library (core SHARED ${CORE_SRC})
70+
set_target_properties(core PROPERTIES OUTPUT_NAME "lua53")
71+
target_link_libraries (core ${MYLIBS})
7072

71-
add_library (core ${LUA_SRC} ${CORE_SRC})
72-
target_link_libraries (lua ${MYLIBS})
7373
add_executable (lua ${LUA_SRC})
7474
target_link_libraries (lua core)
75+
7576
add_executable (luac ${LUAC_SRC})
7677
target_link_libraries (luac core)
7778

typescriptlua.code-workspace

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
"name": "Experiments"
1717
"path": "./experiments"
1818
},
19-
{
20-
"name": "LUA Source Code"
21-
"path": "./lua"
22-
},
2319
{
2420
"name": "VSCode Lua Debugger"
2521
"path": "./vscode-lua-debug"

0 commit comments

Comments
 (0)