lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Mike,

I think the problem is that "x" and "y" are nil, not that color is of
the wrong type.

If you can just change this line

            gl.glReadPixels(x, y, 1, 1, gl.GL_RGB, gl.GL_INT, color)
to
            gl.glReadPixels(10, 10, 1, 1, gl.GL_RGB, gl.GL_INT, color)

and test it, you should see that it's gonna work.

Thanks,
Dimiter "malkia" Stanev

On Fri, Feb 18, 2011 at 7:54 PM, Michael Gogins
<michael.gogins@gmail.com> wrote:
>            local color_t = ffi.typeof('int[4]')
>            print('color_t:', color_t, ffi.sizeof(color_t))
>            local color = color_t()
>            -- void glReadPixels (GLint x, GLint y, GLsizei width,
> GLsizei height, GLenum format, GLenum type, GLvoid * pixels);
>            gl.glReadPixels(x, y, 1, 1, gl.GL_RGB, gl.GL_INT, color)
>            -- gl.glReadPixels(x, y, 1, 1, gl.GL_RGB, gl.GL_INT,
> ffi.cast('void *', color))
>
> Whichever of the two forms of glReadPixels I call above, I get the
> same runtime error (Ubuntu 10.04):
>
> Z:\home\mkg\Downloads\malkia-luajit-opencl-e559146\luajit:
> ../../scripts/ChordSpaceView.lua:488: cannot convert 'void *' to 'int'
>
> It it possible to do this -- allow the C function to copy data into an
> address pointed to by a void pointer, then type cast the copied data
> back to an array of elementary types?
>
> All the other OpenGL functions I use in this program work fine.
>
> Regards,
> Mike Gogins
>
>



-- 
Dimiter "malkia" Stanev,
ICQ: 21875894
malkia@mac.com
malkia@gmail.com