Correct GLX function pointer loading links
This commit is contained in:
@@ -33,7 +33,7 @@ If you use GNU Emacs, the above style can be configured via the following elisp:
|
|||||||
|
|
||||||
## Lua
|
## Lua
|
||||||
|
|
||||||
If you are contributing to `glava-config`, we use a style close to standard Lua with some emphasis on compat table definitions and readability
|
If you are contributing to `glava-config`, we use a style close to standard Lua with some emphasis on compact table definitions and readability
|
||||||
|
|
||||||
* If an opening brace has no tokens preceding it on the same line, take the first entry in the table and place it on the same line following the brace
|
* If an opening brace has no tokens preceding it on the same line, take the first entry in the table and place it on the same line following the brace
|
||||||
* If there are multiple closing braces, combine them onto the same line
|
* If there are multiple closing braces, combine them onto the same line
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ Note that versions since `2.0` use Meson for the build system, although the `Mak
|
|||||||
|
|
||||||
**Ubuntu/Debian users:** the following command ensures you have all the needed packages and headers to compile GLava with the default feature set:
|
**Ubuntu/Debian users:** the following command ensures you have all the needed packages and headers to compile GLava with the default feature set:
|
||||||
```bash
|
```bash
|
||||||
sudo apt-get install libpulse0 libpulse-dev libxext6 libxext-dev libxrender-dev libxcomposite-dev liblua5.3-dev liblua5.3 lua-lgi lua-filesystem libobs0 libobs-dev meson gcc
|
sudo apt-get install libpulse0 libpulse-dev libxext6 libxext-dev libxrender-dev libxcomposite-dev liblua5.3-dev liblua5.3 lua-lgi lua-filesystem libobs0 libobs-dev meson build-essential gcc
|
||||||
```
|
```
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|||||||
@@ -32,6 +32,13 @@ local function path_concat(...)
|
|||||||
return table.concat(ret, "/")
|
return table.concat(ret, "/")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Wrap table such that it can be called to index and call its members,
|
||||||
|
-- useful for switch-style syntax
|
||||||
|
local function switch(tbl)
|
||||||
|
local mt = { __call = function(self, i) return rawget(self, i)() end }
|
||||||
|
return setmetatable(tbl, mt)
|
||||||
|
end
|
||||||
|
|
||||||
-- To parse data from GLSL configs we use some complex pattern matching.
|
-- To parse data from GLSL configs we use some complex pattern matching.
|
||||||
--
|
--
|
||||||
-- Because Lua's patterns operate on a per-character basis and do not offer
|
-- Because Lua's patterns operate on a per-character basis and do not offer
|
||||||
@@ -41,6 +48,20 @@ end
|
|||||||
--
|
--
|
||||||
-- This effectively means we have some fairly powerful parsing which allows us
|
-- This effectively means we have some fairly powerful parsing which allows us
|
||||||
-- to handle things like quoted strings with escaped characters.
|
-- to handle things like quoted strings with escaped characters.
|
||||||
|
local function unquote(match)
|
||||||
|
local ret = {}
|
||||||
|
local escaped = false
|
||||||
|
for c in match:gmatch(".") do
|
||||||
|
if c == "\"" then
|
||||||
|
if escaped then ret[#ret + 1] = c end
|
||||||
|
elseif c ~= "\\" then ret[#ret + 1] = c end
|
||||||
|
if c == "\\" then
|
||||||
|
if escaped then ret[#ret + 1] = c end
|
||||||
|
escaped = not escaped
|
||||||
|
else escaped = false end
|
||||||
|
end
|
||||||
|
return table.concat(ret, "")
|
||||||
|
end
|
||||||
local function none(...) return ... end
|
local function none(...) return ... end
|
||||||
local MATCH_ENTRY_PATTERN = "^%s*%#(%a+)%s+(%a+)"
|
local MATCH_ENTRY_PATTERN = "^%s*%#(%a+)%s+(%a+)"
|
||||||
local MATCH_DATA_PREFIX = "^%s*%#%a+%s+%a+"
|
local MATCH_DATA_PREFIX = "^%s*%#%a+%s+%a+"
|
||||||
@@ -49,29 +70,25 @@ local MATCH_TYPES = {
|
|||||||
pattern = "(%d+.?%d*)",
|
pattern = "(%d+.?%d*)",
|
||||||
cast = tonumber,
|
cast = tonumber,
|
||||||
serialize = tostring
|
serialize = tostring
|
||||||
},
|
}, ["int"] = {
|
||||||
["int"] = {
|
|
||||||
pattern = "(%d+)",
|
pattern = "(%d+)",
|
||||||
cast = tonumber,
|
cast = tonumber,
|
||||||
serialize = function(x) tostring(math.floor(x)) end
|
serialize = function(x) tostring(math.floor(x)) end
|
||||||
},
|
}, ["color-expr"] = {
|
||||||
["string"] = {
|
pattern = "(.+)",
|
||||||
|
cast = none,
|
||||||
|
serialize = none
|
||||||
|
}, ["expr"] = {
|
||||||
|
pattern = "(.+)",
|
||||||
|
cast = none,
|
||||||
|
serialize = none
|
||||||
|
}, ["ident"] = {
|
||||||
|
pattern = "(%w+)",
|
||||||
|
cast = none,
|
||||||
|
serialize = none
|
||||||
|
}, ["string"] = {
|
||||||
pattern = "(.+)",
|
pattern = "(.+)",
|
||||||
-- Strip away string quotation and escape syntax
|
cast = unquote,
|
||||||
cast = function(match)
|
|
||||||
local ret = {}
|
|
||||||
local escaped = false
|
|
||||||
for c in match:gmatch(".") do
|
|
||||||
if c == "\"" then
|
|
||||||
if escaped then ret[#ret + 1] = c end
|
|
||||||
elseif c ~= "\\" then ret[#ret + 1] = c end
|
|
||||||
if c == "\\" then
|
|
||||||
if escaped then ret[#ret + 1] = c end
|
|
||||||
escaped = not escaped
|
|
||||||
else escaped = false end
|
|
||||||
end
|
|
||||||
return table.concat(ret, "")
|
|
||||||
end,
|
|
||||||
-- Read-ahead function to generate a fixed-width pattern
|
-- Read-ahead function to generate a fixed-width pattern
|
||||||
-- to match the next (possibly quoted) string
|
-- to match the next (possibly quoted) string
|
||||||
transform = function(match)
|
transform = function(match)
|
||||||
@@ -134,7 +151,8 @@ local MATCH_TYPES = {
|
|||||||
config.path_concat = path_concat
|
config.path_concat = path_concat
|
||||||
config.path_split = path_split
|
config.path_split = path_split
|
||||||
|
|
||||||
local function create_p(parts, mode, silent)
|
local function create_pf(arr, mode, silent)
|
||||||
|
local parts = {}
|
||||||
local function errfmt(err)
|
local function errfmt(err)
|
||||||
return string.format("Failed to create '%s' in '%s': %s",
|
return string.format("Failed to create '%s' in '%s': %s",
|
||||||
path_concat(parts, "/"), path_concat(arr, "/"), err)
|
path_concat(parts, "/"), path_concat(arr, "/"), err)
|
||||||
@@ -147,16 +165,17 @@ local function create_p(parts, mode, silent)
|
|||||||
local m = (i == #arr and mode or "directory")
|
local m = (i == #arr and mode or "directory")
|
||||||
local attr, err = lfs.attributes(path, "mode")
|
local attr, err = lfs.attributes(path, "mode")
|
||||||
if attr == nil then
|
if attr == nil then
|
||||||
({
|
local ret, err = switch {
|
||||||
file = function()
|
file = function()
|
||||||
local ret, err = lfs.touch(path)
|
local ret, err = lfs.touch(path)
|
||||||
if ret ~= true then return false, errfmt(err) end
|
if not ret then return false, errfmt(err) end
|
||||||
end,
|
end,
|
||||||
directory = function()
|
directory = function()
|
||||||
local ret, err = lfs.mkdir(path)
|
local ret, err = lfs.mkdir(path)
|
||||||
if ret ~= true then return false, errfmt(err) end
|
if not ret then return false, errfmt(err) end
|
||||||
end,
|
end,
|
||||||
})[m]()
|
}(m)
|
||||||
|
if ret == false then return ret, err end
|
||||||
elseif attr ~= m then
|
elseif attr ~= m then
|
||||||
if not (silent and #parts == #arr) then
|
if not (silent and #parts == #arr) then
|
||||||
return false, string.format("'%s' is not a %s", path, m)
|
return false, string.format("'%s' is not a %s", path, m)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ function main.entry(prog, ...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local mappings = require "glava-config.mappings"
|
local mappings = require "glava-config.mappings"
|
||||||
-- Associate `map_name = tbl` from mapping list for future lookups
|
-- Associate `map_name = tbl` from mapping list for future lookups, etc.
|
||||||
for k, v in pairs(mappings) do
|
for k, v in pairs(mappings) do
|
||||||
local i = 1
|
local i = 1
|
||||||
local adv = false
|
local adv = false
|
||||||
|
|||||||
@@ -222,6 +222,7 @@ return function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Generators for producing widgets (and their layouts) that bind to configuration values
|
-- Generators for producing widgets (and their layouts) that bind to configuration values
|
||||||
|
-- note: `get_data` returns _formatted_ data, such that it can be written directly in GLSL
|
||||||
local widget_generators
|
local widget_generators
|
||||||
widget_generators = {
|
widget_generators = {
|
||||||
-- A switch to represent a true/false value
|
-- A switch to represent a true/false value
|
||||||
@@ -286,7 +287,7 @@ return function()
|
|||||||
s.internal:get_style_context():add_provider(cssp, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
s.internal:get_style_context():add_provider(cssp, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
||||||
s.internal:get_style_context():add_class("fixed-width-font-entry")
|
s.internal:get_style_context():add_class("fixed-width-font-entry")
|
||||||
end
|
end
|
||||||
if not attrs.entries then
|
if not attrs.entries and not attrs._ignore_restrict then
|
||||||
-- Handle idenifier formatting for entries without a preset list
|
-- Handle idenifier formatting for entries without a preset list
|
||||||
function s.internal:on_changed()
|
function s.internal:on_changed()
|
||||||
local i = s.internal.text
|
local i = s.internal.text
|
||||||
@@ -298,6 +299,13 @@ return function()
|
|||||||
end
|
end
|
||||||
return s
|
return s
|
||||||
end,
|
end,
|
||||||
|
-- A full GLSL expression
|
||||||
|
["expr"] = function(attrs)
|
||||||
|
-- Expressions can be implemented by using the identity field and disabling
|
||||||
|
-- input format restrictions.
|
||||||
|
attrs._ignore_restrict = true
|
||||||
|
return widget_generators.ident(attrs)
|
||||||
|
end,
|
||||||
-- Adjustable and bound floating-point value
|
-- Adjustable and bound floating-point value
|
||||||
["float"] = function(attrs)
|
["float"] = function(attrs)
|
||||||
local widget = Gtk.SpinButton {
|
local widget = Gtk.SpinButton {
|
||||||
@@ -487,8 +495,7 @@ return function()
|
|||||||
upper = 1000,
|
upper = 1000,
|
||||||
lower = -1000,
|
lower = -1000,
|
||||||
header = "Scale:"
|
header = "Scale:"
|
||||||
}
|
} },
|
||||||
},
|
|
||||||
-- match against GLSL mix expression, ie.
|
-- match against GLSL mix expression, ie.
|
||||||
-- `mix(#3366b2, #a0a0b2, clamp(d / GRADIENT, 0, 1))`
|
-- `mix(#3366b2, #a0a0b2, clamp(d / GRADIENT, 0, 1))`
|
||||||
match = "mix%s*%(" ..
|
match = "mix%s*%(" ..
|
||||||
|
|||||||
@@ -186,6 +186,17 @@ static Atom ATOM__MOTIF_WM_HINTS, ATOM_WM_DELETE_WINDOW, ATOM_WM_PROTOCOLS, ATOM
|
|||||||
static GLXContext sharelist_ctx;
|
static GLXContext sharelist_ctx;
|
||||||
static bool sharelist_assigned = false;
|
static bool sharelist_assigned = false;
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
static const char *dl_names[] = {
|
||||||
|
"../Frameworks/OpenGL.framework/OpenGL",
|
||||||
|
"/Library/Frameworks/OpenGL.framework/OpenGL",
|
||||||
|
"/System/Library/Frameworks/OpenGL.framework/OpenGL",
|
||||||
|
"/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
static const char *dl_names[] = {"libGL.so.1", "libGL.so"};
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool offscreen(void) {
|
static bool offscreen(void) {
|
||||||
return sharelist_assigned;
|
return sharelist_assigned;
|
||||||
}
|
}
|
||||||
@@ -209,20 +220,18 @@ static void init(void) {
|
|||||||
maximized = false;
|
maximized = false;
|
||||||
transparent = false;
|
transparent = false;
|
||||||
|
|
||||||
void* hgl = dlopen("libGL.so.1", RTLD_LAZY);
|
void* hgl = NULL;
|
||||||
void* hglx = dlopen("libGLX.so.0", RTLD_LAZY);
|
for(size_t i = 0; i < (sizeof(dl_names) / sizeof(dl_names[0])) && hgl == NULL; ++i)
|
||||||
|
hgl = dlopen("libGL.so.1", RTLD_LAZY);
|
||||||
|
|
||||||
if (!hgl && !hglx) {
|
if (!hgl) {
|
||||||
fprintf(stderr, "Failed to load GLX functions (libGL and libGLX do not exist!)\n");
|
fprintf(stderr, "Failed to load GLX functions (libGL and libGLX do not exist!)\n");
|
||||||
glava_abort();
|
glava_abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Depending on the graphics driver, the GLX functions that we need may either be in libGL or
|
|
||||||
libGLX. */
|
|
||||||
void* resolve_f(const char* symbol) {
|
void* resolve_f(const char* symbol) {
|
||||||
void* s = NULL;
|
void* s = NULL;
|
||||||
if (hgl) s = dlsym(hgl, symbol);
|
if (hgl) s = dlsym(hgl, symbol);
|
||||||
if (!s && hglx) s = dlsym(hglx, symbol);
|
|
||||||
if (!s) {
|
if (!s) {
|
||||||
fprintf(stderr, "Failed to resolve GLX symbol: `%s`\n", symbol);
|
fprintf(stderr, "Failed to resolve GLX symbol: `%s`\n", symbol);
|
||||||
glava_abort();
|
glava_abort();
|
||||||
|
|||||||
Reference in New Issue
Block a user