AST macros to generate OpenGL boilerplatie

Hey people, I am currently working on a macro library that I would like to advertise a bit here, when I am allowed to (I hope so, when not pleas let me know). Generally speaking it is a library that tries to be as thin around OpenGL as possible, but in areas, where writing raw OpenGL would be tedious and error prone. Everything that can be determined from the environment should be generated, and the programmer should not be bothered with details like uniform locations, or compiling and linking together shader source files. I realized that I would not be able to do this in c++, so I have chosen another language that is more powerful in terms of AST based macros, but without giving of the static typing or the control of the memory layout. It would be great if I could get some feedback from people who actually do OpenGL programming. It is of course far from being complete, but it is ready to be played around with and receive some feedback.

The idea is to make everything much more locale to where it is needed, and overall make the programmer much more productive. Here is an example of the Hello triangle, and I could get it down to just a few lines. Of course it does not show all the capabilities of my library, but it is a starting point:



import ../fancygl

let (window, context) = defaultSetup()

let vertices = arrayBuffer([vec4f(-1,-1,0,1), vec4f(1,-1,0,1), vec4f(0,1,0,1)])
let colors   = arrayBuffer([vec4f( 1, 0,0,1), vec4f(0, 1,0,1), vec4f(0,0,1,1)])

var evt: Event = defaultEvent
var runGame: bool = true

while runGame:
  while pollEvent(evt):
    if evt.kind == QuitEvent:
      runGame = false
      break
    if evt.kind == KeyDown and evt.key.keysym.scancode == SDL_SCANCODE_ESCAPE:
      runGame = false

  shadingDsl:
    primitiveMode = GL_TRIANGLES
    numVertices = 3
    attributes:
      a_vertex = vertices
      a_color  = colors
    vertexMain:
      """
      gl_Position = a_vertex;
      v_color = a_color;
      """
    vertexOut:
      "out vec4 v_color"
    fragmentMain:
      """
      color = v_color;
      """
glSwapWindow(window)

My project is on here on github with more examples.

I would like to read some comments about it, positive as well as negative. I am also very interested in doubts about where this idea to wrap OpenGL might fail. Som fancy graphics effects that could net be implemented with a system like this.