mirror of https://github.com/adamdruppe/arsd.git
gdc9 support
This commit is contained in:
parent
de576e37e1
commit
82728ad3f4
|
@ -14424,11 +14424,14 @@ static if(!SdpyIsUsingIVGLBinds) {
|
||||||
|
|
||||||
I would LOVE to overload it with the original glBufferData, but D won't
|
I would LOVE to overload it with the original glBufferData, but D won't
|
||||||
let me since glBufferData is a function pointer :(
|
let me since glBufferData is a function pointer :(
|
||||||
|
|
||||||
|
Added: August 25, 2020 (version 8.5)
|
||||||
+/
|
+/
|
||||||
void glBufferDataSlice(GLenum target, const(void[]) data, GLenum usage) {
|
void glBufferDataSlice(GLenum target, const(void[]) data, GLenum usage) {
|
||||||
glBufferData(target, data.length, data.ptr, usage);
|
glBufferData(target, data.length, data.ptr, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/++
|
/++
|
||||||
Convenience class for using opengl shaders.
|
Convenience class for using opengl shaders.
|
||||||
|
|
||||||
|
@ -14552,15 +14555,15 @@ final class OpenGlShader {
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
/// Assigns the 4 floats. You will probably have to call this via the .opAssign name
|
/// Assigns the 4 floats. You will probably have to call this via the .opAssign name
|
||||||
void opAssign(float x, float y, float z, float a) {
|
void opAssign(float x, float y, float z, float w) {
|
||||||
glUniform4f(id, x, y, z, a);
|
glUniform4f(id, x, y, z, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct UniformsHelper {
|
static struct UniformsHelper {
|
||||||
OpenGlShader _shader;
|
OpenGlShader _shader;
|
||||||
|
|
||||||
Uniform opDispatch(string name)() {
|
@property Uniform opDispatch(string name)() {
|
||||||
auto i = glGetUniformLocation(_shader.shaderProgram, name.ptr);
|
auto i = glGetUniformLocation(_shader.shaderProgram, name.ptr);
|
||||||
if(i == -1)
|
if(i == -1)
|
||||||
throw new Exception("Could not find uniform " ~ name);
|
throw new Exception("Could not find uniform " ~ name);
|
||||||
|
@ -14573,7 +14576,6 @@ final class OpenGlShader {
|
||||||
`OpenGlShader.Uniform = shader.uniforms.foo; // calls glGetUniformLocation(this, "foo");
|
`OpenGlShader.Uniform = shader.uniforms.foo; // calls glGetUniformLocation(this, "foo");
|
||||||
+/
|
+/
|
||||||
@property UniformsHelper uniforms() { return UniformsHelper(this); }
|
@property UniformsHelper uniforms() { return UniformsHelper(this); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
version(linux) {
|
version(linux) {
|
||||||
|
@ -15801,8 +15803,7 @@ __gshared bool librariesSuccessfullyLoaded = true;
|
||||||
__gshared bool openGlLibrariesSuccessfullyLoaded = true;
|
__gshared bool openGlLibrariesSuccessfullyLoaded = true;
|
||||||
|
|
||||||
private mixin template DynamicLoadSupplementalOpenGL(Iface) {
|
private mixin template DynamicLoadSupplementalOpenGL(Iface) {
|
||||||
static foreach(name; __traits(derivedMembers, Iface))
|
mixin(staticForeachReplacement!Iface);
|
||||||
mixin("__gshared typeof(&__traits(getMember, Iface, name)) " ~ name ~ ";");
|
|
||||||
|
|
||||||
void loadDynamicLibrary() @nogc {
|
void loadDynamicLibrary() @nogc {
|
||||||
(cast(void function() @nogc) &loadDynamicLibraryForReal)();
|
(cast(void function() @nogc) &loadDynamicLibraryForReal)();
|
||||||
|
@ -15817,9 +15818,38 @@ private mixin template DynamicLoadSupplementalOpenGL(Iface) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private mixin template DynamicLoad(Iface, string library, bool openGLRelated = false) {
|
private const(char)[] staticForeachReplacement(Iface)() pure {
|
||||||
|
/*
|
||||||
|
// just this for gdc 9....
|
||||||
|
// when i drop support for it and switch to gdc10, we can put this original back for a slight compile time ram decrease
|
||||||
|
|
||||||
static foreach(name; __traits(derivedMembers, Iface))
|
static foreach(name; __traits(derivedMembers, Iface))
|
||||||
mixin("__gshared typeof(&__traits(getMember, Iface, name)) " ~ name ~ ";");
|
mixin("__gshared typeof(&__traits(getMember, Iface, name)) " ~ name ~ ";");
|
||||||
|
*/
|
||||||
|
|
||||||
|
char[] code = new char[](__traits(derivedMembers, Iface).length * 64);
|
||||||
|
size_t pos;
|
||||||
|
|
||||||
|
void append(in char[] what) {
|
||||||
|
if(pos + what.length > code.length)
|
||||||
|
code.length = (code.length * 3) / 2;
|
||||||
|
code[pos .. pos + what.length] = what[];
|
||||||
|
pos += what.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(name; __traits(derivedMembers, Iface)) {
|
||||||
|
append(`__gshared typeof(&__traits(getMember, Iface, "`);
|
||||||
|
append(name);
|
||||||
|
append(`")) `);
|
||||||
|
append(name);
|
||||||
|
append(";");
|
||||||
|
}
|
||||||
|
|
||||||
|
return code[0 .. pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
private mixin template DynamicLoad(Iface, string library, bool openGLRelated = false) {
|
||||||
|
mixin(staticForeachReplacement!Iface);
|
||||||
|
|
||||||
private void* libHandle;
|
private void* libHandle;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue