OpenGL in D2

Nrgyzer nrgyzer at gmail.com
Mon Feb 21 02:50:14 PST 2011


== Auszug aus Siqu (user at example.net)'s Artikel
> Hi,
> I'm trying to figure out how I could get a simple OpenGL/GLUT
program working
> in DMD2. As an attachment, I've added a C version of what I'd like
to do. I'd
> compile the C version using:
> gcc simple.c -lglut -lGLU -o simple
> I've found a few OpenGL projects, like bindings
> (http://www.dsource.org/projects/bindings/) and derelict
> (http://www.dsource.org/projects/derelict/), but I still can't find
any way to
> easily use or install them (for D2 on Ubuntu). I'd have thought
that, since D
> interfaces so well with C, just using C libraries wouldn't require
specific
> wrapper libraries, but it seems an automated method for converting
C headers
> to D isn't currently possible?
> Anyway, any help would be appreciated,
> Thanks.
>  << simple.c >>

I'm using derelict, primary on windows, but I've also a running
version on Ubuntu.
You can download derelict at http://www.dsource.org/projects/derelict/
changeset/525/branches/Derelict2?old_path=%2F&format=zip

I think you've already a running version of the dmd-compiler? If yes,
you can simply extract the package, open your shell browse to the
extracted folder and run "make -flinux.mak DC=dmd" which worked for
me on windows and linux (make sure you've installed make and dmd is
in your environment-values). On windows you've to create a folder
called "lib" before you run the command above - I currently can't say
it exactly if it's needed on linux, too.
After it compiled, you can copy all the created lib-files to the lib-
folder (I think this should be /usr/lib or something like this - run
"find / -name 'phobos.lib'" and copy the lib-files to the same
directory where phobos.lib is located. Copy the content of the
"import"-dir to a location where you've all your binding for D, so
that you can simply use "import derelict.sdl.sdl" or similar.

When you've installed it correctly, you can use derelict/opengl like
described on the derelict site. Note that you have to use 'pragma
(lib, "DerelictSDL")' or similar to use the binding. It is also
important the you insert 'pragma(lib, "dl")' in you source that you
can compile it successfully.

I hope this helped :)


More information about the Digitalmars-d-learn mailing list