♻️ Add base classes for the effects and shaders
This commit is contained in:
+1
-26
@@ -13,8 +13,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const {Gtk, Gio} = imports.gi;
|
||||
const ByteArray = imports.byteArray;
|
||||
const {Gtk} = imports.gi;
|
||||
|
||||
// Returns the given argument, except for "alpha", "beta", and "rc". In these cases -3,
|
||||
// -2, and -1 are returned respectively.
|
||||
@@ -90,28 +89,4 @@ function shellVersionIsAtLeast(major, minor) {
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// This loads the file at 'path' contained in the extension's resources to a JavaScript
|
||||
// string.
|
||||
function loadStringResource(path) {
|
||||
const data = Gio.resources_lookup_data(path, 0);
|
||||
return ByteArray.toString(ByteArray.fromGBytes(data));
|
||||
}
|
||||
|
||||
// This loads a GLSL file from the extension's resources to a JavaScript string. Any
|
||||
// #include statements in this file are replaced with the corresponding file contents.
|
||||
function loadGLSLResource(path) {
|
||||
let code = loadStringResource(path);
|
||||
|
||||
// This regex matches either #include "..." or #include <...>. The part between the
|
||||
// brackets is captured in the capture group.
|
||||
const regex = RegExp('#include ["<](.+)[">]', 'g');
|
||||
|
||||
code = code.replace(regex, (m, file) => {
|
||||
return loadStringResource('/shaders/' + file);
|
||||
});
|
||||
|
||||
// Add a trailing newline. Else the GLSL compiler complains...
|
||||
return code + '\n';
|
||||
}
|
||||
Reference in New Issue
Block a user