the Fiddler's picture

OpenTK.Math.Half

Project:The Open Toolkit library
Component:Code
Category:feature request
Priority:normal
Assigned:Inertia
Status:closed
Description

This type should provide an interface similar to IntPtr, with a methods, conversion operators and constructors that can pack/unpack floats and doubles.

I'm opening this task so we can keep track of progress.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Inertia's picture

#62

[license]
Well, citing non-lawyer answers in a court of law isn't going to help. Let's leave it as is for now, we're certainly on the safe side with the current state.

[v9]

  • Added Half2 and Half3, tested and works.
  • Removed a check for 0.0f in the Half constructors and FromSingle() methods (was unnecessary)
  • Removed pack/size from Structlayout, to be on the safe side.
  • General cleanup of docu, no more C++ references.
  • Changed -0.0f to 0x8000 and removed check in Half.IsNaN property for it.
  • Changed all (float) into (Single) in public methods/docu, because it's more explicit.

I'm really out of ideas now what should be added, and no known issues left.

AttachmentSize
OpenTK Half v9.rar17.03 KB
Inertia's picture

#63

Title:Add half type to OpenTK.Math» OpenTK.Math.Half
Status:open» in progress (review)
the Fiddler's picture

#64

I have committed the code with slight modifications and updated the license to display the OpenEXR terms (at least until we get an answer from OpenEXR).

Changes:

  • Vector[234]h instead of Half[234], to match Vector[234]d.
  • Renamed _internalBits to bits and made the field private.
  • Refactored the From/ToBinaryStream methods of Vector[234]h to use Half.From/ToBinaryStream.
  • Made Half -> Double / Single conversions implicit (like Single -> Double is implicit).
  • Trimmed down the API.

As part of this work, I've completely rewritten the double structs (Vector[234]d, Matrix4d and Quaterniond) so that they match their single counterparts. There is still some work left to normalize all APIs (they are missing the binary read / write methods of Half), but that can wait a little.

What's left now is the GL <-> Half interop (which I'll add shortly). It would also be great to add unit tests to the math library, but that's a whole other discussion.

objarni's picture

#65

What unit test tool does OpenTK use?

the Fiddler's picture

#66

the Fiddler's picture

#67

Status:in progress (review)» fixed
the Fiddler's picture

#68

Status:fixed» closed

Closing issues fixed in 0.9.2.

the Fiddler's picture

#69

Version:0.9.x-dev»