Right now I'm trying to do a very tiny OpenGL in nim. I'm at the stage where I 
need to bind my buffer data. The compiler is giving me this error:
    
    
    Error: expression has no address
    

Here is the C code I'm trying to port: 
    
    
    float points = [
      0.0, 0.5, 0.0,
      0.5, -0.5, 0.0,
      -0.5, -0.5, 0.0
    ];
    
    // ...
    
    GLuint vbo = 0;
    glGenBuffers(1, &vbo);
    glBindBuffer(GL_ARRAY_BUFFER, vbo);
    glBufferData(GL_ARRAY_BUFFER, 9 * sizeof(float), points, GL_STATIC_DRAW);
    

And here is my nim code right now: 
    
    
    let
      points = [
        0.0, 0.5, 0.0,
        0.5, -0.5, 0.0,
        -0.5, -0.5, 0.0
      ]
      numVertexBuffers = GlSizei(1)
      pointsBufferSize = GlSizeiptr(sizeof(points))
    
    # ...
    
    var
      vbo: GlUint
    
    glGenBuffers(numVertexBuffers, vbo.addr)
    glBindBuffer(GL_ARRAY_BUFFER, vbo)
    glBufferData(GL_ARRAY_BUFFER, pointsBufferSize, points.addr, 
GL_STATIC_DRAW)  # It errors here on `points.addr`
    
    

Here is the definition for the glBufferData() proc: 
[https://github.com/nimious/gles/blob/master/src/gles2/gl2.nim#L494](https://github.com/nimious/gles/blob/master/src/gles2/gl2.nim#L494)
 I have no idea what's wrong here.

Reply via email to