This simple example initializes Direct3D9 and draws a static pink triangle in
the center of a black background. It shows how to create and use vertex buffers
and shaders. For compiling shaders for Direct3D it uses the
dxc library, which utilizes the DirectX
effects compiler DLL that comes with Windows. This lets you compile shaders on
the fly. You might also use the command line dxc tool to create your shaders
up front if you have so many of them that compiling on the fly makes your
program too slow.
For window creation this sample uses
the Windows API. Direct3D needs a handle to
the window it runs in so you need a method for setting this up. Other libraries
that you can use include SDL2,
Allen Dang's gform library and the
walk library.
If you simply build this sample with go build the resulting program will keep
a console window open while running. Use the build.bat to build instead, it
passes the flag -H=windowsgui to the linker which gets rid of the console
window.