Commit graph

3142 commits

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