Commit graph

5579 commits

Author SHA1 Message Date
thefiddler 346921981d [Build] Added -debug to Rewrite commandline parameters 2014-02-25 01:08:53 +01:00
thefiddler 18ef634610 [Build] Fixed ErrorHelper local variable
We need to emit a ldloca instruction before constructing the
ErrorHelper instance, in order to reference it in the finally
block below.
2014-02-25 01:08:53 +01:00
thefiddler 2f3e7a9493 [Rewrite] Fixed exit from try-finally block 2014-02-25 01:08:53 +01:00
Fraser 10ca14ac6d Add ErrorHelper to bindings.
Wrap new generated binding calls with using ErrorHelper. Sets up a try
to call the method in and a finally block to call Dispose on the
ErrorHelper. Currently hardcoded to only work for the graphics modules.
2014-02-25 01:08:53 +01:00
thefiddler 925abfdb10 [EGL] Removed unnecessary OpenTK.Platform.Windows reference 2014-02-21 14:04:33 +01:00
thefiddler ae3f8cff55 [Doc] Fixed doxygen latex-to-pdf conversion
pdflatex will fail when a <seealso> elements is placed within a
<summary> element. This is now fixed.
2014-02-16 15:30:22 +01:00
Stefanos A. 0052ff435e [Win] Do not raise KeyPress for control chars
This matches the documented behavior of the GameWindow.KeyPress event.
2014-02-13 14:01:35 +01:00
Stefanos A. 1c1607da56 [OpenTK] Make VB.Net overload resolution happy
GLHelper.cs contains a number of overloads that cannot be resolved by
VB.Net. We cannot remove them, as that will break
backward-compatibility, but we can hide them by moving them after the
autogenerated overloads in GL.cs.

Terrible hack, but it appears to work.

Issue originally reported at http://www.opentk.com/node/3554 as "OpenTK
1.1, VB.net and ambiguous functions."
2014-02-12 16:14:00 +01:00
thefiddler 30571f7532 Merge pull request #58 from Frassle/develop
Replace non-breaking space.
2014-02-11 23:54:47 +01:00
Fraser Waters a18fb1ebaa Remove non-breaking space.
Causes the build on Ubuntu to fail.
2014-02-11 16:36:31 +00:00
Stefanos A 61f0ca89b4 Merge branch 'joyhat' into develop 2014-02-10 10:54:22 +01:00
thefiddler ccd1ad0fd7 [GL] Do not limit strings to StringBuilder.Capacity. Fixes issue #57
We let StringBuilder grow to fit the unmanaged string. This appears to
match the default CLR marshaling behavior, which was used in OpenTK 1.0.
2014-02-07 15:57:36 +01:00
thefiddler 63dd4597c7 [GL][ES] Mark DebugProc* delegates as unmanaged function pointers
Calling convention is platform-dependent: stdcall on Windows, cdecl
elsewhere. This maps to CallingConvention.Winapi in .Net parlance.
2014-02-06 15:01:22 +01:00
thefiddler bb741579c6 Merge pull request #56 from l3m/matrix4d-axis-angle
Updated Matrix4d.FromAxisAngle to mirror the Matrix4 version.
2014-02-06 10:33:09 +01:00
thefiddler 2bcf153475 [GL] Fixed invalid IL instruction in Get*() and Delete*() functions 2014-02-04 16:07:58 +01:00
thefiddler d8eda71a2c [GL] Added missing ActiveUniformType.FloatMat3x2 token 2014-02-04 14:26:52 +01:00
Jonas Boesch e2ecba7274 Updated Matrix4d.FromAxisAngle to mirror the Matrix4 version. 2014-02-04 14:03:59 +01:00
thefiddler 6856fe5e71 Merged remote-tracking branch 'l3m/matrix4d-quat-fix' into develop
Updated the Matrix4d CreateFromQuaternion methods to actually create
Matrix4d. They now mirror the Matrix4 CreateFromQuaternion methods,
just using doubles and the -d classes.

Previously, Matrix4d.CreateFromQuaterion actually created a Matrix4
from a single-precision Quaterion.
2014-02-03 11:11:36 +01:00
Stefanos A. d0522f1073 [Win] Do not create second WinMMJoystick instance 2014-02-01 16:03:07 +01:00
Stefanos A. 45df508f8f [Win] Query WinMM joysticks on devicechange event 2014-02-01 16:02:02 +01:00
Stefanos A. 2d110728aa [Win] Cache WinMM joystick capabilities 2014-02-01 16:01:33 +01:00
Stefanos A. 2dee96d918 [Input] Fixed SetButton index check 2014-01-31 16:40:57 +01:00
Stefanos A. 4fceca2f80 [Input] Fixed compilation error 2014-01-31 16:37:36 +01:00
thefiddler 5145ebceb7 [Mac] Implemented JoystickHat support 2014-01-31 16:17:04 +01:00
thefiddler a7228274aa [Input] Added JoystickCapabilities.HatCount 2014-01-31 15:40:07 +01:00
thefiddler 168c45f0e2 [SDL2] Implemented support for hat state 2014-01-31 15:03:51 +01:00
thefiddler 801d6ead04 [Input] Added hat state to JoystickState 2014-01-31 15:03:30 +01:00
thefiddler 0cacdf6ae4 [Input] Do not use a bitfield for hat position
Using a bitfield does not save storage space in this case, and also
stops pattern matching from working (switch() statement in C# or match
… with expressions in F#.)
2014-01-31 15:03:19 +01:00
thefiddler a4ce2182d2 [Input] Added JoystickHatState structure 2014-01-31 15:01:35 +01:00
thefiddler 5fe2d60857 [Input] Added structures for joystick hat input 2014-01-30 17:40:26 +01:00
thefiddler 41a23ca371 [Input] Fixed off-by-one error in internal max axes/buttons 2014-01-30 17:36:59 +01:00
Stefanos A. 0e7f237d5e [Examples] BindAttribLocation must precede LinkProgram 2014-01-30 11:42:07 +01:00
Stefanos A. bc95477488 [Examples] Updated to use 1.1 API 2014-01-30 11:40:01 +01:00
thefiddler 71d6da80de [Win] Faster WinMM GetCapabilities() and GetState()
joyGetDevCaps() is an extremely slow call that allocates memory.
WinMMJoystick is now caching its results for a significant speedup in
Joystick.GetCapabilities() and GetState().

The cache is updated whenever a joystick device is removed. WIP to
handle device added notifications.
2014-01-30 10:18:11 +01:00
thefiddler eeaa3276f1 [Input] Implemented axis-button mappings 2014-01-29 10:39:18 +01:00
thefiddler ef429aff01 [Input] Added support for JoystickButtons 16-31 2014-01-29 10:28:06 +01:00
thefiddler c73e4785cd Merge remote-tracking branch 'cwassall/develop' into develop 2014-01-26 12:19:51 +01:00
thefiddler b9426006ef [GLControl] Warn when accessing GL properties on non-current context 2014-01-26 11:08:08 +01:00
thefiddler c9a86a63ab [GLControl] Use IGraphicsContext.SwapInterval to get/set vsync
This patch fixes warnings related to the deprecated
IGraphicsContext.VSync property.
2014-01-26 10:39:39 +01:00
thefiddler 24be068742 [GLControl] Clarified docs regarding multiple contexts 2014-01-26 10:36:52 +01:00
thefiddler cd42f92c12 [Input] Corrected GamePadState range to byte [0,255] 2014-01-25 17:05:06 +01:00
Stefanos A. 06a3d7e1a7 [OpenTK] Don't skip AA modes in RelaxGraphicsMode
Previously, specifying an odd AA mode (e.g. 5x) would have been relaxed
to 0x. Now, it will be correctly relaxed to 4x.
2014-01-22 23:25:11 +01:00
thefiddler 417a6bedc1 [SDL2] Use RelaxGraphicsMode to find optimal mode
For SDL2, RelaxGraphicsMode requires us to clear context attributes
between consecutive attempts. This is implemented by calling
ClearGLAttributes().
2014-01-22 11:37:37 +01:00
thefiddler 0575e63a27 [Max] Use RelaxGraphicsMode to find optimal mode 2014-01-22 11:03:40 +01:00
thefiddler 6ba475e23f [Win] Use RelaxGraphicsMode to find optimal mode 2014-01-22 10:49:55 +01:00
thefiddler 615df9201b [OpenTK] Moved RelaxGraphicsMode to Utilities
This functionality is useful for all platform backends and is not
specific to the X11 backend.
2014-01-22 10:49:27 +01:00
thefiddler 6f3951e825 [OpenTK] Allow a GraphicsMode.Buffers value of 0
0 in this case means “don’t care”.
2014-01-22 10:48:40 +01:00
thefiddler ff36f0f35a [OpenTK] Clamp max AA level to 64x
This protects against a potential denial-of-service issue during mode
selection, where the platform backend will try to reduce AA level until
a supported mode is found.
2014-01-22 10:35:08 +01:00
thefiddler 2b6aec3b23 [OpenTK] Removed unused GraphicsMode field 2014-01-22 10:31:01 +01:00
Stefanos A. 770b697583 [Win] Clear extension list on reload 2014-01-21 09:04:27 +01:00
Stefanos A. 88ae446781 [Win] Removed WGL delegates in favor of calli 2014-01-21 09:00:57 +01:00
Stefanos A. 5379deaf63 [Win] Implemented calli-based interop for WGL 2014-01-21 09:00:25 +01:00
cwassall 7b591962e8 Change original_resolution field to a property
As the original_resolution field needs to be accessed from outside the
module, it should be an internal property as opposed to an internal
field
2014-01-20 12:51:55 +00:00
cwassall 5f6c8e654c Remember DisplayDevice original resolutions
When refreshing the AvailableDevices list, it is important to set the
original resolution on any DisplayDevices that were previously available
to allow the RestoreResolution() method to work correctly.
2014-01-19 19:44:12 +00:00
Stefanos A. c2e3328f59 [GLControl] Use dummy context in design mode
Creating a GraphicsContext with null parameters is not a guarantee that
we will get a dummy context that does not call any OpenGL functions. We
need to explicitly define and construct a dummy context that is safe to
use inside the designer.

Affects issue #49
2014-01-18 18:33:25 +01:00
Stefanos A. b87b9e0a27 [Win] Fix X1/X2 mouse buttons (fixes issue #27) 2014-01-16 17:16:03 +01:00
Stefanos A. 8cb3538767 [Examples] Move UTF8 sample to Test folder 2014-01-16 14:37:27 +01:00
Stefanos A 51e99fe638 Merge branch 'utf8_test' of https://github.com/ganaware/opentk into utf8 2014-01-16 14:33:15 +01:00
Stefanos A. b9f57ba4d2 [OpenTK] Use ASCII encoding
Most OpenGL versions work with single-byte ASCII strings exclusively.
OpenGL 4.2 adds UTF8 encoded comments to GLSL shaders. Unfortunately,
UTF16 (.Net) to UTF8 conversions will usually modify the length of the
resulting byte array.

This is not currently possible to implement inside OpenTK, since the
binding generator does not know which length parameter corresponds to a
string parameter.

For this reason, and to maintain compatibility with older OpenGL
versions, we perform a destructive UTF16-to-ASCII encoding, which
replaces unsupported characters by '?'. This allows multi-byte post-4.2.
GLSL shaders to work as expected.

If non-destructive round-tripping of strings is required, the user will
have to use the IntPtr overload for string parameters and perform the
UTF16-to-UTF8 encoding/decoding manually. This need is very unlikely to
arise in practice.
2014-01-16 14:32:11 +01:00
Stefanos A 606b4ddcd1 Merge branch 'develop' of https://github.com/opentk/opentk into utf8 2014-01-16 11:44:34 +01:00
Stefanos A 9268b5ed7f Merge branch 'develop' into utf8 2014-01-16 11:39:22 +01:00
Nayuta Taga b15f91a0f2 shader source with Japanese comment test 2014-01-16 18:27:32 +09:00
Nayuta Taga 1929cf60fa Merge branch 'utf8' into utf8_test 2014-01-16 18:05:03 +09:00
thefiddler 44e2576c86 [OpenTK] Protect against invalid axis/button ids 2014-01-15 01:24:20 +01:00
thefiddler e6a9adf494 [OpenTK] Fixed polling 2014-01-15 01:19:45 +01:00
thefiddler e7f037b0a2 [OpenTK] Fixed legacy joystick hotplugging & events 2014-01-15 01:13:39 +01:00
thefiddler df7d7ae8eb [Linux] Implemented joystick guid detection 2014-01-15 00:57:28 +01:00
thefiddler 73e3b66038 [OpenTK] Use LegacyJoystickDriver for IJoystickDriver implementation 2014-01-14 23:53:24 +01:00
thefiddler fb917a6d89 [Linux] Implemented joystick hotplugging 2014-01-14 23:51:31 +01:00
thefiddler 4ca8c78764 [OpenTK] Suggest alternative to obsolete INativeWindow.InputDriver property 2014-01-14 23:40:23 +01:00
Stefanos A. 4473c8373e [X11] Implemented joystick hotplugging
This is a work in progress.
2014-01-14 18:37:16 +01:00
Stefanos A. b004dc7a0a [X11] Added INotify.cs to project files 2014-01-14 18:36:36 +01:00
Stefanos A. 4203c14b22 [X11] Removed IJoystickDriver from X11Joystick
Legacy IJoystickDriver support is now implemented through a
LegacyJoystickDriver instance.
2014-01-14 18:36:19 +01:00
Stefanos A f3036e5f10 Merge branch 'develop' into linux_joystick 2014-01-14 18:26:05 +01:00
Stefanos A cb4e4d5e72 Merge branch 'legacy_joystick' into linux_joystick 2014-01-14 18:17:05 +01:00
Stefanos A. d467629ad8 [Linux] Added INotify bindings
These are not currently used.
2014-01-14 18:15:53 +01:00
Stefanos A 962a9f7733 Merge branch 'issue43_unstablefps' into develop 2014-01-14 14:21:19 +01:00
Stefanos A. 0c9b612bff [OpenTK] Increase max Update/RenderFrame rates
Given the new 144Hz monitors on the market today, it makes sense to
increase the Update/RenderFrame limit from 200Hz to 500Hz.
2014-01-14 14:20:38 +01:00
Stefanos A. 1f44cf27a1 [OpenTK] Do not hang when update rate too high
OpenTK will now detect when an UpdateFrame handler is consistently
taking too long to finish, and stop raising UpdateFrame events. This
gives ProcessEvents() a chance to execute and will protect the
application from hanging up.
2014-01-14 13:55:24 +01:00
Stefanos A. 95d71bc0cc [OpenTK] Respect a TargetUpdatePeriod of zero 2014-01-14 13:33:41 +01:00
Stefanos A. 7b98255626 [Examples] Improved timing display
GameWindowStates will now display the average fps and draw three moving
boxes based on different timing methods.

If the timing implementation in OpenTK is working correctly, all three
boxes should be moving at the same speed.
2014-01-14 13:27:09 +01:00
Stefanos A. 97e49b76b2 [OpenTK] Fix UpdateFrame quantization error
The UpdateFrame event rate will now match TargetUpdatePeriod even if
vsync is enabled. Previously, it would be quantized to a multiple or
integer fraction of of the vsync rate.
2014-01-14 13:04:30 +01:00
Stefanos A. 3eccb89821 [OpenTK] Remove Thread.Sleep() from loop timing 2014-01-13 11:36:56 +01:00
Stefanos A. b3554bb74c [OpenTK] Simplified update and render loops 2014-01-13 11:22:33 +01:00
thefiddler 7afe48c979 [Audio] Don't crash when Alc.GetString() returns null
Alc.GetString() could crash if the unmanaged code returned null due to
any kind of failure. This is now fixed and better documented.

Additionally, the array overload for Alc.GetString() will now correctly
forward the ‘device’ parameter to unmanaged code.
2014-01-12 22:05:15 +01:00
Stefanos A. fca9f930e4 [OpenTK] Fix UpdateFrame loop condition
Multiple UpdateFrame events should be raised to match the desired
TargetUpdateFrequency, when TargetUpdateFrequency > 0. The loop would
incorrectly check for TargetRenderFrequency instead.

Affects issue #43
2014-01-12 21:37:18 +01:00
Stefanos A. c31f64f7e1 [OpenTK] Frameskip needs TargetUpdateFrequency!=0 2014-01-11 01:46:38 +01:00
Stefanos A. 19eb72b3a9 [OpenTK] Fixed Utilities.CreateSdl2WindowInfo
Utilities.CreateSdl2WindowInfo should store the specified windowHandle
directly instead of trying to call SDL.SDL.CreateWindowFrom.
2014-01-10 16:56:26 +01:00
Stefanos A. aff9719872 [SDL2] Implemented GetWindowWMInfo 2014-01-10 16:55:20 +01:00
Stefanos A. bdfcf43e0b [Win] More robust pixel format selection
This patch adds more robust checks for WGL_ARB_pixel_format and
WGL_ARB_multisample before using the relevant extensions, and adds
checks whether Wgl.Arb.ChoosePixelFormat() returns a valid pixel format
before trying to use it (thanks to Repetier for catching this edge
case.)

Additionally, the ChoosePixelFormatPFD code-path now heavily penalizes
single-buffered modes when the user requests a double-buffered mode.

Affects issues #42 and #45
2014-01-10 15:41:57 +01:00
Stefanos A. ef5aedba6f [Win] More robust WGL extension detection
Affects issue #42 and issue #45
2014-01-10 09:24:59 +01:00
thefiddler a4d2a31386 [Mac] OpenGL 3.x/4.x require core profile flag
SDL will fail to construct an OpenGL 3.x/4.x context on Mac OS X,
unless ContextProfileFlags.CORE is specified.

Fixes issue #44

Upstream enhancement request at
https://bugzilla.libsdl.org/show_bug.cgi?id=2342
2014-01-09 23:36:28 +01:00
Stefanos A. 7f64945079 [OpenTK] Do not raise *Frame events when time = 0
Affects issue #40
2014-01-09 00:51:09 +01:00
Stefanos A. 28ac3cec0b [Win] Fix issue #35 (OpenTK over Remote Desktop)
When running over remote desktop without hardware acceleration, there
are no GraphicsModes that support desktop composition. This patch adds
logic to avoid requesting composition-capable modes when running over
RDP.

Additionally, it changes the mode selection logic to consider modes that
support features partially (e.g. 16bpp color instead of 32bpp), albeit
with a heavy penalty over fully supported modes.
2014-01-09 00:14:25 +01:00
Stefanos A. 1b3b510376 [Win] Check registry keys before accessing
Fixes crashes when using OpenTK over the Remote Desktop Client for Mac
(version 2010).
2014-01-09 00:10:41 +01:00
Stefanos A. 4af9d30ccb [Win] Fix issue #33; fix issue #34
This patch adds a workaround for WM_STYLECHANGED messages that are not
delivered when running on Mono/Windows. If we detect Mono, then we call
HandleStyleChanged() directly in order to update the internal state of
our WinGLNative instance.
2014-01-08 22:29:22 +01:00
Stefanos A. 51ad513dbb [Win] Do not overload internal SetWindowLong
The internal function is now appended with "Internal".
2014-01-08 19:22:03 +01:00
Stefanos A. 7363cfee7b [Win] Do not unregister class twice
Only the parent window would register a class, but both the parent and
the child window would unregister it. This is now fixed.
2014-01-08 19:21:29 +01:00
Stefanos A. 51baed7286 [Win] Remove unnecessary #if clauses 2014-01-08 00:45:42 +01:00
Stefanos A. e260a42954 [Win] Refactor huge wndproc into functions 2014-01-08 00:02:27 +01:00
Stefanos A. a961fb3db3 [Examples] Added keys to modify timing
Use [ and ] to decrease and increase the UpdateFrame frequency.
Use < and > to decrease and increase the RenderFrame frequency.
2014-01-07 22:09:52 +01:00
Stefanos A. b6a806a568 [OpenTK] Improved timing stability
OpenTK now directly calculates the elapsed time between UpdateFrame
(RenderFrame) events and compares that directly to TargetUpdatePeriod
(TargetRenderPeriod). This significantly simplifies the implementation
and improves timing stability.
2014-01-07 22:09:02 +01:00
Stefanos A. 6e03d501ae [OpenTK] Fixed Update/RenderTime calculation
These values should only be re-calculated when an Update/RenderFrame
event is raised. Otherwise, they should retain their previous values.
2014-01-07 15:55:11 +01:00
thefiddler 251f5717ae [Examples] Improve timing information; add vsync toggle 2014-01-07 09:12:35 +01:00
thefiddler 99df27b635 [OpenTK] Corrected GameWindow.Update/RenderFrequency information 2014-01-07 09:11:55 +01:00
thefiddler 56a3dd91e5 [OpenTK] Implemented GameWindow.UpdateTime and RenderTime properties 2014-01-07 09:09:43 +01:00
thefiddler 3856fcd48e [OpenTK] More robust timing for UpdateFrame and RenderFrame
FrameEventArgs.Time should no longer drift from clock time measured
outside GameWindow.
2014-01-07 08:52:02 +01:00
thefiddler c5dcc8a93b [Examples] Calculate timing information in GameWindowStates 2014-01-07 01:01:00 +01:00
thefiddler d49dacb5b3 [Examples] Cleaned up input device printing in GameWindowStates 2014-01-07 00:48:09 +01:00
thefiddler 94c3c24bfb [OpenTK] Platform backends should inherit from PlatformFactoryBase
This reduces code duplication wrt deprecated interfaces and common
support code between backends.
2014-01-06 14:49:05 +01:00
thefiddler d84be0d594 [OpenTK] Added base IPlatformFactory implementation
PlatformFactoryBase provides a common base interface for platform
backends. Platform backends should inherit from PlatformFactoryBase in
order to reduce code duplication.
2014-01-06 14:47:58 +01:00
thefiddler a94a293732 [Platform] Implemented legacy IJoystickDriver
LegacyJoystickDriver implements the legacy IJoystickDriver interface
(GameWindow.Joysticks) in terms of the new IJoystickDriver2 interface
(OpenTK.Input.Joystick).

This removes a large chunk of code from each platform backend, as they
no longer need to implement IJoystickDriver themselves. Additionally,
it adds support for device hot plugging which was previously missing.
2014-01-06 14:25:05 +01:00
Stefanos A. 83f54f70aa [OpenTK] Simplify and improve timing calculations
This patch modifies GameWindow.Run() to use a single stopwatch instead
of two separate stopwatches for timing UpdateFrame and RenderFrame
events.

It improves timing accuracy for issue #20 (FrameEventArgs.Time
Inconsistencies)
2014-01-06 01:57:54 +01:00
Stefanos A. 88c57db5b6 [Math] Added MathHelper.Clamp 2014-01-06 01:52:08 +01:00
thefiddler a9ab3650da [Mac] Do not store *State structs directly
Storing Mouse/KeyboardState structs directly makes updates more
difficult than they should be. It is simpler to create simple classes
instead.
2014-01-05 23:58:05 +01:00
thefiddler 4d660fdeba [Input] Added Keyboard/MouseState.SetIsConnected to mirror JoystickState 2014-01-05 23:50:17 +01:00
thefiddler fda2d32d2d [Mac] Map GamePads, MultiAxisControllers and Wheels to joysticks 2014-01-05 22:44:58 +01:00
thefiddler a1123834a0 [Mac] Call DeviceRemoved() in Dispose() event
The necessary cleanup code already exists in DeviceRemoved(). No need
to duplicate this in the Dispose() event.
2014-01-05 22:38:26 +01:00
thefiddler ab85afd5ba [Mac] Avoid IOHIDDeviceConformsTo call in DeviceRemoved handler
DeviceAdded already checks that devices conform to the desired usage
pages. Checking again in DeviceRemoved is unnecessary - if a device
exists, then it has already passed muster.
2014-01-05 22:36:01 +01:00
thefiddler 9e223486f6 [Mac] Implement Joystick.GetGuid() 2014-01-05 22:15:55 +01:00
thefiddler 5c5afb3ea3 [Mac] Calculate joystick Guid for USB devices 2014-01-05 22:06:19 +01:00
thefiddler b458b40683 [Mac] Use out/ref parameters instead of unsafe pointers in bindings 2014-01-05 22:05:54 +01:00
thefiddler fa386dc991 [Mac] Connect devices to first available index 2014-01-05 21:53:28 +01:00
thefiddler fc81f30251 [Examples] Draw device index for Joysticks and GamePads 2014-01-05 21:32:24 +01:00
thefiddler 05af21e61b [Mac] Do not call CFRelease on HID properties
HID properties are callee-owned and should not be released by the
caller. Fixes crash (memory corruption) on device hot plugging.
2014-01-05 21:27:34 +01:00
thefiddler 02c9f471ea [Mac] DllImport must be marked as extern 2014-01-05 21:18:20 +01:00
thefiddler 7388bd935d [Mac] Correctly unschedule HIDManager from run loop 2014-01-05 20:17:03 +01:00
thefiddler 4c7f6a92a7 [Mac] Don't let exceptions escape to unmanaged code 2014-01-05 04:20:51 +01:00
thefiddler 892d129e54 [Mac] Fixed DllEntryPointNotFound crash on device unplugging 2014-01-05 04:15:30 +01:00
thefiddler 2ee24efb2f [Mac] Implemented joystick buttons 2014-01-05 04:11:11 +01:00
thefiddler fad42994e1 [Mac] Implemented joystick axis movement 2014-01-05 03:54:53 +01:00
thefiddler 92635b3f35 [Input] Added JoystickAxis/Button.Last; added JoystickAxis.Axis10.
JoystickAxis/Button.Last is used internally to allocate the correct
amount of storage for joystick axes and buttons. JoystickAxis.Axis10 is
required to support the maximum number of axes available on Mac OS X.
2014-01-05 03:54:34 +01:00
thefiddler 59249c2624 [Mac] Implemented joystick device detection 2014-01-05 03:03:46 +01:00
thefiddler 07bcda0f57 [Mac] Retrieve HID joystick name 2014-01-05 02:42:47 +01:00
thefiddler 6dadbd3570 [Mac] Implemented necessary CFString methods 2014-01-05 02:42:33 +01:00
thefiddler 32653d2c64 [Mac] Construct JoystickDevice when joysticks are connected 2014-01-05 00:47:40 +01:00
thefiddler 3757db9978 [Input] Allow extending JoystickDevice<> 2014-01-05 00:46:59 +01:00
thefiddler bf8efea121 [Mac] Only add callbacks for recognized USB HID devices 2014-01-05 00:00:49 +01:00
thefiddler c44b477388 [Mac] Implement device added/removed events for joysticks 2014-01-04 23:58:59 +01:00
thefiddler 9659a1d786 [Mac] Add skeleton HID input implementation for joysticks 2014-01-04 23:55:38 +01:00
thefiddler 3a63496b6d Merge branch 'gamepad' into develop
Conflicts:
	Source/OpenTK/OpenTK.csproj
2014-01-03 02:23:02 +01:00
thefiddler 514390fc9a [Graphics] Added missing documentation comment 2014-01-03 02:18:28 +01:00
thefiddler 53552b0070 [Input] Corrected malformed documentation comments 2014-01-03 02:17:42 +01:00
thefiddler 3095afa18a [Input] Documented all public members 2014-01-03 01:58:16 +01:00
thefiddler b35aad1503 [Input] Removed JoystickState.GetAxis(int) overload 2014-01-03 01:58:08 +01:00
thefiddler 8649e4a044 [Input] Added SetVibration() API skeleton 2014-01-02 19:52:00 +01:00
thefiddler ec43b9ff85 [Input] GamePad and Joystick classes should be sealed 2014-01-02 19:27:04 +01:00
thefiddler b513e35ea8 [SDL2] Implemented PacketNumber property 2014-01-02 19:24:38 +01:00
thefiddler 1ccf7e5ad2 [Input] Added PacketNumber property 2014-01-02 19:24:15 +01:00
thefiddler b5d42b7992 [Input] Implemented GetState() and simplified GetCapabilities() 2014-01-02 18:37:53 +01:00
thefiddler d49af2787f [Input] Simplified configuration parser and added GetEnumerator() 2014-01-02 18:37:20 +01:00
thefiddler 8f00bbc9f2 [Input] Added internal Joystick.GetAxisRaw() method 2014-01-02 18:36:27 +01:00
thefiddler 0593ea62e6 [Input] Added Source and Target to GamePadConfigurationItem 2014-01-02 18:36:09 +01:00
thefiddler bf5d2a738d [Input] Made configuration database non-static 2014-01-02 02:42:51 +01:00
thefiddler 9e4827bf67 [SDL2] Fixed SDL_JoystickGetGUID capitalization 2014-01-02 02:20:51 +01:00
thefiddler a8fb977017 [Input] Initialize JoystickDevice.Details in constructor 2014-01-02 02:20:25 +01:00
thefiddler fb57a9062d [Input] Renamed GamePadMap to GamePadConfiguration 2014-01-02 01:38:12 +01:00
thefiddler dc1ffab78d [Input] Implemented IGamePadDriver.GetName() 2014-01-02 01:34:21 +01:00
thefiddler c2c76f2ab2 [Input] Made the Name property public
We can use the name property to implement a hypothetical
GamePad.GetName() method in the future.
2014-01-02 01:33:57 +01:00
thefiddler b056a50e73 [Input] Added xml documentation for GamePadCapabilities 2014-01-02 01:33:08 +01:00
thefiddler a0dad7f698 [Input] Implemented MappedGamePadDriver.GetCapabilities() 2014-01-02 01:13:20 +01:00
thefiddler f0fbb26efe [Input] Added ability to parse SDL configuration db strings 2014-01-02 01:07:21 +01:00
thefiddler 5e75fac056 [Input] Added configuration db for GamePads
The database is based on the SDL bindings found at
https://hg.libsdl.org/SDL/file/b744b3f8754b/src/joystick/SDL_gamecontrol
lerdb.h
2014-01-02 01:06:47 +01:00
thefiddler b9a8e365de [Input] Added IJoystickDriver2.GetGuid() API 2013-12-31 14:09:17 +01:00
thefiddler cd143af60a [SDL2] Added JoystickGetGUID method 2013-12-31 14:08:28 +01:00
thefiddler 1687518ef5 [SDL2] Add compile-time check for SDL2 GameController vs MappedGamePadDriver 2013-12-31 11:46:40 +01:00
thefiddler ef7f31099d [Input] Removed unnecessary #region 2013-12-31 01:02:07 +01:00
thefiddler 7d4d116ce9 [Input] Renamed GamePadMapping to GamePadMap 2013-12-31 01:01:52 +01:00
thefiddler d4348c5083 [SDL2] Fixed joystick/controller hotplugging support 2013-12-30 17:22:45 +01:00
thefiddler 9c8a5f5028 [SDL2] Fixed GameControllerButton to Buttons translation 2013-12-30 17:15:49 +01:00
thefiddler 43ef78f222 [SDL2] Fix issue where changes to mutable struct were lost 2013-12-30 17:09:20 +01:00
thefiddler 9beb396c9e [SDL2] Explicitly enable joystick and gamepad events 2013-12-30 17:08:42 +01:00
thefiddler 2d303a6884 [Input] Buttons should have [Flags] attribute 2013-12-30 16:07:06 +01:00
Stefanos A. 6faa58aac3 [SDL2] Fixed joystick hotplugging
SDL2 uses a weird system of device ids and instance ids to report
joystick events, where the ADDED event uses a device id and the rest use
instance ids.

The SDL2 joystick driver is now fixed to correctly distinguish between
the two, which fixes hotplugging support for joystick devices.
2013-12-30 15:24:48 +01:00
thefiddler 52b8762593 [SDL2] Fixed mapping of instance ids to device ids 2013-12-30 14:57:28 +01:00
thefiddler a4366e52f5 [Input] Added missing closing brace in ToString() message 2013-12-30 14:56:22 +01:00
thefiddler 064a45e4a7 [Input] Fixed incorrect variable name 2013-12-30 13:49:26 +01:00
thefiddler 1b0a72472e [SDL] Use TranslateAxis() to decode ControllerAxisEvent
SDL GameControllerAxis and GamePadAxes are not interchangeable. The
driver will now correctly interpret incoming SDL messages and update
the GamePadState for the relevant axis.
2013-12-30 13:42:37 +01:00
thefiddler e997ddf9c6 [Input] Fixed GamePadState.SetAxis() implementation
GamePadState.SetAxis() receives a GamePadAxes enumeration, which is a
bitmask of the axes we wish to set. SetAxis now correctly decodes the
bitmask to apply the values we are interested in.
2013-12-30 13:39:43 +01:00
thefiddler 0b8db7c40b [X11] Removed unused variable 2013-12-30 10:25:17 +01:00
thefiddler 4005710b99 [X11] Fixed current resolution detection. 2013-12-30 09:23:33 +01:00
thefiddler 3dbf575765 [Build] Added new files to the relevant csproj scripts 2013-12-28 01:23:39 +01:00
thefiddler 3bad2eefdc [Examples] Added ExternalContext test
This test uses SDL2 to create a window and an OpenGL context. It then
uses OpenTK to render into the external SDL2 context. If everything is
working correctly, a black window should appear and gradually turn
white before disappearing.
2013-12-28 01:17:56 +01:00
thefiddler 04e6d9335a [Graphics] Improved support for external OpenGL contexts
When combining OpenTK with a third-party OpenGL toolkit, it is now
possible to implement a suitable GetAddress() and GetCurrentContext()
implementation in terms of the third-party toolkit. If no
implementation is specified, then OpenTK will try to guess the most
suitable implementation within its own platform backends.

If no custom implementation is defined, and if no suitable
implementation can be found, then OpenTK will throw a
PlatformNotSupportedException. If a suitable implementation is found or
defined, then OpenTK will attempt to load OpenGL entry points using
that implementation.

In this case third-party toolkit remains solely responsible for
managing its context via its MakeCurrent(), SwapBuffers(), etc
implementations.
2013-12-28 01:14:59 +01:00
thefiddler 5cebaccfca [Dummy] Improved thread-safety; added entry-point loader
DummyGLContext will now attempt to load OpenGL and OpenGL ES entry
points when a suitable OpenGL context is current on the calling thread.
This allows OpenTK to be used on contexts created through third-party
toolkits.
2013-12-28 01:09:59 +01:00
thefiddler 8bcbb06f8e [Platform] Added internal CreateGetAddress() function
CreateGetAddress() constructs a GraphicsContext.GetAddressDelegate that
is suitable for the current platform. This can be used when combining
OpenTK with an OpenGL context created through a third-party toolkit.
2013-12-28 01:08:24 +01:00
thefiddler cf76aa6085 [Mac] Moved GetAddress implementation to its own class
The functions defined in libdl.dylib are useful in more places than
just AglContext. Moving them to their own class ensures we can access
these from wherever we might need them.
2013-12-28 01:06:33 +01:00
thefiddler 9171977079 [SDL2] Added missing [SuppressUnamangedCodeSecurity] attribute 2013-12-28 01:04:46 +01:00
thefiddler b79d951e62 [Mac] Use Cgl.GetCurrentContext instead of Agl
CGL appears to work with both AGL and NSOpenGL contexts, whereas AGL is
limited to AGL contexts. This allows us to be more flexible in terms of
implementation (i.e. we can use Cgl.GetCurrentContext to retrieve a
handle to a context created through SDL, which uses NSOpenGL
internally.)
2013-12-28 01:04:22 +01:00
thefiddler 0d1df41393 [X11] Improve GraphicsMode fallback (fixes issue #23)
When the user requests a GraphicsMode that is not directly supported
by the GPU/drivers, we should relax the requested parameters until
we find a supported mode. An exception should only be thrown when
there is no usable mode.

This makes the X11 backend match the behavior of Windows. The SDL/X11
backend works a little bit differently, in that it falls back to the
a default mode directly if the requested mode is not available. There
is nothing we can do about that.
2013-12-27 14:01:21 +02:00
thefiddler 88f7cd68f5 [X11] Fixed border size on Gnome 3
The _NET_FRAME_EXTENTS atom is implemented differently by
different window managers, when window decorations are hidden
with Motif. Unity returns a 0 size, while Gnome 3 returns the
previous size.

This patch removes that ambiguity: when decorations are hidden,
border size becomes zero. This should work everywhere, unless
some window manager decides to troll us by decorating the window
when we explicitly request no decorations. Sigh...
2013-12-27 13:31:51 +02:00
thefiddler ab8796c942 [Input] Do not crash with scancodes > 255 2013-12-27 11:10:41 +01:00
thefiddler 6c6e09aae6 [X11] Allow resizing with fixed borders
Windows can now be resized programmatically, even when they have
WindowBorder.Fixed. All resizing logic is now consolidated in the
Bounds property, and ConfigureNotify messages are now handled
correctly depending on their source (StructureNotify or
SubStructureNotify.)
2013-12-27 11:07:38 +01:00
thefiddler 4d27b6ee55 Implemented X11 KeyDown/KeyUp events and reduced code duplication 2013-12-25 11:46:02 +01:00
thefiddler ffdf881cea Do not raise KeyPress for control characters 2013-12-25 11:14:30 +01:00
thefiddler f7fbf38c43 IsButtonBind should check for buttons, not axes 2013-12-25 01:47:27 +01:00
thefiddler b4b8bc1665 Implemented SDL IJoystickDriver2 and IGamePadDriver 2013-12-24 19:15:23 +01:00
thefiddler c51c4934df Added GameControllerGetBind APIs 2013-12-24 19:14:54 +01:00
thefiddler 6fc679c4ba Removed duplicate button types 2013-12-24 19:14:35 +01:00
thefiddler 1eb807bb64 Use IGamePadDriver through MappedGamePadDriver 2013-12-24 17:18:05 +01:00
Stefanos A 7fd7b8c7a2 Improved ToString implementation 2013-12-24 17:18:05 +01:00
Stefanos A 9a90772cef Fixed WinMM offsets for IJoystickDevice2 2013-12-24 17:18:05 +01:00
Stefanos A f3cb578587 Improved WinMMJoystickDriver hotplugging behavior 2013-12-24 17:18:05 +01:00
Stefanos A d33d0c7387 Added state output for OpenTK.Input.Joystick 2013-12-24 17:18:05 +01:00
Stefanos A 82a2c9113c Implemented structural equality 2013-12-24 17:18:04 +01:00
Stefanos A 890d56ae63 Connected XInput driver 2013-12-24 17:18:04 +01:00
Stefanos A 15c01d0d5c WinMMJoystick implements IJoystickDriver2
WinMM is optimized for general joystick use, not for the canonical
GamePad layout. Instead of exposing IGamePadDriver directly, it should
expose IJoystickDriver2 and use a mapping driver to get GamePad support.
2013-12-24 17:18:04 +01:00
Stefanos A 165aa5bde6 Added MappedGamePadDriver skeleton implementation 2013-12-24 17:18:04 +01:00
Stefanos A 02fb6bf2f9 Implements JoystickState and Capabilities setters 2013-12-24 17:18:04 +01:00
Stefanos A 91b54cfbf3 No reason to comment out #region License 2013-12-24 17:18:04 +01:00
Stefanos A 52daef4b0d Added internal GamePadMapping class 2013-12-24 17:18:04 +01:00
Stefanos A 2839db587e Implemented thumbsticks and trigger caps 2013-12-24 17:18:04 +01:00
Stefanos A 7e5307bd4a Added IJoystickDevice2 interface 2013-12-24 17:18:03 +01:00
Stefanos A e2d86fdf52 Implemented initial XInput IGamePadDriver 2013-12-24 17:18:03 +01:00
Stefanos A b62f5993d4 Added missing left/right triggers 2013-12-24 17:18:03 +01:00
Stefanos A f459647613 Removed all instances of refresh_text 2013-12-24 17:18:03 +01:00
Stefanos A ddc52ce135 Implemented GamePad Capabilities and Type 2013-12-24 17:18:03 +01:00
Stefanos A ea3c9ffe85 Refresh text continuously 2013-12-24 17:18:03 +01:00
Stefanos A dd648a8362 Initial implementation of GamePadTriggers 2013-12-24 17:18:03 +01:00
thefiddler 8f7eebb58d Enabled HIDInput IGamePadDriver implementation 2013-12-24 17:18:02 +01:00
Stefanos A 5d88a8daf4 Implemented GamePad API (WIP) 2013-12-24 17:18:02 +01:00
Stefanos A 0875cbd928 Removed unnecessary IsButtonValid method 2013-12-24 17:18:02 +01:00
Stefanos A 1adc3f7733 Display start button in ToString() 2013-12-24 17:18:02 +01:00
Stefanos A 0c9a67da41 Fixed rendering of joysticks and gamepads
Joysticks and gamepad states would overlap, causing some lines to be
unreadable. This is now fixed.
2013-12-24 17:18:02 +01:00
Stefanos A 44351a03c4 More robust handling of device add/remove events 2013-12-24 17:18:02 +01:00
Stefanos A 31ce400a7e Fixed expansion of joysticks collection 2013-12-24 17:18:02 +01:00
Stefanos A 2f1a81da2c Log errors in subsystem initialization 2013-12-24 17:18:02 +01:00
Stefanos A 1d61bd9dd2 Reuse Sdl2Factory.InputDriver in Sdl2NativeWindow 2013-12-24 17:18:01 +01:00
Stefanos A a72d70c3d0 Delay joystick initialization until necessary 2013-12-24 17:18:01 +01:00
Stefanos A 3660509dee Added SDL_InitSubSystem method 2013-12-24 17:18:01 +01:00
Stefanos A 4a13415fc6 Fixed x/y axis mixup. 2013-12-24 17:18:01 +01:00
Stefanos A 1ba5fd4380 Cleaned up using directives 2013-12-24 17:18:01 +01:00
Stefanos A 76a35c0b91 Added missing newline 2013-12-24 17:18:01 +01:00
Stefanos A 91d248ad29 Implemented GamePadThumbSticks 2013-12-24 17:18:01 +01:00
Stefanos A 18f99c2f63 Added state information for GamePads 2013-12-24 17:18:00 +01:00
Stefanos A 0c10f29bd8 More compact string representation 2013-12-24 17:18:00 +01:00
Stefanos A 1acf8a807b Implemented IEquatable<> interface 2013-12-24 17:18:00 +01:00
thefiddler 2bf024a912 Implemented new GamePad interface (WIP) 2013-12-24 17:18:00 +01:00
thefiddler ecd04a3cad Implemented GamePadButtons 2013-12-24 17:18:00 +01:00
thefiddler 484af18673 Updated internal IGamePadDriver interface 2013-12-24 17:18:00 +01:00
thefiddler ee65f81f56 Implemented GameController API bindings 2013-12-24 17:18:00 +01:00
thefiddler d9985fc571 Use SDL2 event API for joystick devices 2013-12-24 17:18:00 +01:00
thefiddler 022e5c845c Implemented SDL2 Joystick and GameController events 2013-12-24 17:17:59 +01:00
thefiddler d7fefe495e Removed unused constructors 2013-12-23 21:43:17 +01:00
thefiddler 95270c877d Added Compositing and FrameworkScaled flags 2013-12-23 21:42:16 +01:00
thefiddler 1189b33ed5 Fixed OpenTK/Carbon key repeat behavior to match the other backends 2013-12-23 20:40:27 +01:00
thefiddler c13d80d6d8 Fixed GameWindow.{Bounds, Location, Size, X, Y} setters on OpenTK/Carbon 2013-12-23 20:21:02 +01:00
thefiddler c6a21a2239 Implemented KeyDown & KeyUp events on OpenTK/Carbon 2013-12-23 19:32:16 +01:00
Stefanos A. 2d7734c915 Remove bogus GraphicsMode.Index check. Fixes #22
GraphicsMode.Index is set by the platform-specific context constructor,
which is invoked after the X11GLControl constructor. It does not make
sense to check GraphicsMode.Index in the X11GLControl constructor, as it
is never set at that point.
2013-12-22 15:40:01 +01:00
Stefanos A. 30cd9cb7f8 Fixed crash in MakeCurrent(null)
MakeCurrent(null) should set the bound device context to zero.
2013-12-22 11:10:05 +01:00
Stefanos A. 0a46e20029 Added WGL_DRAW_TO_WINDOW_ARB flag
Without this flag, OpenGL rendering does not work as expected.

Additionally, all WGL_ARB_pixel_format attributes are expected to be
specified in key-value pairs. Fixed double-buffering and stereoscoping
rendering attributes.
2013-12-22 10:35:05 +01:00
Stefanos A. a2744719d5 Improved WGL mode selection
Fixed WGL_ARB_pixel_format attribute selection for doublebuffering,
stereoscopic rendering and hardware acceleration. Implemented
minimization strategy to select the optimal PixelFormatDescriptor in the
fallback path.
2013-12-22 09:20:40 +01:00
Stefanos A. 956bbe6491 Fixed DescribePixelFormatPFD
When using the PFD codepath, we now call DescribePixelFormat to retrieve
an exact interpretation of the pixel format selected by the driver.
2013-12-21 23:35:55 +01:00
Stefanos A. 1723be8a8b Prioritize accelerated formats first
Instead of creating a list of all available formats and iterating
through that, we let the driver decide which is the best accelerated
format to use for the user parameters. If no such format exists, we fall
back to generic acceleration or software acceleration, in turn.

This affects issue #21
2013-12-21 22:43:35 +01:00
Stefanos A. a7ae4bb038 Turn 1-element array to ref/out param 2013-12-21 22:41:35 +01:00
Stefanos A. 4aa2eae2e5 Display renderer information 2013-12-21 22:41:10 +01:00
Stefanos A fd0c086e3d Marshal strings as UTF8 (affects #18)
Starting with OpenGL 4.2, strings passed to GL.ShaderSource are allowed
to contain multi-byte characters in comments (issue #18). This patch
modifies the marshaling code to use UTF8.GetBytes in order to marshal
strings, instead of Marshal.StringToHGlobalAnsi().
2013-12-21 00:51:34 +01:00
Stefanos A. 0c990583a3 Implemented KeyDown and KeyUp messages 2013-12-21 00:50:25 +01:00
Stefanos A. 42ce028bbf Clean fix issue #19
Isolate and commit fix for issue #19 without potential for regressions.
2013-12-21 00:43:05 +01:00
Stefanos A e1619a8ad3 Revert "Fix issue #19"
This reverts commit 2c14ec5f80.
2013-12-21 00:41:55 +01:00
Stefanos A. 2c14ec5f80 Fix issue #19
Don't filter window messages passed to our window (see
http://blogs.msdn.com/b/oldnewthing/archive/2005/02/09/369804.aspx).
Additionally, return the correct values for all messages we are actually
handling and clean up unmanaged memory after we are done with the
window.
2013-12-20 23:31:42 +01:00
Stefanos A. b941a8f06b Explicitly set WindowProcedure calling convention 2013-12-20 23:29:47 +01:00
Stefanos A. 2ddd555aaf Simplify ProcessEvents implementation
Instead of combining PeekMessage+GetMessage, we can simply call
PeekMessage(Remove) to achieve the same effect. This also allows us to
remove the IsIdle property, which is no longer used anywhere.
2013-12-20 08:42:36 +01:00
Stefanos A. a251617e9b Threads with message pump require STA comparment
May affect issue #19
2013-12-19 10:39:36 +01:00
Stefanos A. 93e7b896c2 Replace Wgl.GetCurrentDC with cached dc
with
2013-12-18 14:51:00 +01:00
Stefanos A. ea1dbf7f5e No point in using 16bpp color 2013-12-18 14:29:18 +01:00
Stefanos A. d8a4ca1162 Cleaned up temporary context construction
The temporary context is now retained until the actual context has been
constructed. If we don't do this, then WGL_ARB_create_context may fail
to work correctly on specific GPUs (e.g. Intel). This may affect issue
#19.
2013-12-18 14:29:06 +01:00
Stefanos A. a57b4c4270 Fixed GetModesARB implementation
The correct way to query number of available pixel formats is to use
Wgl.Arb.GetPixelFormatAttrib(NumberPixelFormatsArb), not
Wgl.Arb.ChoosePixelFormats. This fixes an issue where Intel drivers
would fail to report any pixel formats in GetModesARB, even when
WGL_ARB_pixel_format is supported.
2013-12-18 14:16:49 +01:00
Stefanos A. fb93f2af93 Minor code cleanup 2013-12-17 23:31:04 +01:00
Stefanos A. 44b8a9dbdc Use gdi32 implementations of functions
Several functions are defined in both gdi32 and opengl32. Using the
opengl32/wgl versions did not appear to help with issue #19. Let's use
the gdi32 version instead, as suggested here:
https://www.opengl.org/wiki/Platform_specifics:_Windows#The_WGL_functions
2013-12-17 22:35:30 +01:00
Stefanos A. dd31b41f08 Load opengl32.dll before gdi32.dll
According to
http://stackoverflow.com/questions/199016/wglcreatecontext-in-c-sharp-failing-but-not-in-managed-c,
opengl32.dll must be loaded before gdi32.dll. Affect issue #19.
2013-12-17 21:24:25 +01:00
Stefanos A. f4f793a5d3 Minor code cleanup
No need to wrap Wgl.DescribePixelFormat, just call it directly.
2013-12-17 16:40:15 +01:00
Stefanos A. 9129e62343 Use opengl32 instead of gdi32 throughout
Since we are dynamically loading opengl32.dll, we are supposed to use
the wgl version of functions that exist in both opengl32 and gdi32 dlls.
2013-12-17 16:39:45 +01:00
Stefanos A. 9c2db338e9 Corrected the entrypoint for wglChoosePixelFormat 2013-12-17 16:38:56 +01:00
Stefanos A. 809799aa90 Clean up shader error detection 2013-12-17 12:09:00 +01:00
Stefanos A. f4360beb74 Use 16bit depth in GraphicsMode.Default
16bits appear to be better supported than 24bits on virtual machines.
2013-12-16 10:44:37 +01:00
Stefanos A. 3c6682e080 GraphicsContext cannot be released by finalizer
On many/most platforms, GraphicsContexts can only be released by the
thread where they are current. This means that the user must call
GraphicsContext.Dispose() or risk a resource leak.

Since we cannot release contexts on the finalizer thread, we should keep
strong references, instead of weak references, until the user explicitly
calls Dispose().

This patch fixes issues with SDL2 crashing when running the MonoGame
WindowsGL test suite.
2013-12-16 10:43:56 +01:00
Stefanos A. 498f16c2bd Improved diagnostics
This helps when tracking down GraphicsContext-related issues in SDL2.
2013-12-16 10:39:54 +01:00
Stefanos A. 6ad91dcc5b Added hack for MonoGame compatibility
MonoGame uses reflection to access internal APIs. We need to keep these
available until this is fixed downstream.
2013-12-16 10:39:11 +01:00
Stefanos A. 1392d48ec0 Protect against recursion in Closing event
Misbehaving clients that shall not be named here may call
GameWindow.Close() inside the GameWindow.Closing event. This causes
recursion in SDL2, crashing the application.

This patch adds a guard to protect against recursion when calling
GameWindow.Close().
2013-12-16 10:37:59 +01:00
Stefanos A 39a216f1ac Added overloads for compatibility with svn r3127
Several projects are still using the last svn revision from the
sourceforge repository (r3127). These overloads provide an upgrade path
from r3127 to OpenTK 1.1.
2013-12-16 01:55:05 +01:00
Stefanos A 6e110cb820 Normalized xml doc file paths 2013-12-15 23:24:17 +01:00
Stefanos A a46f895cda Fixed build in Nsis configuration 2013-12-15 22:33:28 +01:00
Stefanos A 78acd27c4c Updated OpenGL documentation to Khronos r24522 2013-12-15 22:32:32 +01:00
Stefanos A 14d815dc8b Fixed deprecation warning 2013-12-15 22:02:32 +01:00
Stefanos A 0db58e36bc Eliminated cls-compliance warnings in BlittableValueType 2013-12-15 22:02:21 +01:00
Stefanos A f579d0fd81 Eliminated cls-compliance warnings in the math library 2013-12-15 22:02:08 +01:00
Stefanos A aeb7a72d79 Eliminated CLS-compliance warnings in the bindings 2013-12-15 22:01:45 +01:00
Stefanos A e9f54dc61e Fixed memory corruption on string return type marshaling 2013-12-15 20:57:25 +01:00
parallels b31e0e8474 Compatibility fixes for Mono 2.10
The Mono 2.10 compiler fails when compiling extern methods that are not
marked as DllImport. We fix that by adding a method body that throws a
NotImplementedException instead.

Additionally, MonoDevelop 2.8 cannot open sln files with ToolsVersion 12.
The fix is to change ToolsVersion to 11.
2013-12-15 18:27:24 +01:00
Stefanos A d0e52f6de7 Maintain backwards compatibility with 1.1 2013-12-15 16:58:33 +01:00
Stefanos A dfd683ef49 Merge master into no-reflect 2013-12-15 16:36:37 +01:00
Stefanos A 5b48564ec2 Ignore missing comments warning
The OpenGL manpages do not include extension methods. Ignore this
warning to let more important ones shine through.
2013-12-06 19:33:03 +01:00
Stefanos A 1d26917758 Updated license information 2013-12-06 09:23:56 +01:00
Stefanos A f1e93005b9 Added methods for 1.0 compatibility 2013-12-06 09:23:43 +01:00
Stefanos A. a4f59f7384 Split binaries for library and supporting tools
Tools now go to the Binaries/Tools/[Debug|Release] directory. OpenTK
remains at BInaries/OpenTK/[Debug|Release].

Mono.Cecil and IKVM now reside under the Dependencies/managed/
directory.
2013-12-05 18:43:47 +01:00
Stefanos A 0bdb871e90 Merge remote-tracking branch 'origin/master' into no-reflect 2013-12-05 14:53:37 +01:00
Stefanos A ca5a5b4d16 Reduce temporary string allocations
Instead of modifying the name of an OpenGL symbol on the managed side,
before copying it to the unmanaged side, we perform the modification
directly on the unmanaged side. This reduces the total amount of
allocations in OpenTK by ~30% (673496 bytes in 10750 objects compared
to 930272 bytes in 15243 objects before this modification.)
2013-12-05 11:20:58 +01:00
Stefanos A b2911267c2 Added debug arguments in release builds 2013-12-05 09:14:13 +01:00
Stefanos A d942986d17 Generate debug symbols in release builds 2013-12-05 09:13:50 +01:00
Stefanos A. 455a02299e Updated project files
Generate debug symbols on release builds. Remove unused resx file that
referenced WinForms.
2013-12-05 09:03:12 +01:00
Stefanos A e59405dab3 Implemented manual marshaling of string parameters 2013-12-04 22:32:56 +01:00
Stefanos A 7487aab4d9 Correct convenience wrapper implementation 2013-12-04 22:26:30 +01:00
Stefanos A e2801c8c6c Convert string[] callsites to IntPtr
This fixes the signature mismatch between the new marshaling code and
the callsites.
2013-12-04 21:22:33 +01:00
Stefanos A f15c9ecb95 Implemented marshaling for string arrays
This allows functions such as GL.ShaderSource to run on Mono without
crashing.
2013-12-04 20:33:19 +01:00
Stefanos A 406de0b846 Regenerated bindings 2013-12-03 09:10:45 +01:00
Stefanos A 4286b47d6f Clean up wrapper generation
We can now apply multiple WrapperTypes values to a single parameter.
2013-12-03 09:10:36 +01:00
Stefanos A e178f306eb Update WrapperTypes values for [Flags] 2013-12-03 09:09:19 +01:00
Stefanos A 33874c2d6d Removed duplicate ldarg 2013-12-03 08:59:48 +01:00
Stefanos A. ca36c6f26a Workaround for #5
WS_CLIPCHILDREN and WS_CLIPSIBLINGS appear to cause flickering on
specific video cards. OpenGL appears to work correctly without these, so
we'll disable them to return to OpenTK 1.0 behavior.
2013-12-02 23:39:36 +01:00
Stefanos A. 58ab194ba8 Fixed centering for non DPI-aware applications 2013-12-02 23:37:22 +01:00
Stefanos A. c480911843 DPI-scaling should affect resolution
The correct resolution will now be reported depending on whether the
application is DPI-aware.
2013-12-02 23:37:00 +01:00
Stefanos A. d215075bff High-resolution mode is enabled by default 2013-12-02 22:34:39 +01:00
Stefanos A. 1475b3d427 Made DPI-awareness configurable (issue #6)
It is now possible to indicate that an application is not DPI-aware. In
that case, OpenTK will let the operating system handle DPI scaling. This
results in worse visuals (pixel doubling) but allows non DPI-aware
applications to continue working.
2013-12-02 22:18:16 +01:00
Stefanos A 78c0c0d16e Removed unused code 2013-12-02 16:30:14 +01:00
Stefanos A 48efbed1e3 Added MonoDevelop project policy 2013-12-02 12:00:11 +01:00
Stefanos A d5137d6057 Initial implementation of manual StringBuilder marshaling (WIP)
The implementation is based on Marshal.AllocHGlobal and
Marshal.FreeHGlobal. This is not working correctly yet.
2013-12-02 11:59:40 +01:00
Stefanos A 45cdc2c1cd Added manual marshaling for StringBuilder
Mono fails to marshal StringBuilder arguments in unmanaged callsites
invoked through calli. We need to implement the marshaling code
ourselves.
2013-12-02 11:58:41 +01:00
Stefanos A 6ccab1784f Use StdCall calling convention by default
It appears that calli callsites cannot be decorated with the
“platformapi” calling convention like DllImport signatures can. This is
problematic since Windows uses stdcall by default and most other
platforms use cdecl.

There are three approaches to this issue, without going back to
delegate calls: (a) generate an unmanaged thunk that cleans up the
stack after a GL call; (b) use libFFI; (c) use cdecl *or* stdcall
everywhere and hope that the runtime can cope.

.Net 2.0 can detect and fix stdcall functions invoked through a cdecl
callsite. .Net 4.0 adds a configuration option to enable or disable
this fixup (faster p/invoke if disabled) and raise a MDA exception when
this condition is detected. (This affects x86 only.)

Mono appears to be able to cope with cdecl functions invoked through a
stdcall callsite.

More testing is required.
2013-12-01 21:25:03 +01:00
Stefanos A 438f83c8d9 Mark slots with [DllImport]; remove "core" and "delegates" generation
We should be able to use static pinvokes on platforms that do not
provide or require extensions and calli instructions on platforms with
extension APIs. This dinstiction will be implemented as a parameter in
the rewriter.
2013-12-01 21:17:15 +01:00
Stefanos A d6bf7c0d78 Regenerated bindings 2013-12-01 18:28:25 +01:00
Stefanos A 12c9c14133 Enabled symbol generation; minor code cleanup 2013-12-01 18:28:11 +01:00
Stefanos A 2290e06cbd Use untyped int for enums in unmanaged callsites
By using untyped integers instead of typed integers in the unmanaged
callsites, we allow monolinker to keep the exact set of enums that are
used by the user. Without this, we’d have to keep every single enum in
place to avoid missing type exceptions.

This does not affect the public signatures or the generated code in any
way.
2013-12-01 18:26:01 +01:00
Stefanos A 6f535ec095 Load system types from referenced mscorlib 2013-11-30 02:32:10 +01:00
Stefanos A. 76f0782fb1 Use C calling convention even on Windows 2013-11-30 02:16:34 +01:00
Stefanos A. 31d14cebff Corrected the handling of arrays
This includes arrays of primitives and arrays of generics. Our code is
similar to the code generated by the Mono C# compiler for the "fixed"
construct. The .Net compiler produces slightly different code (two local
variables instead of one) - more research is required.
2013-11-30 02:00:07 +01:00
Stefanos A. 0d9df5ad72 Refactored il emitters into methods 2013-11-29 19:24:38 +01:00
Stefanos A. 78c0c6fd4c Use unmanaged StdCall calling convention
Default results in a managed calling convention which does not generate
unmanaged thunking code for parameter marshaling.
System.Runtime.InteropServices.CallingConvention.Winapi appears to
correspond to StdCall for calli callsites (this might be different for
pinvoke, which supports an unmanaged "platformapi" calling convention.)
Needs more testing to prove this is doing the right thing on non-Windows
platforms.
2013-11-29 19:11:52 +01:00
Stefanos A. c6d59b1f29 Removed deleted file from project 2013-11-28 23:23:03 +01:00
Stefanos A. 0a39143b3e Removed unused WGL methods
WGL was autogenerated a few years ago but never touched after that.
Since we use a tiny fraction of all available methods, it makes sense to
remove the unused ones. This reduces dll size and improves startup
times.
2013-11-28 23:22:35 +01:00
Stefanos A. c53c0bc66f Added GetProcAddress(IntPtr) overloads
This might allow us to improve startup performance, by avoiding string
marshaling during extension loading.
2013-11-28 23:21:19 +01:00
Stefanos A. 8b8ea714ee Fixed wglGetProcAddress entry point
A typo would cause extension loading to fail. This is now fixed.
2013-11-28 09:04:08 +01:00
Stefanos A. 7775fa64aa Removed unused WGL bindings
Our WGL bindings contained dozens of methods that OpenTK did not use.
Removing these reduces the dll size and improves startup times.
2013-11-27 19:37:59 +01:00
Stefanos A. 9c7e5201db Fixed entry point validity check 2013-11-27 19:36:42 +01:00
Stefanos A. fb99c7d7a1 Enable InitLocals to make peverify happy 2013-11-27 09:16:23 +01:00
Stefanos A. e48a624003 Fixed convenience return type implementation 2013-11-27 09:09:33 +01:00
Stefanos A. ec67232e88 Corrected RewrittenAttribute definition 2013-11-27 08:45:28 +01:00
Stefanos A. f5b33b6487 Build 3.5 profile with Visual Studio 2013-11-27 08:28:39 +01:00
Stefanos A. 6bde1beb91 Rewrite nested types
Fixes zero-RVA exception for OpenGL extensions (e.g. GL.Ext etc)
2013-11-27 08:28:22 +01:00
Stefanos A. c369bfc75e Use [AutoGenerated] only for generated methods
The rewriter will patch the body of methods marked with [AutoGenerated].
Methods that are implemented manually (e.g. various math helper
overloads) should avoid this attribute.
2013-11-27 08:27:52 +01:00
Stefanos A daf5b828c9 Implemented string return types 2013-11-27 01:40:12 +01:00
Stefanos A ac65eb7b09 Added MonoDevelop artifacts 2013-11-27 00:05:26 +01:00
Stefanos A da4de365e8 Regenerated bindings 2013-11-27 00:03:21 +01:00
Stefanos A 4f58348502 Implemented convenience wrapper types 2013-11-27 00:03:03 +01:00
Stefanos A 82b0b477da Emit native signatures
The patcher uses those signatures to implement wrapper functionality
for the various wrapper types that exist in OpenTK.
2013-11-27 00:02:26 +01:00
Stefanos A bb7980b6a9 Update to latest version from git 2013-11-26 19:07:01 +01:00
Stefanos A 83868b45c6 Protect against multiple runs; optimize il 2013-11-26 19:06:39 +01:00
Stefanos A 4149cdfa88 Do not emit method bodies. 2013-11-26 01:31:29 +01:00
Stefanos A 40f992b5bd Rewrite support for [Slot] attribute 2013-11-26 01:31:10 +01:00
Stefanos A. 84a1e5a739 Initial work on Pin<> statements (WIP) 2013-11-25 20:00:22 +01:00
Stefanos A. bb15844deb Fixed build on Visual Studio 2013-11-25 10:06:10 +01:00
Stefanos A 27d5e7a43e Applied MonoDevelop project style 2013-11-25 08:54:15 +01:00
Stefanos A 997f390ec1 Corrected keyfile path 2013-11-25 08:53:44 +01:00
Stefanos A 793dac65e5 Corrected patch for CallReturn<TRet, ...> signatures
.Net will happily execute a calli with a generic return type, whereas
Mono will refuse to. Mono is probably doing the right thing here. Fixed
by resolving the generic return into a concrete type.
2013-11-25 08:53:27 +01:00
Stefanos A. 442f8b6131 Added rewrite postbuild event 2013-11-25 00:58:39 +01:00
Stefanos A. 0f609f6e22 Fixed calling convention for non-Windows platforms 2013-11-25 00:58:09 +01:00
Stefanos A. e65f206554 Fixed core loading on Windows
On Windows, entry points for OpenGL 1.0 and 1.1 are not exposed by
wglGetProcAddress. We fall back to LoadLibrary+GetProcAddress when
wglProcAddress fails.
2013-11-25 00:26:20 +01:00
Stefanos A. 0434f623e1 Added InteropHelper file 2013-11-25 00:20:22 +01:00
Stefanos A. 1868b5e3db Implemented dll rewriter using Mono.Cecil 2013-11-25 00:19:54 +01:00
Stefanos A. 74159da199 Regenerated bindings 2013-11-25 00:19:18 +01:00
Stefanos A. c8e753d2da Moved address parameter to last place
This way, it is the last item on the evaluation stack before calling the
unmanaged function pointer. This simplifies the calli rewrite procedure.
2013-11-25 00:18:43 +01:00
Stefanos A. 1e6a819b07 Removed GLObsolete.cs helper
This file must be recreated using the new loading mechanism.
2013-11-24 13:59:15 +01:00
Stefanos A. 811b04e880 Regenerated bindings with new loading mechanism 2013-11-24 13:58:54 +01:00
Stefanos A. fec958c8dc Hooked up new loading mechanism 2013-11-24 13:58:30 +01:00
Stefanos A. 657c447737 Hooked up new loading mechanism 2013-11-24 13:58:12 +01:00
Stefanos A. 825ed3621f Implemented new loading mechanism 2013-11-24 13:57:43 +01:00
Stefanos A. 7a57c9c3d2 Clarified GetAddress documentation 2013-11-24 13:57:23 +01:00
Stefanos A. 475e7ea797 Allow overriding of loading methods 2013-11-24 13:57:08 +01:00
Stefanos A. 1e71ca9122 Removed delegates and DllImports 2013-11-24 13:56:35 +01:00
Stefanos A. 2045f3e98e Add slots into entry point table 2013-11-24 13:55:13 +01:00
Stefanos A. 7b93a87bb0 Generate entry point tables 2013-11-24 13:54:52 +01:00
Stefanos A 8ee2152709 Moved delegate loaders to the Delegates class 2013-11-23 17:23:26 +01:00
Stefanos A 03a26ed12f Regenerated bindings with lazy loading 2013-11-22 20:07:01 +01:00
Stefanos A 0fea0a19b7 Added support for lazy binding loading 2013-11-22 20:06:49 +01:00
Stefanos A 5d0e7a4acf Moved GetExtensionDelegate to the correct position 2013-11-22 20:06:28 +01:00
Stefanos A ffe934fa5d Added static GetExtensionDelegate implementation 2013-11-22 20:06:04 +01:00
Stefanos A. 32a5e0fc50 Add test for new text input events 2013-11-22 18:25:30 +01:00
Elias Holzer 6ee04b2ff9 Implemented KeyPress event for Sdl2NativeWindow. 2013-11-22 18:05:11 +01:00
Elias Holzer f851d8887c Implemented KeyDown and KeyUp events for Sdl2NativeWindow. 2013-11-22 18:04:53 +01:00
Elias Holzer 38532804ec Enabled KeyDown and KeyUp events in NativeWindow. 2013-11-22 18:03:17 +01:00
Stefanos A 2ace001203 Implemented direct binding loading
OpenTK normally uses reflection to load bindings, instead of generating
huge constructors. Although reflection is faster on first load (thanks
to reduced JIT overhead), it fails to work correctly with monolinker.
This branch explores the performance of a direct binding.
2013-11-22 17:32:17 +01:00
Stefanos A. e2404d2cfc Fix "CursorVisible bugs"
When we enter the modal resize loop on Windows with ClipCursor set, we
cause a feedback loop where every resize causes the cursor to move and
every move causes a new resize. To fix this, we need to ungrab the
cursor when we are enter the modal loop.
2013-11-22 14:10:21 +01:00
Stefanos A. b7af883cff Fix exceptions on reused OpenGL context handles
Implementations may reuse OpenGL context handles that have been
destroyed. If a context is finalized but not Disposed, then OpenTK may
keep a reference to the old context handle, causing a crash when the
same handle is returned for a new context. To fix that, new context
handles will now replace old handles in case of a clash.
2013-11-21 09:34:06 +01:00
Stefanos A. 08701d318c Destroy SDL window when finalized
SDL_DestroyWindow must be called on the main thread. If the window is
finalized, the finalizer will push a CLOSE event to the event loop
(thread-safe) and the window will be destroyed on the main thread.
2013-11-21 09:31:32 +01:00
Stefanos A. 75d4f3d07c Fixed #5
We need to release the cursor before closing a GameWindow, otherwise
subsequent GameWindows may fail to receive mouse events.
2013-11-20 18:05:45 +01:00
Stefanos A. 486130c01e Toolkit.Init() now returns a concrete class
This gives us room for expansion in the future, if necessary.
2013-11-20 13:12:42 +01:00
Stefanos A. 1d19a80b53 Removed incorrect comment 2013-11-20 13:05:49 +01:00
Stefanos A. 48803bb4d6 Fixed #4
Sdl2InputDriver.Dispose() would call SDL_DelEventWatch with a different
"user_data" parameter than SDL_AdEventWatch. This caused the EventFilter
to remain registered and subsequently crash when closing and reopening a
window.
2013-11-20 09:10:12 +01:00
Stefanos A 255f4e9083 Completed compatibility overloads for OpenTK 1.0 2013-11-20 08:16:07 +01:00
Stefanos A 02120f429f Do not trim 's' from Groups 2013-11-20 08:16:06 +01:00
Stefanos A. 8c5887e996 Aligned GL core and compat enums 2013-11-18 18:51:38 +01:00
Stefanos A. a34407f440 Removed stale QuickStart project
Instead of QuickStart.sln, we should provide proper templates.
2013-11-18 18:38:03 +01:00
Stefanos A. 32828ecd8a Do not call SDL.GetVersion unless requested 2013-11-18 18:35:23 +01:00
Stefanos A 635bb85313 Reverted 'h' suffix detection
This causes too many breaking changes in the NV namespace.
2013-11-18 18:32:36 +01:00
Stefanos A ac0fab7760 More compatibility overloads for OpenGL 2013-11-18 18:32:36 +01:00
Stefanos A 5d4c42672f Improved suffix detection. Support index-based parameter overloading. 2013-11-18 18:32:34 +01:00
Stefanos A. e7f70330b2 Implemented IEquatable<ColorFormat>
This eliminates memory allocations when storing and comparing
ColorFormat structures.
2013-11-18 13:49:06 +01:00
Stefanos A 3d50554903 Added OpenGL overloads for OpenTK-1.0 compatibility 2013-11-18 13:28:44 +01:00
Stefanos A e572f418af Added compatibility overloads for ES 2.0 2013-11-18 01:10:01 +01:00
Stefanos A 01d40c551a Aligned FBO API with desktop OpenGL 2013-11-17 23:57:38 +01:00