diff --git a/ClassicalSharp/Entities/Entity.cs b/ClassicalSharp/Entities/Entity.cs index 48bbac204..d061ded63 100644 --- a/ClassicalSharp/Entities/Entity.cs +++ b/ClassicalSharp/Entities/Entity.cs @@ -34,7 +34,7 @@ namespace ClassicalSharp { public virtual Vector3 CollisionSize { get { return new Vector3( 8/16f, 28.5f/16f, 8/16f ); - //Model.CollisionSize; TODO: for non humanoid models, we also need to offset eye position. + //Model.CollisionSize; TODO: for non humanoid models } } diff --git a/OpenTK/Platform/Windows/API.cs b/OpenTK/Platform/Windows/API.cs index 78579c9c0..a60190f64 100644 --- a/OpenTK/Platform/Windows/API.cs +++ b/OpenTK/Platform/Windows/API.cs @@ -613,28 +613,6 @@ namespace OpenTK.Platform.Windows { DECIMAL = 0x6E, DIVIDE = 0x6F, F1 = 0x70, - F2 = 0x71, - F3 = 0x72, - F4 = 0x73, - F5 = 0x74, - F6 = 0x75, - F7 = 0x76, - F8 = 0x77, - F9 = 0x78, - F10 = 0x79, - F11 = 0x7A, - F12 = 0x7B, - F13 = 0x7C, - F14 = 0x7D, - F15 = 0x7E, - F16 = 0x7F, - F17 = 0x80, - F18 = 0x81, - F19 = 0x82, - F20 = 0x83, - F21 = 0x84, - F22 = 0x85, - F23 = 0x86, F24 = 0x87, NUMLOCK = 0x90, diff --git a/OpenTK/Platform/X11/API.cs b/OpenTK/Platform/X11/API.cs index 9d3bee3cc..ffd658570 100644 --- a/OpenTK/Platform/X11/API.cs +++ b/OpenTK/Platform/X11/API.cs @@ -191,41 +191,7 @@ namespace OpenTK.Platform.X11 { * function key groups on the left and/or right sides of the keyboard. * We've not found a keyboard with more than 35 function keys total. */ - F1 = 0xffbe, - F2 = 0xffbf, - F3 = 0xffc0, - F4 = 0xffc1, - F5 = 0xffc2, - F6 = 0xffc3, - F7 = 0xffc4, - F8 = 0xffc5, - F9 = 0xffc6, - F10 = 0xffc7, - F11 = 0xffc8, - F12 = 0xffc9, - F13 = 0xffca, - F14 = 0xffcb, - F15 = 0xffcc, - F16 = 0xffcd, - F17 = 0xffce, - F18 = 0xffcf, - F19 = 0xffd0, - F20 = 0xffd1, - F21 = 0xffd2, - F22 = 0xffd3, - F23 = 0xffd4, - F24 = 0xffd5, - F25 = 0xffd6, - F26 = 0xffd7, - F27 = 0xffd8, - F28 = 0xffd9, - F29 = 0xffda, - F30 = 0xffdb, - F31 = 0xffdc, - F32 = 0xffdd, - F33 = 0xffde, - F34 = 0xffdf, F35 = 0xffe0, /* Modifiers */ @@ -243,8 +209,6 @@ namespace OpenTK.Platform.X11 { Alt_R = 0xffea, /* Right alt */ Super_L = 0xffeb, /* Left super */ Super_R = 0xffec, /* Right super */ - Hyper_L = 0xffed, /* Left hyper */ - Hyper_R = 0xffee, /* Right hyper */ /* * Latin 1 @@ -269,15 +233,15 @@ namespace OpenTK.Platform.X11 { minus = 0x002d, /* U+002D HYPHEN-MINUS */ period = 0x002e, /* U+002E FULL STOP */ slash = 0x002f, /* U+002F SOLIDUS */ - Number0 = 0x0030, /* U+0030 DIGIT ZERO */ - Number1 = 0x0031, /* U+0031 DIGIT ONE */ - Number2 = 0x0032, /* U+0032 DIGIT TWO */ - Number3 = 0x0033, /* U+0033 DIGIT THREE */ - Number4 = 0x0034, /* U+0034 DIGIT FOUR */ - Number5 = 0x0035, /* U+0035 DIGIT FIVE */ - Number6 = 0x0036, /* U+0036 DIGIT SIX */ - Number7 = 0x0037, /* U+0037 DIGIT SEVEN */ - Number8 = 0x0038, /* U+0038 DIGIT EIGHT */ + Number0 = 0x0030, /* U+0030 DIGIT ZERO */ + Number1 = 0x0031, /* U+0031 DIGIT ONE */ + Number2 = 0x0032, /* U+0032 DIGIT TWO */ + Number3 = 0x0033, /* U+0033 DIGIT THREE */ + Number4 = 0x0034, /* U+0034 DIGIT FOUR */ + Number5 = 0x0035, /* U+0035 DIGIT FIVE */ + Number6 = 0x0036, /* U+0036 DIGIT SIX */ + Number7 = 0x0037, /* U+0037 DIGIT SEVEN */ + Number8 = 0x0038, /* U+0038 DIGIT EIGHT */ Number9 = 0x0039, /* U+0039 DIGIT NINE */ colon = 0x003a, /* U+003A COLON */ semicolon = 0x003b, /* U+003B SEMICOLON */ @@ -287,30 +251,6 @@ namespace OpenTK.Platform.X11 { question = 0x003f, /* U+003F QUESTION MARK */ at = 0x0040, /* U+0040 COMMERCIAL AT */ A = 0x0041, /* U+0041 LATIN CAPITAL LETTER A */ - B = 0x0042, /* U+0042 LATIN CAPITAL LETTER B */ - C = 0x0043, /* U+0043 LATIN CAPITAL LETTER C */ - D = 0x0044, /* U+0044 LATIN CAPITAL LETTER D */ - E = 0x0045, /* U+0045 LATIN CAPITAL LETTER E */ - F = 0x0046, /* U+0046 LATIN CAPITAL LETTER F */ - G = 0x0047, /* U+0047 LATIN CAPITAL LETTER G */ - H = 0x0048, /* U+0048 LATIN CAPITAL LETTER H */ - I = 0x0049, /* U+0049 LATIN CAPITAL LETTER I */ - J = 0x004a, /* U+004A LATIN CAPITAL LETTER J */ - K = 0x004b, /* U+004B LATIN CAPITAL LETTER K */ - L = 0x004c, /* U+004C LATIN CAPITAL LETTER L */ - M = 0x004d, /* U+004D LATIN CAPITAL LETTER M */ - N = 0x004e, /* U+004E LATIN CAPITAL LETTER N */ - O = 0x004f, /* U+004F LATIN CAPITAL LETTER O */ - P = 0x0050, /* U+0050 LATIN CAPITAL LETTER P */ - Q = 0x0051, /* U+0051 LATIN CAPITAL LETTER Q */ - R = 0x0052, /* U+0052 LATIN CAPITAL LETTER R */ - S = 0x0053, /* U+0053 LATIN CAPITAL LETTER S */ - T = 0x0054, /* U+0054 LATIN CAPITAL LETTER T */ - U = 0x0055, /* U+0055 LATIN CAPITAL LETTER U */ - V = 0x0056, /* U+0056 LATIN CAPITAL LETTER V */ - W = 0x0057, /* U+0057 LATIN CAPITAL LETTER W */ - X = 0x0058, /* U+0058 LATIN CAPITAL LETTER X */ - Y = 0x0059, /* U+0059 LATIN CAPITAL LETTER Y */ Z = 0x005a, /* U+005A LATIN CAPITAL LETTER Z */ bracketleft = 0x005b, /* U+005B LEFT SQUARE BRACKET */ backslash = 0x005c, /* U+005C REVERSE SOLIDUS */ @@ -320,30 +260,6 @@ namespace OpenTK.Platform.X11 { grave = 0x0060, /* U+0060 GRAVE ACCENT */ quoteleft = 0x0060, /* deprecated */ a = 0x0061, /* U+0061 LATIN SMALL LETTER A */ - b = 0x0062, /* U+0062 LATIN SMALL LETTER B */ - c = 0x0063, /* U+0063 LATIN SMALL LETTER C */ - d = 0x0064, /* U+0064 LATIN SMALL LETTER D */ - e = 0x0065, /* U+0065 LATIN SMALL LETTER E */ - f = 0x0066, /* U+0066 LATIN SMALL LETTER F */ - g = 0x0067, /* U+0067 LATIN SMALL LETTER G */ - h = 0x0068, /* U+0068 LATIN SMALL LETTER H */ - i = 0x0069, /* U+0069 LATIN SMALL LETTER I */ - j = 0x006a, /* U+006A LATIN SMALL LETTER J */ - k = 0x006b, /* U+006B LATIN SMALL LETTER K */ - l = 0x006c, /* U+006C LATIN SMALL LETTER L */ - m = 0x006d, /* U+006D LATIN SMALL LETTER M */ - n = 0x006e, /* U+006E LATIN SMALL LETTER N */ - o = 0x006f, /* U+006F LATIN SMALL LETTER O */ - p = 0x0070, /* U+0070 LATIN SMALL LETTER P */ - q = 0x0071, /* U+0071 LATIN SMALL LETTER Q */ - r = 0x0072, /* U+0072 LATIN SMALL LETTER R */ - s = 0x0073, /* U+0073 LATIN SMALL LETTER S */ - t = 0x0074, /* U+0074 LATIN SMALL LETTER T */ - u = 0x0075, /* U+0075 LATIN SMALL LETTER U */ - v = 0x0076, /* U+0076 LATIN SMALL LETTER V */ - w = 0x0077, /* U+0077 LATIN SMALL LETTER W */ - x = 0x0078, /* U+0078 LATIN SMALL LETTER X */ - y = 0x0079, /* U+0079 LATIN SMALL LETTER Y */ z = 0x007a, /* U+007A LATIN SMALL LETTER Z */ braceleft = 0x007b, /* U+007B LEFT CURLY BRACKET */ bar = 0x007c, /* U+007C VERTICAL LINE */ diff --git a/OpenTK/Platform/X11/Functions.cs b/OpenTK/Platform/X11/Functions.cs index cadad461f..c1a549eb2 100644 --- a/OpenTK/Platform/X11/Functions.cs +++ b/OpenTK/Platform/X11/Functions.cs @@ -23,15 +23,9 @@ using KeyCode = System.Byte; // Or maybe ushort? namespace OpenTK.Platform.X11 { internal static class API { - internal static readonly object Lock = new object(); [DllImport("libX11"), SuppressUnmanagedCodeSecurity] public extern static IntPtr XOpenDisplay(IntPtr display); - public static IntPtr XOpenDisplay_Safe(IntPtr display) { - lock (Lock) { - return XOpenDisplay(display); - } - } [DllImport("libX11"), SuppressUnmanagedCodeSecurity] public extern static int XCloseDisplay(IntPtr display); @@ -354,28 +348,25 @@ namespace OpenTK.Platform.X11 { depths[i] = *data++; return depths; } - - static Display defaultDisplay; - static int screenCount; - internal static Display DefaultDisplay { get { return defaultDisplay; } } - internal static int ScreenCount { get { return screenCount; } } + internal static Display DefaultDisplay; + internal static int ScreenCount; static API() { - defaultDisplay = API.XOpenDisplay_Safe(IntPtr.Zero); - if (defaultDisplay == IntPtr.Zero) + DefaultDisplay = API.XOpenDisplay(IntPtr.Zero); + if (DefaultDisplay == IntPtr.Zero) throw new PlatformException("Could not establish connection to the X-Server."); - screenCount = API.XScreenCount(DefaultDisplay); + ScreenCount = API.XScreenCount(DefaultDisplay); Debug.Print("Display connection: {0}, Screen count: {1}", DefaultDisplay, ScreenCount); //AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); } static void CurrentDomain_ProcessExit(object sender, EventArgs e) { - if (defaultDisplay != IntPtr.Zero) { - API.XCloseDisplay(defaultDisplay); - defaultDisplay = IntPtr.Zero; + if (DefaultDisplay != IntPtr.Zero) { + API.XCloseDisplay(DefaultDisplay); + DefaultDisplay = IntPtr.Zero; } } diff --git a/OpenTK/Platform/X11/X11DisplayDevice.cs b/OpenTK/Platform/X11/X11DisplayDevice.cs index fd9b37fe7..7b43b87cd 100644 --- a/OpenTK/Platform/X11/X11DisplayDevice.cs +++ b/OpenTK/Platform/X11/X11DisplayDevice.cs @@ -110,8 +110,7 @@ namespace OpenTK.Platform.X11 { Debug.Print("[Warning] XRandR returned an invalid resolution ({0}) for display device {1}", size, screen); continue; } - short[] rates = null; - rates = API.XRRRates(API.DefaultDisplay, screen, resolution_count); + short[] rates = API.XRRRates(API.DefaultDisplay, screen, resolution_count); // It seems that XRRRates returns 0 for modes that are larger than the screen // can support, as well as for all supported modes. On Ubuntu 7.10 the tool @@ -172,11 +171,10 @@ namespace OpenTK.Platform.X11 { } static float FindCurrentRefreshRate(int screen) { - short rate = 0; IntPtr screen_config = API.XRRGetScreenInfo(API.DefaultDisplay, API.XRootWindow(API.DefaultDisplay, screen)); ushort rotation = 0; int size = API.XRRConfigCurrentConfiguration(screen_config, out rotation); - rate = API.XRRConfigCurrentRate(screen_config); + short rate = API.XRRConfigCurrentRate(screen_config); API.XRRFreeScreenConfigInfo(screen_config); return (float)rate; } diff --git a/OpenTK/Platform/X11/X11GLContext.cs b/OpenTK/Platform/X11/X11GLContext.cs index d1798e751..870aaecf9 100644 --- a/OpenTK/Platform/X11/X11GLContext.cs +++ b/OpenTK/Platform/X11/X11GLContext.cs @@ -71,14 +71,12 @@ namespace OpenTK.Platform.X11 { info.Screen = currentWindow.Screen; int items; - lock (API.Lock) { - IntPtr vs = API.XGetVisualInfo(Display, XVisualInfoMask.ID | XVisualInfoMask.Screen, ref info, out items); - if (items == 0) - throw new GraphicsModeException(String.Format("Invalid GraphicsMode specified ({0}).", mode)); + IntPtr vs = API.XGetVisualInfo(Display, XVisualInfoMask.ID | XVisualInfoMask.Screen, ref info, out items); + if (items == 0) + throw new GraphicsModeException(String.Format("Invalid GraphicsMode specified ({0}).", mode)); - info = (XVisualInfo)Marshal.PtrToStructure(vs, typeof(XVisualInfo)); - API.XFree(vs); - } + info = (XVisualInfo)Marshal.PtrToStructure(vs, typeof(XVisualInfo)); + API.XFree(vs); return info; } diff --git a/OpenTK/Platform/X11/X11GLNative.cs b/OpenTK/Platform/X11/X11GLNative.cs index 757b1625d..088a83497 100644 --- a/OpenTK/Platform/X11/X11GLNative.cs +++ b/OpenTK/Platform/X11/X11GLNative.cs @@ -45,8 +45,6 @@ namespace OpenTK.Platform.X11 { const int _min_width = 30, _min_height = 30; X11WindowInfo window = new X11WindowInfo(); - - const string MOTIF_WM_ATOM = "_MOTIF_WM_HINTS"; // The Atom class from Mono might be useful to avoid calling XInternAtom by hand (somewhat error prone). IntPtr wm_destroy; @@ -63,6 +61,7 @@ namespace OpenTK.Platform.X11 { IntPtr net_wm_icon; IntPtr net_frame_extents; + IntPtr motif_wm_hints; static readonly IntPtr xa_cardinal = (IntPtr)6; static readonly IntPtr _remove = (IntPtr)0; @@ -102,7 +101,7 @@ namespace OpenTK.Platform.X11 { Debug.Print("Creating X11GLNative window."); // Open a display connection to the X server, and obtain the screen and root window. - window.Display = API.XOpenDisplay_Safe(IntPtr.Zero); + window.Display = API.DefaultDisplay; if (window.Display == IntPtr.Zero) throw new PlatformException("Could not open connection to X"); @@ -211,6 +210,7 @@ namespace OpenTK.Platform.X11 { net_wm_action_maximize_vertically = API.XInternAtom(window.Display, "_NET_WM_ACTION_MAXIMIZE_VERT", false); net_wm_icon = API.XInternAtom(window.Display, "_NEW_WM_ICON", false); net_frame_extents = API.XInternAtom(window.Display, "_NET_FRAME_EXTENTS", false); + motif_wm_hints = API.XInternAtom(window.Display, "_MOTIF_WM_HINTS", true); } void SetWindowMinMax(short min_width, short min_height, short max_width, short max_height) { @@ -253,11 +253,8 @@ namespace OpenTK.Platform.X11 { bool IsWindowBorderHidden { get { - IntPtr prop = IntPtr.Zero; - // Test if decorations have been disabled through Motif. - IntPtr motif_hints_atom = API.XInternAtom(this.window.Display, MOTIF_WM_ATOM, true); - if (motif_hints_atom != IntPtr.Zero) { + if (motif_wm_hints != IntPtr.Zero) { // TODO: How to check if MotifWMHints decorations have been really disabled? if (_decorations_hidden) return true; @@ -291,7 +288,7 @@ namespace OpenTK.Platform.X11 { } bool DisableMotifDecorations() { - IntPtr atom = API.XInternAtom(this.window.Display, MOTIF_WM_ATOM, true); + IntPtr atom = motif_wm_hints; if (atom != IntPtr.Zero) { //Functions.XGetWindowProperty(window.Display, window.WindowHandle, atom, IntPtr.Zero, IntPtr.Zero, false, MotifWmHints hints = new MotifWmHints(); @@ -317,7 +314,7 @@ namespace OpenTK.Platform.X11 { } bool EnableMotifDecorations() { - IntPtr atom = API.XInternAtom(this.window.Display, MOTIF_WM_ATOM, true); + IntPtr atom = motif_wm_hints; if (atom != IntPtr.Zero) { //Functions.XDeleteProperty(this.window.Display, this.Handle, atom); MotifWmHints hints = new MotifWmHints(); @@ -365,11 +362,6 @@ namespace OpenTK.Platform.X11 { borderRight = Marshal.ReadIntPtr(prop, IntPtr.Size).ToInt32(); borderTop = Marshal.ReadIntPtr(prop, IntPtr.Size * 2).ToInt32(); borderBottom = Marshal.ReadIntPtr(prop, IntPtr.Size * 3).ToInt32(); - - //Debug.WriteLine(border_left); - //Debug.WriteLine(border_right); - //Debug.WriteLine(border_top); - //Debug.WriteLine(border_bottom); } API.XFree(prop); } @@ -390,7 +382,7 @@ namespace OpenTK.Platform.X11 { Size newSize = new Size( e.ConfigureEvent.width + borderLeft + borderRight, e.ConfigureEvent.height + borderTop + borderBottom); - if (Bounds.Size != newSize) { + if (bounds.Size != newSize) { bounds.Size = newSize; client_rectangle.Size = new Size(e.ConfigureEvent.width, e.ConfigureEvent.height); diff --git a/OpenTK/Platform/X11/X11GraphicsMode.cs b/OpenTK/Platform/X11/X11GraphicsMode.cs index 829bac4a4..97ea4161a 100644 --- a/OpenTK/Platform/X11/X11GraphicsMode.cs +++ b/OpenTK/Platform/X11/X11GraphicsMode.cs @@ -65,7 +65,7 @@ namespace OpenTK.Platform.X11 // See http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.opengl/doc/openglrf/glXChooseFBConfig.htm // for the attribute declarations. Note that the attributes are different than those used in Glx.ChooseVisual. - IntPtr SelectVisualUsingFBConfig( int[] visualAttribs ) { + unsafe IntPtr SelectVisualUsingFBConfig( int[] visualAttribs ) { // Select a visual that matches the parameters set by the user. IntPtr display = API.DefaultDisplay; IntPtr visual = IntPtr.Zero; @@ -74,18 +74,15 @@ namespace OpenTK.Platform.X11 IntPtr root = API.XRootWindow(display, screen); Debug.Print("Display: {0}, Screen: {1}, RootWindow: {2}", display, screen, root); - unsafe + Debug.Print("Getting FB config."); + int fbcount; + // Note that ChooseFBConfig returns an array of GLXFBConfig opaque structures (i.e. mapped to IntPtrs). + IntPtr* fbconfigs = Glx.glXChooseFBConfig(display, screen, visualAttribs, out fbcount); + if (fbcount > 0 && fbconfigs != null) { - Debug.Print("Getting FB config."); - int fbcount; - // Note that ChooseFBConfig returns an array of GLXFBConfig opaque structures (i.e. mapped to IntPtrs). - IntPtr* fbconfigs = Glx.glXChooseFBConfig(display, screen, visualAttribs, out fbcount); - if (fbcount > 0 && fbconfigs != null) - { - // We want to use the first GLXFBConfig from the fbconfigs array (the first one is the best match). - visual = Glx.glXGetVisualFromFBConfig(display, *fbconfigs); - API.XFree((IntPtr)fbconfigs); - } + // We want to use the first GLXFBConfig from the fbconfigs array (the first one is the best match). + visual = Glx.glXGetVisualFromFBConfig(display, *fbconfigs); + API.XFree((IntPtr)fbconfigs); } } catch (EntryPointNotFoundException) { Debug.Print("Function glXChooseFBConfig not supported.");