Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFI additions #156

Open
GoogleCodeExporter opened this issue Aug 19, 2015 · 1 comment
Open

FFI additions #156

GoogleCodeExporter opened this issue Aug 19, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

Hello Fujita

I've been trying to use ypsilon for GLSL shader implementation, but I'm having 
a little trouble with some of the GL calls.  It may be that I've missed 
something, of course.

My issue is this:  glShaderSource as follows:

;; void glShaderSource(GLuint shader, GLsizei count, const GLchar ** string, 
const GLint * length);
(define-function void glShaderSource (int int void* void*))

and, having successfully created a shader object, try to attach my source to 
it.  The problem is that glShaderSource wants an array of c strings as its 
third parameter, and I can't seem to make one. What I really want to do is 
something like this:

        (let* ([shader-source     (make-c-string source-string)]
               [shader-source-ptr (make-c-void* shader-source)]
               [shader-length     (bytevector-length shader-source)]
               [shader-lengths    (make-c-int 1)])
          (glShaderSource my-shader 1 shader-source-ptr shader-lengths)

Or, even better, given that I don't need my strings to be null-terminated 

        (let* ([shader-source     (make-bytevector-mapping source-string)]
               [shader-source-ptr (make-c-void* shader-source)]
               [shader-length     (string-length source-string)]
               [shader-lengths    (make-c-int shader-length)])                                                                         
          (glShaderSource my-shader 1 shader-source-ptr shader-lengths)

The problem, in both cases, is the second assignment in the let*, or "how do I 
put the address of one bytevector or bytevector mapping into another bytevector 
or bytevector mapping".  I can't see a way of doing this with the current API.

Regards

Simon

Original issue reported on code.google.com by simon.st...@gmail.com on 29 May 2013 at 6:38

@GoogleCodeExporter
Copy link
Author

Dammit, my browser appears to have eaten part of that.

"glShaderSource as follows:" should read "I have wrapped glShaderSource as 
follows:"

Original comment by simon.st...@gmail.com on 29 May 2013 at 6:39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant