-
Notifications
You must be signed in to change notification settings - Fork 627
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
Splitting Platform/Windows/API.cs into OpenTK.NT #765
Conversation
What is end purpose of this? |
Moving all the P/Invoke code into its own library.. |
Remove unused leftover functions
- Renamed structs to be inline with WinApi docs - Used WinApi typedefs whereever(?) possible (might have missed some) - renamed Enums to be more consistent (uppercase if part of a struct, if only used with a function, '<FunctionName><Usage>' in PascalCase instead) - added docs from WinApi docs for a lot of enums
The files directly in the EDIT: I still need to clean up the remaining code in API.cs, I'd love to get rid of it completely. Everything in the class "Constants" should be moved to enums or flags. The non-WinApi structs should be moved to OpenTK.Core->Platform->Windows. |
I went with the following:
There's still the things from my last "todo" post (testing some structs) plus a very small amount of missing XML doc (<25 stylecop errors), but this is mostly done now. |
Absolutely fantastic. Looking forward to merging this. |
to lparam and wparam
1557f32
to
159da04
Compare
src/OpenTK.GLControl/WinGLControl.cs
Outdated
@@ -51,53 +49,8 @@ public IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags | |||
return new GraphicsContext(mode, WindowInfo, major, minor, flags); | |||
} | |||
|
|||
public bool IsIdle => !PeekMessage(ref msg, IntPtr.Zero, 0, 0, 0); | |||
public bool IsIdle => !User32.Message.PeekMessage(out message, IntPtr.Zero, 0, 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that message are allocated in managed code before call? Last time got issue by passing huge struct with out
mod(it was nested and with arrays) and it genereated runtime exceptions, always with random time after call while trying to Marshal struct, changes to ref with preallocation before call fixed issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since message
is a field, it will always be initialized before we access it.
This means that
private Msg message;
is (at least for normal usage) equivalent to
private Msg message = default(Msg);
So yes, I'm pretty sure that the message is allocated before the unmanaged function call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok : )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if someone make call:
Msg msg;
PeekMessage(out msg);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msg
will be initialized to its default value. Even then, with an out, you don't strictly need to initialize anything since out guarantees initialization. Might want to brush up on that.
Looks like it's just about time to merge this. All set, @FreezyLemon? |
THIS IS HEAVILY WIP!
Todo
OpenTK.NT.Native
, and not e.g.OpenTK.NT.Native.User32.Structs
)HWND
instead ofIntPtr
)