Direct2D programming

720 views
Skip to first unread message

Alice

unread,
Jun 22, 2011, 11:19:44 AM6/22/11
to golang-nuts
What is the easiest way to do Direct2D programming with Go?

Any short example would be appreciated.

Jeroen Dirks

unread,
Jun 22, 2011, 11:34:00 AM6/22/11
to golang-nuts
I think that Direct2D is a C++ API. (I think it is possible to do raw
Direct2D coding in C only but that is very painful.)

So it is not directly usable from Go.

Your best bet is to use SWIG to make a Go wrapper of the C++ API and
then use your Go API to do Direct2D programming.

(Unless someone already made a Go wrapper for Direct2D/DirectX then
use their Go API)

Ethan

unread,
Dec 9, 2011, 11:13:31 PM12/9/11
to golan...@googlegroups.com
Hmm, correct me if I'm wrong, although DirectX API is C++, it exports all the functionality through a C interface, which Go can talk with directly.

Krzysztof Kowalczyk

unread,
Dec 10, 2011, 3:11:51 AM12/10/11
to golan...@googlegroups.com
Yes, DirectX is COM which is C++ but with a stable ABI (layout of
virtual table, calling conventions) and therefore can be called from
plain C (http://www.codeproject.com/KB/COM/com_in_c1.aspx) therefore
one should be able to write a wrapper in Go like for any other C code.

But as Jeroen said, it's painful.

-- kjk

lars....@googlemail.com

unread,
Apr 30, 2016, 11:28:24 PM4/30/16
to golang-nuts, doff...@gmail.com
I have created a Go wrapper for Direct3D9 with which you can also render 2D graphics: https://github.com/gonutz/d3d9

My entry to the GopherGala 2016 was a simple 2D game utilizing this wrapper: https://github.com/gonutz/gophette

Also the "samples" folder in the d3d9 wrapper gives you some basic starting points on how to use D3D9 in Go.
Reply all
Reply to author
Forward
0 new messages