DerelictGL3 glGenBuffers segmentation fault.
Mike Parker
aldacron at gmail.com
Sun Dec 24 05:23:12 UTC 2017
On Sunday, 24 December 2017 at 03:00:16 UTC, Kevin wrote:
> On Sunday, 24 December 2017 at 01:42:58 UTC, Mike Parker wrote:
I've found the problem. But first...
> I making a simple static library.
I don't see a static library anywhere. You weren't "importing a
static library", something which isn't possible in D anyway. You
import modules, not libraries.
The reason it worked in your main source file (cube.d) and not in
your buffers module is this line:
mixin glFreeFuncs!(GLVersion.gl33);
You have that in cube.d, but in buffers.d you have this:
import derelict.opengl;
If you are going to use glFreeFuncs like this, you can't import
opengl that way. As per the DerelictGL3 documentation [1], the
simplest way to make this work is to implement a module that
publicly imports derelict.opengl and declares the mixin, then
import that module elsewehre. So the first step to making your
code work is this:
```
module mygl;
public import derelict.opengl;
mixin glFreeFuncs!(GLVersion.GL33);
```
That's not all, though. The documentation also explicitly says
you have to define the DerelictGL3_CustomFreeFuncs version when
you compile. So add this to your dub.json:
```
"versions": [
"DerelictGL3_CustomFreeFuncs"
],
```
That should at least get you compiling. But your dependency
declarations have a couple of issues that need fixing. Currently,
you have this:
```
"derelict-sdl2": "~>3.0",
"derelict-gl3": "~2.0",
```
Your sdl2 dependency is syntactically correct, but what it says
is that you're happy with any version of DerelictSDL2 from 3.0.x
to 3.9.x, inclusive. The result is that you're actually getting
version 3.1.0-alpha.3. In the near future, I'll be updating for
SDL 2.0.7 and will add a new 3.2.0-alpha.1 version. If you run
`dub upgrade` at that point, you'll get that version. That's a
bad idea!
What you want to do is to specify the full version,
major.minor.path, 3.0.0. And, since there is a 3.0.0-beta and not
a 3.0.0, you'll need to append -beta.
The same applies to your gl3 dependency, but you have another
problem there. The syntax is incorrect: ~2.0 instead of ~>2.0.
~foo tells dub to look for a git branch with the name "foo" --
and it's deprecated syntax. Since there happens to be a branch in
the DerelictGL3 github repo named "2.0", that's what you're
actually getting.
So you should update your dependencies to look like this:
```
"derelict-sdl2": "~>3.0.0-beta",
"derelict-gl3": "~>2.0.0-beta",
```
Be sure to delete your dub.selections.json after editing and
before you rebuild.
With these, you'll be compiling and properly upgrading in the
future if you need to.
[1] http://derelictorg.github.io/packages/gl3/
More information about the Digitalmars-d-learn
mailing list