google / dart-gl

OpenGL ES 2.0 Dart Native Extension
BSD 3-Clause "New" or "Revised" License
90 stars 17 forks source link

glGetIntegerv always returns one value, but the spec allows for multiple #8

Closed lyceel closed 7 years ago

lyceel commented 7 years ago

From @exavolt: """ I've found an implementation incompatibilities of glGet* functions. From the spec1, a glGet* function might returns one or more values which varies between parameters. For example, glGetIntegerv(GL_ACTIVE_TEXTURE) returns only one value, while something like glGetIntegerv(GL_VIEWPORT) would return four values. The binding always assume that the functions return only one value which, in many cases, it makes the functions practically useless because they returned only the first value.

I think that this could cause a more serious issue, i.e., buffer overrun, because the buffer provided to hold the returned values might be smaller than the number of value asked by the parameter.

The updated implementation should use a map of parameter names with their respective expected number of values as defined in the spec1. On call, the binding function will allocate the appropriately-sized buffer based on the parameter name before calling its respective actual glGet function.

"""

lyceel commented 7 years ago

Fixed glGet*v to return a List of the appropriate type.