title: How can I create a pointer to existing data using the LuaJIT FFI?
body: <p>I know there are examples of creating pointers using the LuaJIT FFI, but most of these aren't pointed to existing data. One such example of this is here:
  <a href="https://stackoverflow.com/questions/14011598/how-to-pass-a-pointer-to-luajit-ffi-to-be-used-as-out-argument">How to pass a pointer to LuaJIT ffi to be used as out argument?</a></p>
  
  <p>One thing that I haven't been able to successfully do is create a pointer to an existing value. In order to have a pointer type as far as I know, I have to know that I want to have a pointer point to it at some point in the future, as in:</p>
  
  <pre><code>local vao = ffi.new("GLuint[1]")
  gl.GenVertexArrays(1, vao)
  gl.BindVertexArray(vao[0])
  </code></pre>
  
  <p>Here, I know that glGenVertexArrays needs a pointer to <code>vao</code>, so I specify it as a GLuint[1]. In C, I would be doing something like the following:</p>
  
  <pre><code>GLuint vao;
  glGenVertexArrays(1, &amp;vao);
  glBindVertexArray(vao);
  </code></pre>
  
  <p>Here, I have no idea that I'll be needing a pointer to <code>vao</code>, so I can just specify it normally.</p>
  
  <p>In other words, is there a way to get the address of, or create a pointer to, an existing value? Do I have to foresee what I'll be doing with the value before I create it?</p>
  
  <p>Thanks!</p>