glGetShaderSource StringBuilder argument

Project:Tao.OpenGl
Component:Code
Category:bug
Priority:normal
Assigned:Unassigned
Status:Active
Description

In the 2.1.0 framework version, the last argument of the glGetShaderSource was changed from StringBuilder to StringBuilder[]. While it is possible to pass an array consisting of a single StringBuilder to the function, the results are always null.
I'm assuming it's a typo in the source for the code generator. The prototypes of all other functions taking a StringBuilder remained unchanged.

Old prototype:
public static void glGetShaderSource(int shader, int bufSize, out int length, StringBuilder source);

New prototype:

public static void glGetShaderSource(int shader, int bufSize, out int length, StringBuilder[] source);

The meaning of bufSize in 2.1.0 was changed to mean the size of the StringBuilder[] array, not the maximum character capacity.

This is how it worked before:

int length;
var sb = new StringBuilder( 8192 );
Gl.glGetShaderSource( shader.Handle, sb.Capacity, out length, sb );
// sb contains shader source, length is correct

This is how I tried to use it in 2.1.0, without success:

int length;
var sb = new StringBuilder( 8192 );
var x = new StringBuilder[] { sb };
Gl.glGetShaderSource( shader.Handle, 1, out length, x );
// sb is empty, length is zero
// notice the 'capacity' parameter had to be changed to 1 to prevent the call from crashing

It's not really that important of a function, I only noticed this because it broke some of my code, so don't lose any sleep over it. And again, thanks for all your nice work.

Gregor.

Thanks for the report. This

Thanks for the report.

This looks like a bug in the generator, although a rather strange one. GetShaderInfoLog, which has the same signature as GetShaderSource, is somehow translated correctly.

From the specs:

GetShaderSource(shader, bufSize, length, source)
return void
param shader UInt32 in value
param bufSize SizeI in value
param length SizeI out array [1]
param source Char out array [length]

GetShaderInfoLog(shader, bufSize, length, infoLog)
return void
param shader UInt32 in value
param bufSize SizeI in value
param length SizeI out array [1]
param infoLog Char out array [length]

"Char array" is mapped to string and the "out" flow direction modifies string to StringBuilder. I'm not sure where the StringBuilder[] comes from, but I'm investigating the problem.

Just a thought: maybe one of

Just a thought: maybe one of the parameter names ('source' for example) is a reserved keyword in the generator. That could be confusing it.

Gregor.

Theme by La Boite a site | Powered by Drupal