SapphireDensetsu / ypsilon

Automatically exported from code.google.com/p/ypsilon
Other
0 stars 0 forks source link

FFI additions #156

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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 commented 8 years ago
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