Passing a string buffer to a C function
Hi all, I'm trying to do some GLSL shaders with MacRuby. However, I'm a bit stumped as to how to call glGetShaderInfoLog if the shader compilation fails. The C function's prototype is: void glGetShaderInfoLog(GLuint shader, GLsizei maxLength, GLsizei * length, GLchar * infoLog); I couldn't find any docs on how Pointer.new_with_type, so I tried a few things, such as: log_info = Pointer.new_with_type('c', 4096) length = Pointer.new_with_type('i') glGetShaderInfoLog(@shader_id, 4096, length, log_info) However, I get the error: TypeError: can't convert Pointer into String It seems that the bridge wants log_info to be a String object. But, using a String causes a bus error. I'm expecting that the bridge isn't expecting the string to be mutated. Any suggestions would be appreciated! /\/\ike
Hi Mike, Thanks for the report. I think this is because GLchar* is typed in the runtime as a C-style string. The compiler should allow Pointer objects for this runtime type. Currently, it only allows nil, symbols and strings. Could you file a bug? We will track this... Thanks, Laurent On May 5, 2010, at 10:43 AM, Mike Taylor wrote:
Hi all,
I'm trying to do some GLSL shaders with MacRuby. However, I'm a bit stumped as to how to call glGetShaderInfoLog if the shader compilation fails. The C function's prototype is:
void glGetShaderInfoLog(GLuint shader, GLsizei maxLength, GLsizei * length, GLchar * infoLog);
I couldn't find any docs on how Pointer.new_with_type, so I tried a few things, such as:
log_info = Pointer.new_with_type('c', 4096) length = Pointer.new_with_type('i')
glGetShaderInfoLog(@shader_id, 4096, length, log_info)
However, I get the error:
TypeError: can't convert Pointer into String
It seems that the bridge wants log_info to be a String object. But, using a String causes a bus error. I'm expecting that the bridge isn't expecting the string to be mutated.
Any suggestions would be appreciated!
/\/\ike
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (2)
-
Laurent Sansonetti
-
Mike Taylor