Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.

Commit d391f3f

Browse files
Improved linux compatibility
1 parent 15b840c commit d391f3f

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

gen/cdef.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11

22
import re
33
import sys
4-
from collections import OrderedDict
54

6-
defines = OrderedDict()
5+
defines = {}
76
cdefs = []
87

98
location_re = re.compile(r'^# \d+ "([^"]*)"')
@@ -63,7 +62,10 @@
6362
# Otherwise just include it in the cdef
6463
elif in_gl:
6564
# Windows likes to add __stdcall__ to everything, but it isn't needed and is actually harmful when using under linux.
66-
cdefs.append(line.replace(r'__attribute__((__stdcall__)) ', ''))
65+
line = line.replace('__attribute__((__stdcall__)) ', '')
66+
# While linux likes to add __attribute__((visibility("default")))
67+
line = line.replace('__attribute__((visibility("default"))) ', '')
68+
cdefs.append(line.replace('__attribute__((__stdcall__)) ', ''))
6769

6870
# Output the file
6971
print("--[[ BEGIN AUTOGENERATED SEGMENT ]]")
@@ -72,7 +74,7 @@
7274
print("\t", line, sep="")
7375
print("\t]]; glc = {")
7476

75-
for k in defines.keys():
77+
for k in sorted(defines.keys()):
7678
print("\t%s = %s," % ("['"+k+"']", defines[k]))
7779

7880
print("} end")

glfw_base.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ local gl, glu, glfw
1010
if ffi.os == "Windows" then
1111
gl = ffi.load("opengl32")
1212
glu = ffi.load("glu32")
13+
glfw = ffi.load("glfw3")
1314
else
1415
gl = ffi.load("GL")
1516
glu = ffi.load("GLU")
17+
glfw = ffi.load("glfw.so.3")
1618
end
17-
glfw = ffi.load("glfw3")
1819

1920
Lib.gl = gl
2021
Lib.glc = glc

readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Building
1010
--------
1111

1212
LuaJIT-GLFW builds bindings from the systems OpenGL and GLFW headers, as well as an included `glext.h` file.
13-
To build the bindings, you need to have `gcc` as well as headers for OpenGL and GLFW installed, though the resulting
13+
To build the bindings, you need to have `gcc`, headers for OpenGL and GLFW 3, and Python 3 installed, though the resulting
1414
file should be cross-platform compatible.
1515

1616
To build, just run `build.sh` in the repository directory. This will create a `glfw.lua` file, which is the only file
@@ -30,7 +30,7 @@ LuaJIT-GLFW loads the following libraries:
3030
* `glfw.gl`: OpenGL
3131
* `glfw.glu`: GLU
3232
* `glfw.glfw`: GLFW
33-
* `glfw.glext`: A table that, when indexed, loads the specified extension function.
33+
* `glfw.glext`: A table that, when indexed, loads and returns the specified extension function. Ex. `glext.glMyExtFuncARB(p1, p2)`
3434
* `glfw.glc`: `#define`d values for OpenGL and GLFW (this must be a Lua table instead of `static const` values, because OpenGL uses `longs` in a couple of places)
3535

36-
Additionally, LuaJIT-GLFW wraps GLFW functions and structs for convenience. See `glfw_base.lua`
36+
Additionally, LuaJIT-GLFW wraps GLFW functions and sets metatypes for GLFW structs for convenience. See `glfw_base.lua`

0 commit comments

Comments
 (0)