Commit graph

5284 commits

Author SHA1 Message Date
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