Getting GtkD working with OpenGL

Mike Wey via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 3 11:00:53 PDT 2016


On 10/03/2016 01:50 PM, Chalix wrote:
> On Sunday, 18 September 2016 at 21:41:45 UTC, Mike Wey wrote:
>> The demo still uses the old GtkGLExt binding, which usually isn't
>> available in de distributions repositories.
>>
>> The newer GLArea is easier to use since it's part of GTK.
>>
>> As for the linker errors, you'll need to link with the OpenGL libraries:
>> "-L-lGL -L-lGLU"
>
> Hey, thanks for your fast answer! I had a lot of other work to do, so I
> could only continue working on this project now.
>
> Yeah, that solved my problem :) Now it links. Although if I execute the
> program, it complains about the missing GtkGLExt library, like expected...
> Library load failed: libgdkglext-3.0.so.0
>
> So I wanted to install this library from here:
> https://projects.gnome.org/gtkglext/download.html
> but the ./configure script tells me,
> No package 'pangox' found (pangox >= 1.0.0)
>
> I looked at the folder /usr/lib/x86_64-linux-gnu/ and there is a file
> called "libpangox-1.0.so.0.0.0". So I don't know, why this is not
> working...

You will need the Gtk3 port of gtkglext: https://github.com/tdz/gtkglext
Last time i tried compiling it i needed to remove the documentation 
generation from the make files.

> Anyway, I want to follow Mikes advice and use GLArea instead, so if
> there is not a quick fix available, lets skip the problems with the
> GtkGLExt library...
>
>
>
> But, sadly enough, I did not get GLArea working, too. The documentation
> https://developer.gnome.org/gtk3/stable/GtkGLArea.html
> says, I have to connect my render function to the widget like this:
> g_signal_connect (gl_area, "render", G_CALLBACK (render), NULL);
> But, my compiler can't find the g_signal_connect method (and the GL
> Methods...):
> main.d(22): Error: undefined identifier 'g_signal_connect'
> main.d(39): Error: undefined identifier 'glClearColor'
> main.d(40): Error: undefined identifier 'glClear'
>
> There might some include files (or import files, as you say in D)
> missing, but I could not figure out, where to find them for D...
>
> Could you tell me, where this g_signal_connect method can be found? And
> what I have to include for the GL functionality? Simply "import
> gtk.GLArea;" does not do the trick...

The signal functions can be found in the gobject.Signals module.

But you should use the GLArea.addOnCreateContext / addOnRender / 
addOnResize functions to attach a D delegate to the signal.
You will still need to link with the OpenGL libraries or use someting 
like Derelict.

> Btw, is g_signal_connect a GTK method? I intend to use my program
> platform independent, so if this is dependent on gnome, it would not be
> good.

It's a GLib/GObject method, it's available on any platform GTK runs on.

> Or is there any other way to get the GLArea working? I am used to the Qt
> Libraries, where you create a QGLWidget and simply override the init and
> render functions.
>
>
> Thanks for reading this far, would be great if we could solve this
> problem :D


-- 
Mike Wey


More information about the Digitalmars-d-learn mailing list