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

Fix bool return types #132

Merged
merged 4 commits into from
Jun 8, 2014
Merged

Fix bool return types #132

merged 4 commits into from
Jun 8, 2014

Conversation

thefiddler
Copy link
Contributor

System.Boolean is marshaled as a 4-byte int by default, but GLboolean is typedefed as a 1-byte unsigned char. Calli instructions do not appear to respect [return: MarshalAs(UnmanagedType.U1)], so we need to handle this ourselves by emitting byte instead of bool on the p/invoke signatures.

Fixes issue #129

GLboolean is typedefed as an unsigned char.  It appears that `[return:
MarshalAs(UnmanagedType.U1)]` is ignored in calli p/invokes, so we need
to take care of this ourselves by emitting byte instead of bool for the
p/invoke signature. The public API remains unchanged.

Fixes issue #129.
Since GL_TRUE and GL_FALSE match .Net true and false (1 and 0,
respectively), we can simply reinterpret the byte value as a bool.

In the future, we could issue a `(if value == 0 then false else true)`
statement for added safety, but this does not appear to be necessary
right now.
thefiddler added a commit that referenced this pull request Jun 8, 2014
@thefiddler thefiddler merged commit b9e9485 into opentk:develop Jun 8, 2014
@thefiddler thefiddler deleted the fixbool2 branch June 8, 2014 10:34
@thefiddler thefiddler added this to the 1.1.3 milestone Jun 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant