mirror of https://github.com/adamdruppe/arsd.git
Add support for BindBC bindings
Add support for dynamic OpenGL and static FreeType bindings from BindBC. Fontconfig bindings aren't provided yet, so the inbuilt ones are still used. Add tip to inform users about binding options.
This commit is contained in:
parent
3df61e91ff
commit
ff4349777f
53
nanovega.d
53
nanovega.d
|
@ -142,6 +142,11 @@ $(SIDE_BY_SIDE
|
|||
)
|
||||
)
|
||||
|
||||
$(TIP
|
||||
This library can use either inbuilt or BindBC (external dependency) provided bindings for OpenGL and FreeType.
|
||||
Former are used by default, latter can be activated by passing the `bindbc` version specifier to the compiler.
|
||||
)
|
||||
|
||||
$(TIP
|
||||
If you are going to use the library with a SDL OpenGL context,
|
||||
try working with a backwards compatible context profile.
|
||||
|
@ -524,7 +529,19 @@ version(Posix) {
|
|||
} else {
|
||||
version = nanovg_disable_fontconfig;
|
||||
}
|
||||
version(aliced) {
|
||||
|
||||
version (bindbc) {
|
||||
version = nanovg_builtin_fontconfig_bindings;
|
||||
version = nanovg_bindbc_opengl_bindings;
|
||||
version = nanovg_bindbc_freetype_bindings;
|
||||
version(BindFT_Dynamic)
|
||||
static assert(0, "AsumFace was too lazy to write the code for the dynamic bindbc freetype bindings");
|
||||
else {
|
||||
version(BindFT_Static) {}
|
||||
else
|
||||
static assert(0, "well, duh. you got to pass the BindFT_Static version identifier to the compiler");
|
||||
}
|
||||
} else version(aliced) {
|
||||
version = nanovg_default_no_font_aa;
|
||||
version = nanovg_builtin_fontconfig_bindings;
|
||||
version = nanovg_builtin_freetype_bindings;
|
||||
|
@ -9713,6 +9730,11 @@ FT_Error FT_Get_Kerning (FT_Face, FT_UInt, FT_UInt, FT_UInt, FT_Vector*);
|
|||
void FT_Outline_Get_CBox (const(FT_Outline)*, FT_BBox*);
|
||||
FT_Error FT_Outline_Decompose (FT_Outline*, const(FT_Outline_Funcs)*, void*);
|
||||
}
|
||||
} else version(bindbc) {
|
||||
import bindbc.freetype;
|
||||
alias FT_KERNING_DEFAULT = FT_Kerning_Mode.FT_KERNING_DEFAULT;
|
||||
alias FT_KERNING_UNFITTED = FT_Kerning_Mode.FT_KERNING_UNFITTED;
|
||||
alias FT_KERNING_UNSCALED = FT_Kerning_Mode.FT_KERNING_UNSCALED;
|
||||
} else {
|
||||
import iv.freetype;
|
||||
}
|
||||
|
@ -12145,14 +12167,35 @@ static if (__VERSION__ < 2076) {
|
|||
|
||||
|
||||
//import arsd.simpledisplay;
|
||||
version(nanovg_builtin_opengl_bindings) { import arsd.simpledisplay; } else { import iv.glbinds; }
|
||||
version(nanovg_bindbc_opengl_bindings) {
|
||||
import bindbc.opengl;
|
||||
} else version(nanovg_builtin_opengl_bindings) {
|
||||
import arsd.simpledisplay;
|
||||
} else {
|
||||
import iv.glbinds;
|
||||
}
|
||||
|
||||
private:
|
||||
// sdpy is missing that yet
|
||||
static if (!is(typeof(GL_STENCIL_BUFFER_BIT))) enum uint GL_STENCIL_BUFFER_BIT = 0x00000400;
|
||||
|
||||
|
||||
// OpenGL API missing from simpledisplay
|
||||
|
||||
version(bindbc){
|
||||
private extern(System) nothrow @nogc:
|
||||
// this definition doesn't exist in regular OpenGL (?)
|
||||
enum uint GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9U;
|
||||
private void nanovgInitOpenGL () {
|
||||
// i'm not aware of calling the load multiple times having negative side effects, so i don't do an initialization check
|
||||
GLSupport support = loadOpenGL();
|
||||
if (support == GLSupport.noLibrary)
|
||||
assert(0, "OpenGL initialization failed: shared library failed to load");
|
||||
else if (support == GLSupport.badLibrary)
|
||||
assert(0, "OpenGL initialization failed: a context-independent symbol failed to load");
|
||||
else if (support == GLSupport.noContext)
|
||||
assert(0, "OpenGL initialization failed: a context needs to be created prior to initialization");
|
||||
}
|
||||
} else { // OpenGL API missing from simpledisplay
|
||||
private extern(System) nothrow @nogc {
|
||||
alias GLvoid = void;
|
||||
alias GLboolean = ubyte;
|
||||
|
@ -12445,10 +12488,11 @@ private extern(System) nothrow @nogc {
|
|||
|
||||
glGetIntegerv_NVGLZ = cast(glbfn_glGetIntegerv)glbindGetProcAddress(`glGetIntegerv`);
|
||||
if (glGetIntegerv_NVGLZ is null) assert(0, `OpenGL function 'glGetIntegerv' not found!`);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Context creation flags.
|
||||
|
@ -14538,6 +14582,7 @@ public NVGContext nvgCreateContext (const(NVGContextFlag)[] flagList...) nothrow
|
|||
NVGparams params = void;
|
||||
NVGContext ctx = null;
|
||||
version(nanovg_builtin_opengl_bindings) nanovgInitOpenGL(); // why not?
|
||||
version(nanovg_bindbc_opengl_bindings) nanovgInitOpenGL();
|
||||
GLNVGcontext* gl = cast(GLNVGcontext*)malloc(GLNVGcontext.sizeof);
|
||||
if (gl is null) goto error;
|
||||
memset(gl, 0, GLNVGcontext.sizeof);
|
||||
|
|
Loading…
Reference in New Issue