public void Show() { if (_x11Extensions == null) { throw new InvalidOperationException("No Graphics API implementation in use"); } var display = Marshal.PtrToStructure <X11.XDisplay>(NativeHandle); var screen = Marshal.PtrToStructure <X11.Screen>(display.screens + display.default_screen); var visualInfo = _x11Extensions.GetVisualInfo(display); var visual = Marshal.PtrToStructure <X11.Visual>(visualInfo.visual); var cmap = X11.XCreateColormap(NativeHandle, screen.root, ref visual, 0 /*AllocNone*/); var windowAttributes = new X11.XSetWindowAttributes { colormap = cmap, event_mask = EventMask }; WindowId = X11.XCreateWindow(NativeHandle, screen.root, 0, 0, (uint)Width, (uint)Height, 0, visualInfo.depth, 1, ref visual, 1L << 13 /*CWColormap*/ | 1L << 11 /*CWEventMask*/, ref windowAttributes); X11.XMapWindow(NativeHandle, WindowId); X11.XStoreName(NativeHandle, WindowId, _title); //Attach events var wmResize = X11.XInternAtom(NativeHandle, "WM_SIZE_HINTS", true); _wmDelete = X11.XInternAtom(NativeHandle, "WM_DELETE_WINDOW", true); var events = new[] { wmResize, _wmDelete }; X11.XSetWMProtocols(NativeHandle, WindowId, events, events.Length); }
public void X11_Hash_Should_Match() { var hasher = new X11(); var result = hasher.Digest(testValue).ToHexString(); Assert.Equal("a5c7a5b1f019fab056867b53b2ca349555847082da8ec26c85066e7cb1f76559", result); }
/// <summary> /// Processes XMotionEvents. /// </summary> /// <param name="e">The X11.XMotionEvent to process.</param> /// <returns>True if the event was processed, false otherwise.</returns> internal bool ProcessMotion(ref X11.XMotionEvent e) { MouseDevice m = mice[0]; m.X = e.x; m.Y = e.y; return true; }
internal X11Window(string title, int width, int height) { _title = title; Width = width; Height = height; NativeHandle = X11.XOpenDisplay(null); Keys = new UnixKeys(NativeHandle); EventPtr = Marshal.AllocHGlobal(Marshal.SizeOf <XEvent>()); }
public void x11() { var bytes = Encoders.Hex.DecodeData("010000000000000000000000000000000000000000000000000000000000000000000000c762a6567f3cc092f0684bb62b7e00a84890b990f07cc71a6bb58d64b98e02e0022ddb52f0ff0f1ec23fb901"); var hashBytes = new X11().ComputeBytes(bytes).ToArray(); var hash = Encoders.Hex.EncodeData(hashBytes.Reverse().ToArray()); Assert.Equal("00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6", hash); }
/// <summary> /// Processes XButtonEvents. /// </summary> /// <param name="e">The X11.XButtonEvent to process.</param> /// <returns>True if the event was processed, false otherwise.</returns> internal bool ProcessButton(ref X11.XButtonEvent e) { MouseDevice m = mice[0]; bool pressed = e.type == XEventName.ButtonPress; //e. if ((e.state & (int)X11.MouseMask.Button1Mask) != 0) m[OpenTK.Input.MouseButton.Left] = pressed; if ((e.state & (int)X11.MouseMask.Button2Mask) != 0) m[OpenTK.Input.MouseButton.Middle] = pressed; if ((e.state & (int)X11.MouseMask.Button3Mask) != 0) m[OpenTK.Input.MouseButton.Right] = pressed; if ((e.state & (int)X11.MouseMask.Button4Mask) != 0) m.Wheel++; if ((e.state & (int)X11.MouseMask.Button5Mask) != 0) m.Wheel--; return true; }
public static void InitForToolkit() { if (Environment.OSVersion.Platform == PlatformID.Unix) { X11.SetDisplay(Gdk.Display.Default); X11.DisableEventRetrieval(); } else { Win32.DisableEventRetrieval(); } Init(); }
public bool GetCursorPosition(out Point position) { if (X11.XQueryPointer(NativeHandle, WindowId, out _, out _, out _, out _, out var winX, out var winY, out _)) { position = new Point { X = winX, Y = winY }; return(true); } position = default; return(false); }
public Window(uint width, uint height) { this.width = width; this.height = height; display = X11.XOpenDisplay(0); IntPtr root = X11.XDefaultRootWindow(display); screen = X11.XDefaultScreen(display); window = X11.XCreateSimpleWindow(display, root, 0, 0, width, height, (ulong)0, X11.XWhitePixel(display, screen), X11.XWhitePixel(display, screen)); }
static void Main(string [] args) { Window win = new Window(500, 500); win.Show(); Cairo.XlibSurface s = new Cairo.XlibSurface(win.Display, win.XWindow, X11.XDefaultVisual(win.Display, win.Screen), (int)win.Width, (int)win.Height); Cairo.Context g = new Cairo.Context(s); draw(g, 500, 500); IntPtr xev = new IntPtr(); while (true) { X11.XNextEvent(win.Display, xev); } }
/// <summary> /// Processes X11 KeyEvents. /// </summary> /// <param name="e">The X11.KeyEvent to process</param> /// <returns>True if the event was processed, false otherwise.</returns> internal bool ProcessKeyboardEvent(ref X11.XKeyEvent e) { //int keysym = keysyms[(e.keycode - firstKeyCode) * keysyms_per_keycode].ToInt32(); //int keysym2 = keysyms[(e.keycode - firstKeyCode) * keysyms_per_keycode].ToInt32(); bool pressed = e.type == XEventName.KeyPress; IntPtr keysym = API.LookupKeysym(ref e, 0); IntPtr keysym2 = API.LookupKeysym(ref e, 1); //Debug.Print("Key down: {0}", e.ToString()); int index = keyboards.FindIndex(delegate(KeyboardDevice kb) { return kb.DeviceID == IntPtr.Zero; }); switch (keysym.ToInt64()) { default: if (keymap.ContainsKey((XKey)keysym)) { keyboards[index][keymap[(XKey)keysym]] = pressed; } else if (keymap.ContainsKey((XKey)keysym2)) { keyboards[index][keymap[(XKey)keysym2]] = pressed; } else { //Debug.Print("KeyCode {0} (Keysym: {1}, {2}) not mapped.", e.keycode, (XKey)keysym, (XKey)keysym2); return false; } return true; } }
public void X11_Hash_Should_Throw_On_Null_Input() { var hasher = new X11(); Assert.Throws <ArgumentNullException>(() => hasher.Digest(null)); }
public unsafe override void Dispose() { if (disposed) { return; } disposed = true; disposeChilderen(); #if NaCl PPAPI.StopSwapBufferLoop(); #endif if (dc != IntPtr.Zero) { DisableContext(); } #if WIN32 if (dc != IntPtr.Zero) { if (ctx != IntPtr.Zero) { WGL.DeleteContext(ctx); ctx = IntPtr.Zero; } if (handle != IntPtr.Zero) { WGL.ReleaseDC(handle, dc); handle = IntPtr.Zero; } dc = IntPtr.Zero; } #endif #if RPI if (dc != IntPtr.Zero) { if (surface != IntPtr.Zero) { EGL.DestroySurface(dc, surface); } if (ctx != IntPtr.Zero) { EGL.DestroyContext(dc, ctx); } EGL.Terminate(dc); dc = IntPtr.Zero; } RaspberryPi.bcm_host_deinit(); windowHandle.Free(); #elif LINUX if (dc != IntPtr.Zero) { if (ctx != IntPtr.Zero) { GLX.DestroyContext(dc, ctx); ctx = IntPtr.Zero; } X11.XCloseDisplay(dc); dc = IntPtr.Zero; } #endif #if OSX if (dc != IntPtr.Zero) { if (ctx != IntPtr.Zero) { CGL.DestroyContext(ctx); ctx = IntPtr.Zero; } CGL.ReleaseAllDisplays(); dc = IntPtr.Zero; } #endif base.Dispose(); }
public Video(IDisposableResource parent, IApplication application, DepthStencilFormats depthStencilFormats, bool vSync) : base(parent) { try { int depthBit = 16, stencilBit = 0; switch (depthStencilFormats) { case DepthStencilFormats.None: depthBit = 0; stencilBit = 0; break; case DepthStencilFormats.Defualt: #if iOS || ANDROID || NaCl || RPI depthBit = 16; stencilBit = 0; #else depthBit = 24; stencilBit = 0; #endif break; case DepthStencilFormats.Depth24Stencil8: depthBit = 24; stencilBit = 8; break; case DepthStencilFormats.Depth16: depthBit = 16; stencilBit = 0; break; case DepthStencilFormats.Depth24: depthBit = 24; stencilBit = 0; break; case DepthStencilFormats.Depth32: depthBit = 32; stencilBit = 0; break; default: Debug.ThrowError("Video", "Unsuported DepthStencilFormat type"); break; } currentTextures = new Texture2D[8]; currentSamplerStates = new SamplerState[8]; #if WIN32 || OSX || LINUX || NaCl BackBufferSize = application.FrameSize; this.application = application; #else BackBufferSize = application.FrameSize; this.application = application; #endif #if WIN32 //Get DC handle = application.Handle; dc = WGL.GetDC(handle); WGL.SwapBuffers(dc); //Set BackBuffer format WGL.PIXELFORMATDESCRIPTOR pfd = new WGL.PIXELFORMATDESCRIPTOR(); WGL.ZeroPixelDescriptor(ref pfd); pfd.nVersion = 1; pfd.dwFlags = WGL.PFD_DRAW_TO_WINDOW | WGL.PFD_SUPPORT_OPENGL | WGL.PFD_DOUBLEBUFFER; pfd.iPixelType = (byte)WGL.PFD_TYPE_RGBA; //pfd.cColorBits = 24; //pfd.cAlphaBits = 8; pfd.cDepthBits = (byte)depthBit; pfd.cStencilBits = (byte)stencilBit; pfd.iLayerType = (byte)WGL.PFD_MAIN_PLANE; unsafe { pfd.nSize = (ushort)sizeof(WGL.PIXELFORMATDESCRIPTOR); } int pixelFormatIndex = WGL.ChoosePixelFormat(dc, ref pfd); if (pixelFormatIndex == 0) { Debug.ThrowError("Video", "ChoosePixelFormat failed"); } if (WGL.SetPixelFormat(dc, pixelFormatIndex, ref pfd) == 0) { Debug.ThrowError("Video", "Failed to set PixelFormat"); } ctx = WGL.CreateContext(dc); if (ctx == IntPtr.Zero) { Debug.ThrowError("Video", "Failed to create GL context"); } if (WGL.MakeCurrent(dc, ctx) == 0) { Debug.ThrowError("Video", "Failed to make GL context current"); } WGL.Init(); WGL.SwapInterval(vSync ? 1 : 0); // -1 for smart vsync #endif #if RPI unsafe { // Init Pi video RaspberryPi.bcm_host_init(); const int piDisplay = 0; uint piWidth = 0, piHeight = 0; if (RaspberryPi.graphics_get_display_size(piDisplay, &piWidth, &piHeight) < 0) { Debug.ThrowError("Video", "Failed to get display size"); } Console.WriteLine("piWidth - " + piWidth); Console.WriteLine("piHeight - " + piHeight); BackBufferSize = new Size2((int)piWidth, (int)piHeight); IntPtr dispman_display = RaspberryPi.vc_dispmanx_display_open(piDisplay); if (dispman_display == IntPtr.Zero) { Debug.ThrowError("Video", "Failed: vc_dispmanx_display_open"); } IntPtr dispman_update = RaspberryPi.vc_dispmanx_update_start(0); if (dispman_update == IntPtr.Zero) { Debug.ThrowError("Video", "Failed: vc_dispmanx_update_start"); } var dstRect = new RaspberryPi.VC_RECT_T() { x = 0, y = 0, width = (int)piWidth, height = (int)piHeight }; var srcRect = new RaspberryPi.VC_RECT_T() { x = 0, y = 0, width = ((int)piWidth) << 16, height = ((int)piHeight) << 16 }; IntPtr dispman_element = RaspberryPi.vc_dispmanx_element_add(dispman_update, dispman_display, 0, &dstRect, IntPtr.Zero, &srcRect, RaspberryPi.DISPMANX_PROTECTION_NONE, IntPtr.Zero, IntPtr.Zero, 0); if (dispman_element == IntPtr.Zero) { Debug.ThrowError("Video", "Failed: vc_dispmanx_element_add"); } nativeWindow = new RaspberryPi.DISPMANX_WINDOW_T() { element = dispman_element, width = (int)piWidth, height = (int)piHeight }; windowHandle = GCHandle.Alloc(nativeWindow, GCHandleType.Pinned); RaspberryPi.vc_dispmanx_update_submit_sync(dispman_update); // Init EGL handle = application.Handle; GL.GetError(); //NOTE: THIS MUST BE HERE SO THAT libGLES LOADS BEFORE libEGL dc = EGL.GetDisplay(IntPtr.Zero); int major, minor; if (!EGL.Initialize(dc, out major, out minor)) { Debug.ThrowError("Video", string.Format("Failed to initialize display connection, Error {0}", EGL.GetError())); } int[] pixelFormat = new int[] { //EGL.RENDERABLE_TYPE, EGL.OPENGL_ES2_BIT, //EGL.RED_SIZE, 5, //EGL.GREEN_SIZE, 6, //EGL.BLUE_SIZE, 5, //EGL.ALPHA_SIZE, 0,//EGL.DONT_CARE, EGL.SURFACE_TYPE, EGL.WINDOW_BIT, EGL.DEPTH_SIZE, depthBit, //EGL.STENCIL_SIZE, stencilBit,//EGL.DONT_CARE,//<<<<<<<<<< Test enabling this! //EGL.SAMPLE_BUFFERS, 0, //EGL.SAMPLES, 0, //EGL.MIN_SWAP_INTERVAL, 0, //EGL.MAX_SWAP_INTERVAL, 1, EGL.NONE, }; int num_configs; var configs = new IntPtr(); if (EGL.ChooseConfig(dc, pixelFormat, &configs, 1, &num_configs) == 0 || num_configs == 0) { Debug.ThrowError("Video", string.Format("Failed to retrieve GraphicsMode, error {0}", EGL.GetError())); } if (EGL.BindAPI(EGL.OPENGL_ES_API) == 0) { Debug.ThrowError("Video", "Failed to bind GLES API"); } ; int[] attrib_list = new int[] { EGL.CONTEXT_CLIENT_VERSION, 2, EGL.NONE }; ctx = EGL.CreateContext(dc, configs, IntPtr.Zero, attrib_list); if (ctx == IntPtr.Zero) { Debug.ThrowError("Video", "Failed to create context"); } surface = EGL.CreateWindowSurface(dc, configs, windowHandle.AddrOfPinnedObject(), null); //surface = EGL.CreateWindowSurface(dc, configs[0], handle, null);// <<<<<<<<<<<<<<<<<<<<<<<<<<<< used in x11 if (surface == IntPtr.Zero) { Debug.ThrowError("Video", "Failed to create window surface"); } if (EGL.MakeCurrent(dc, surface, surface, ctx) == 0) { Debug.ThrowError("Video", "Failed to make EGL context current"); } //if (EGL.SwapInterval(dc, vSync ? 1 : 0) == 0) Debug.ThrowError("Video", "Failed to set vSync"); checkForEGLError(); } #elif LINUX //Get DC handle = application.Handle; dc = X11.XOpenDisplay(IntPtr.Zero); int screen = X11.XDefaultScreen(dc); //Set Pixel format int[] attrbs = { GLX.RGBA, GLX.DOUBLEBUFFER,// 1, //GLX.RED_SIZE, 8, //GLX.GREEN_SIZE, 8, //GLX.BLUE_SIZE, 8, //GLX.ALPHA_SIZE, 8, GLX.DEPTH_SIZE,depthBit, GLX.NONE }; IntPtr visual = GLX.ChooseVisual(dc, screen, attrbs); if (visual == IntPtr.Zero) { Debug.ThrowError("Video", "Failed to get visual"); } ctx = GLX.CreateContext(dc, visual, new IntPtr(0), true); GLX.MakeCurrent(dc, handle, ctx); bool failed = false; try { GLX.SwapIntervalSGI(vSync ? 1 : 0); } catch { failed = true; } if (failed) { GLX.Init(); GLX.SwapIntervalMesa(vSync ? 1 : 0); } #endif #if OSX var attribs = new object[] { NSOpenGLPixelFormatAttribute.Window, NSOpenGLPixelFormatAttribute.Accelerated, NSOpenGLPixelFormatAttribute.NoRecovery, NSOpenGLPixelFormatAttribute.DoubleBuffer, NSOpenGLPixelFormatAttribute.ColorSize, 24, NSOpenGLPixelFormatAttribute.AlphaSize, 8, NSOpenGLPixelFormatAttribute.DepthSize, depthBit }; var pixelFormat = new NSOpenGLPixelFormat(attribs); if (pixelFormat == null) { Debug.ThrowError("Video", "NSOpenGLPixelFormat failed"); } NSContext = new NSOpenGLContext(pixelFormat, null); if (NSContext == null) { Debug.ThrowError("Video", "Failed to create GL context"); } NSContext.MakeCurrentContext(); NSContext.SwapInterval = vSync; NSContext.View = application.View; ctx = NSContext.CGLContext.Handle; OS.NSContext = NSContext; /*//Get DC * dc = CGL.DisplayIDToOpenGLDisplayMask(CGL.MainDisplayID()); * if (dc == IntPtr.Zero) Debug.ThrowError("Video", "Failed to get DC"); * * //Set BackBuffer format * int[] attributes = * { * //(int)CGL.PixelFormatAttribute.kCGLPFADoubleBuffer, * //(int)CGL.PixelFormatAttribute.kCGLPFADisplayMask, dc.ToInt32(), * //(int)CGL.PixelFormatAttribute.kCGLPFAWindow, * (int)CGL.PixelFormatAttribute.kCGLPFAAccelerated, * (int)CGL.PixelFormatAttribute.kCGLPFAColorSize, 32, * (int)CGL.PixelFormatAttribute.kCGLPFADepthSize, depthBit, * 0 * }; * * IntPtr pixelFormat = IntPtr.Zero; * int pixelFormatCount = 0; * int error = CGL.ChoosePixelFormat(attributes, ref pixelFormat, ref pixelFormatCount); * if (error != 0 || pixelFormat == IntPtr.Zero) * { * Debug.ThrowError("Video", "ChoosePixelFormat failed"); * } * * error = CGL.CreateContext(pixelFormat, IntPtr.Zero, ref ctx); * if (error != 0 || ctx == IntPtr.Zero) * { * Debug.ThrowError("Video", "Failed to create GL fullscreen context"); * } * * CGL.SetCurrentContext(ctx);*/ #endif #if iOS // GL will be created by the Application #endif #if ANDROID // GL will be created by the Application #endif #if NaCl var frame = application.FrameSize; int[] attribs = { (int)PPAPI.Graphics3DAttrib.PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,// Try to disable this to see if it gets rid of alpha blending presintation issues (int)PPAPI.Graphics3DAttrib.PP_GRAPHICS3DATTRIB_DEPTH_SIZE, depthBit, (int)PPAPI.Graphics3DAttrib.PP_GRAPHICS3DATTRIB_STENCIL_SIZE, stencilBit, (int)PPAPI.Graphics3DAttrib.PP_GRAPHICS3DATTRIB_SAMPLES, 0, (int)PPAPI.Graphics3DAttrib.PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0, (int)PPAPI.Graphics3DAttrib.PP_GRAPHICS3DATTRIB_WIDTH, frame.Width, (int)PPAPI.Graphics3DAttrib.PP_GRAPHICS3DATTRIB_HEIGHT, frame.Height, (int)PPAPI.Graphics3DAttrib.PP_GRAPHICS3DATTRIB_NONE }; graphics = OS.GetGraphics(); if (graphics == IntPtr.Zero) { Debug.ThrowError("Video", "Failed to get Graphics object"); } IntPtr pbbInstance = OS.GetPBBInstance(); if (graphics == IntPtr.Zero) { Debug.ThrowError("Video", "Failed to get PBBInstance object"); } IntPtr gles = OS.GetGlES(); if (gles == IntPtr.Zero) { Debug.ThrowError("Video", "Failed to get GLES object"); } context = PPAPI.InitOpenGL(OS.GetInstance(), graphics, pbbInstance, attribs, gles); if (context == 0) { Debug.ThrowError("Video", "Failed to create GL context"); } PPAPI.SetCurrentContextPPAPI(context); PPAPI.StartSwapBufferLoop(graphics, context); #endif checkForError(); //Setup defualt OpenGL characteristics GL.FrontFace(GL.CCW); // Get Caps Caps = new Caps(); Caps.MaxShaderVersion = ShaderVersions.Unknown; unsafe { int max = 0; GL.GetIntegerv(GL.MAX_TEXTURE_SIZE, &max); Caps.MaxTextureSize = max; // SEEMS TO MESS UP ON OSX //GL.GetIntegerv(GL.MAX_VERTEX_UNIFORM_VECTORS, &max); //Caps.MaxVertexConstants = max; //GL.GetIntegerv(GL.MAX_FRAGMENT_UNIFORM_VECTORS, &max); //Caps.MaxPixelConstants = max; #if RPI byte *shaderVersionPtr = null; #else byte *shaderVersionPtr = GL.GetString(GL.SHADING_LANGUAGE_VERSION); #endif string shaderVersion = ""; while (shaderVersionPtr != null && shaderVersionPtr[0] != 0) { shaderVersion += (char)shaderVersionPtr[0]; shaderVersionPtr++; } #if iOS || RPI shaderVersion = "1.0"; #elif ANDROID shaderVersion = shaderVersion.Substring(shaderVersion.Length - 4, 4); #elif NaCl shaderVersion = shaderVersion.Substring(18, 3); #else shaderVersion = shaderVersion.Substring(0, 4); #endif float shaderValue = Convert.ToSingle(shaderVersion); Caps.Version = Versions.GL1; FileTag = ""; #if iOS || ANDROID || NaCl || RPI if (shaderValue >= 1.0f) { Caps.Version = Versions.GL2; FileTag = "GLES2_"; Caps.MaxShaderVersion = ShaderVersions.GLSL_1_00; } #else if (shaderValue >= 1.1f) { Caps.Version = Versions.GL2; FileTag = "GL2_"; Caps.MaxShaderVersion = ShaderVersions.GLSL_1_10; } if (shaderValue >= 1.2f) { Caps.Version = Versions.GL2; FileTag = "GL2_"; Caps.MaxShaderVersion = ShaderVersions.GLSL_1_20; } // GL3 not supported in GLSL 1.30 becuase 'gl_InstanceID' only exists in GLSL 1.40 /*if (shaderValue >= 1.3f) * { * Caps.Version = Versions.GL3; * IShader.FileTag = "GL3_"; * Caps.MaxShaderVersion = ShaderVersions.GLSL_1_30; * }*/ if (shaderValue >= 1.4f) { Caps.Version = Versions.GL3; FileTag = "GL3_"; Caps.MaxShaderVersion = ShaderVersions.GLSL_1_40; } if (shaderValue >= 1.5f) { Caps.Version = Versions.GL3; FileTag = "GL3_"; Caps.MaxShaderVersion = ShaderVersions.GLSL_1_50; } if (shaderValue >= 3.3f) { Caps.Version = Versions.GL3; FileTag = "GL3_"; Caps.MaxShaderVersion = ShaderVersions.GLSL_3_30; } //if (shaderValue >= 4.0f) Caps.MaxShaderVersion = ShaderVersions.GLSL_4_00; //if (shaderValue >= 4.1f) Caps.MaxShaderVersion = ShaderVersions.GLSL_4_10; //if (shaderValue >= 4.2f) Caps.MaxShaderVersion = ShaderVersions.GLSL_4_20; #endif if (Caps.Version == Versions.GL1) { Debug.ThrowError("Video", "OpenGL 2 or higher is required.\nAre your video card drivers up to date?"); } byte * extensionsPtr = GL.GetString(GL.EXTENSIONS); string extensionValues = ""; while (extensionsPtr != null && extensionsPtr[0] != 0) { extensionValues += (char)extensionsPtr[0]; extensionsPtr++; } var extensions = extensionValues.Split(' '); foreach (var ext in extensions) { switch (ext) { case "GL_instanced_arrays": Caps.HardwareInstancing = true; break; case "GL_ARB_instanced_arrays": Caps.HardwareInstancing = true; break; case "GL_EXT_texture_compression_s3tc": Caps.TextureCompression_S3TC = true; break; case "GL_AMD_compressed_ATC_texture": Caps.TextureCompression_ATC = true; break; case "GL_ATI_texture_compression_atitc": Caps.TextureCompression_ATC = true; break; case "GL_IMG_texture_compression_pvrtc": Caps.TextureCompression_PVR = true; break; } //Console.WriteLine(ext); } } checkForError(); // Init Ext GL.Init(); } catch (Exception e) { Dispose(); throw e; } }
public static IntPtr XtGetGC(Widgets.IWidget w, X11.GCMask value_mask, ref X11.XGCValues values) { return NativeMethods.XtGetGC(w.NativeHandle.Widget, value_mask, ref values); }
private void button1_Click(object sender, EventArgs e) { button2.Visible = true; button3.Visible = true; button4.Visible = true; dataGridView2.Rows.Clear(); for (int c = 0; c < 4; c++) { for (int r = 0; r < 5; r++) { dataGridView1[c, r].Value = String.Empty; dataGridView1[c, r].Style.BackColor = Color.White; } } for (int r = 0; r < 12; r++) { dataGridView2.Rows.Add(); dataGridView2.Rows[r].HeaderCell.Value = (r + 1).ToString(); } X1 = dateTimePicker1.Value.Day; X2 = (X1 % 10); X1 = (X1 / 10); X3 = dateTimePicker1.Value.Month; X4 = (X3 % 10); X3 = (X3 / 10); X5 = dateTimePicker1.Value.Year; X6 = (X5 % 1000) / 100; X7 = (X5 % 100) / 10; X8 = (X5 % 10); X5 = (X5 / 1000); X9 = X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8; X10 = (X9 % 10) + (X9 / 10); X11 = X9 - (X1 * 2); X12 = (X11 % 10) + (X11 / 10); X13 = X9 + X11; X14 = X10 + X12; textBox1.Text = X9.ToString(); textBox2.Text = X10.ToString(); textBox3.Text = X11.ToString(); textBox4.Text = X12.ToString(); textBox5.Text = X13.ToString(); textBox6.Text = X14.ToString(); bigN = dateTimePicker1.Value.ToShortDateString() + textBox1.Text + textBox2.Text + textBox3.Text + textBox4.Text; smlN = textBox5.Text + textBox6.Text; Calc(0); for (int i = 0; i < 3; i++) { bn = 0; sn = 0; for (int j = 1; j < 4; j++) { Calc(i * 3 + j); } if (bn > 12) { bn = (bn % 10) + (bn / 10); } if (sn > 12) { sn = (sn % 10) + (sn / 10); } dataGridView1[3, i + 1].Value = bn.ToString() + '(' + sn.ToString() + ')'; } for (int i = 10; i < 13; i++) { if ((i == X13) || (i == X14)) { switch (i) { case 10: dataGridView1[0, 4].Value = "(10)"; dataGridView1[0, 4].Style.BackColor = Color.Blue; break; case 11: dataGridView1[1, 4].Value = "(11)"; dataGridView1[1, 4].Style.BackColor = Color.Blue; break; case 12: dataGridView1[2, 4].Value = "(12)"; dataGridView1[2, 4].Style.BackColor = Color.Blue; break; } dataGridView1[3, 4].Value = '(' + i.ToString() + ')'; } } BigTable(); GrafMake(); }
class X20 { public X20(X10 p1, X11 p2, X12 p3, X13 p4, X14 p5, X15 p6, X16 p7, X17 p8, X18 p9, X19 p10) { }
public string GetKeyName(uint key) { var keysym = X11.XkbKeycodeToKeysym(_display, key, 0, 1); return(X11.XKeysymToString(keysym)); }
class X16 { public X16(X06 p1, X07 p2, X08 p3, X09 p4, X10 p5, X11 p6, X12 p7, X13 p8, X14 p9, X15 p10) { }
class X18 { public X18(X08 p1, X09 p2, X10 p3, X11 p4, X12 p5, X13 p6, X14 p7, X15 p8, X16 p9, X17 p10) { }
class X14 { public X14(X04 p1, X05 p2, X06 p3, X07 p4, X08 p5, X09 p6, X10 p7, X11 p8, X12 p9, X13 p10) { }
internal static extern IntPtr XtGetGC(IntPtr w, X11.GCMask value_mask, [In,Out]ref X11.XGCValues values);
bool KeyToEvent(X11.Key key, bool enable) { switch (key) { case X11.Key.KP_Up: SetEvent(GameEvent.MoveSceneUp, enable); break; case X11.Key.KP_Begin: SetEvent(GameEvent.MoveSceneDown, enable); break; case X11.Key.KP_Left: SetEvent(GameEvent.MoveSceneLeft, enable); break; case X11.Key.KP_Right: SetEvent(GameEvent.MoveSceneRight, enable); break; case X11.Key.e: SetEvent(GameEvent.ShipForward, enable); break; case X11.Key.d: SetEvent(GameEvent.ShipBackward, enable); break; case X11.Key.s: SetEvent(GameEvent.ShipTurnLeft, enable); break; case X11.Key.f: SetEvent(GameEvent.ShipTurnRight, enable); break; case X11.Key.w: SetEvent(GameEvent.ShipStrafeLeft, enable); break; case X11.Key.r: SetEvent(GameEvent.ShipStrafeRight, enable); break; case X11.Key.Alt_L: SetEvent(GameEvent.SpeedUp, enable); break; case X11.Key.KP_Add: SetEvent(GameEvent.ZoomIn, enable); break; case X11.Key.KP_Subtract: SetEvent(GameEvent.ZoomOut, enable); break; case X11.Key.KP_Divide: SetEvent(GameEvent.Reset, enable); break; case X11.Key.KP_Home: SetEvent(GameEvent.RotateSceneLeft, enable); break; case X11.Key.KP_Page_Up: SetEvent(GameEvent.RotateSceneRight, enable); break; case X11.Key.i: if (enable) show_intel = !show_intel; break; case X11.Key.l: if (enable) show_label = !show_label; break; case X11.Key.c: if (enable) show_circle = !show_circle; break; case X11.Key.Key_1: ship_color = (ConsoleColor) (1 + 8); break; case X11.Key.Key_2: ship_color = (ConsoleColor) (2 + 8); break; case X11.Key.Key_3: ship_color = (ConsoleColor) (3 + 8); break; case X11.Key.Key_4: if (enable && isSetEvent(GameEvent.ShiftPressed)) show_dollar = !show_dollar; if (!isSetEvent(GameEvent.ShiftPressed)) ship_color = (ConsoleColor) (4 + 8); break; case X11.Key.Key_5: ship_color = (ConsoleColor) (5 + 8); break; case X11.Key.Key_6: ship_color = (ConsoleColor) (6 + 8); break; case X11.Key.Key_7: ship_color = (ConsoleColor) (7 + 8); break; case X11.Key.Insert: if (enable) count++; break; case X11.Key.Delete: if (enable) count--; break; case X11.Key.o: SetEvent(GameEvent.DeltaDec, enable); // if (enable) { // d1 -= 0.05; // d2 = d1 * ratioD; // } break; case X11.Key.p: SetEvent(GameEvent.DeltaInc, enable); // if (enable) { // d1 += 0.05; // d2 = d1 * ratioD; // } break; case X11.Key.bracketleft: if (enable) { //timer1 -= 1; timer2 -= 1; //timer1 = Math.Max(timer1, 1); timer2 = Math.Max(timer2, 1); } break; case X11.Key.bracketright: if (enable) { //timer1 += 1; timer2 += 1; } break; case X11.Key.semicolon: if (enable) { timer3 -= 10; timer3 = Math.Max(timer3, 30); } break; case X11.Key.apostrophe: if (enable) timer3 += 10; break; case X11.Key.KP_Enter: ConsoleScreen.Zoom = 1.0; break; case X11.Key.Return: if (enable) painter = painter == pixel_painter ? sprite_painter : pixel_painter; break; case X11.Key.KP_Multiply: SetEvent(GameEvent.AddStar, enable); break; case X11.Key.Shift_L: SetEvent(GameEvent.ShiftPressed, enable); break; case X11.Key.F1: if (enable) show_stat = !show_stat; break; case X11.Key.h: if (enable) show_help = !show_help; break; default: return false; } return true; }
class X12 { public X12(X02 p1, X03 p2, X04 p3, X05 p4, X06 p5, X07 p6, X08 p7, X09 p8, X10 p9, X11 p10) { }
public int Clear() { return(X11.XClearWindow(display, window)); }
class X13 { public X13(X03 p1, X04 p2, X05 p3, X06 p4, X07 p5, X08 p6, X09 p7, X10 p8, X11 p9, X12 p10) { }
internal static extern IntPtr XtGetGC(IntPtr w, X11.GCMask value_mask, IntPtr values);
class X15 { public X15(X05 p1, X06 p2, X07 p3, X08 p4, X09 p5, X10 p6, X11 p7, X12 p8, X13 p9, X14 p10) { }
public static IntPtr CreateWindowSurface(IntPtr vulkanInstance, NativeWindowBase window) { EnsureInit(); if (OperatingSystem.IsWindows() && IsExtensionPresent("VK_KHR_win32_surface")) { vkCreateWin32SurfaceKHRDelegate vkCreateWin32SurfaceKHR = Marshal.GetDelegateForFunctionPointer <vkCreateWin32SurfaceKHRDelegate>(_vkGetInstanceProcAddr(vulkanInstance, "vkCreateWin32SurfaceKHR")); VkWin32SurfaceCreateInfoKHR creationInfo = new VkWin32SurfaceCreateInfoKHR { StructType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR, Next = IntPtr.Zero, Flags = 0, // Broken warning here there is no platform issues here... #pragma warning disable CA1416 HInstance = Win32.GetWindowLong(window.WindowHandle.RawHandle, Win32.GetWindowLongIndex.GWL_HINSTANCE), #pragma warning restore CA1416 Hwnd = window.WindowHandle.RawHandle }; int res = vkCreateWin32SurfaceKHR(vulkanInstance, ref creationInfo, IntPtr.Zero, out IntPtr surface); if (res != 0) { throw new PlatformException($"vkCreateWin32SurfaceKHR failed: {res}"); } return(surface); } if (OperatingSystem.IsLinux()) { if (IsExtensionPresent("VK_KHR_xcb_surface")) { vkCreateXcbSurfaceKHRDelegate vkCreateXcbSurfaceKHR = Marshal.GetDelegateForFunctionPointer <vkCreateXcbSurfaceKHRDelegate>(_vkGetInstanceProcAddr(vulkanInstance, "vkCreateXcbSurfaceKHR")); VkXcbSurfaceCreateInfoKHR creationInfo = new VkXcbSurfaceCreateInfoKHR { StructType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR, Next = IntPtr.Zero, Flags = 0, Connection = X11.GetXCBConnection(window.DisplayHandle.RawHandle), Window = window.WindowHandle.RawHandle }; int res = vkCreateXcbSurfaceKHR(vulkanInstance, ref creationInfo, IntPtr.Zero, out IntPtr surface); if (res != 0) { throw new PlatformException($"vkCreateXcbSurfaceKHR failed: {res}"); } return(surface); } else { vkCreateXlibSurfaceKHRDelegate vkCreateXlibSurfaceKHR = Marshal.GetDelegateForFunctionPointer <vkCreateXlibSurfaceKHRDelegate>(_vkGetInstanceProcAddr(vulkanInstance, "vkCreateXlibSurfaceKHR")); VkXlibSurfaceCreateInfoKHR creationInfo = new VkXlibSurfaceCreateInfoKHR { StructType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR, Next = IntPtr.Zero, Flags = 0, Display = window.DisplayHandle.RawHandle, Window = window.WindowHandle.RawHandle }; int res = vkCreateXlibSurfaceKHR(vulkanInstance, ref creationInfo, IntPtr.Zero, out IntPtr surface); if (res != 0) { throw new PlatformException($"vkCreateXlibSurfaceKHR failed: {res}"); } return(surface); } } throw new NotImplementedException(); }
class X17 { public X17(X07 p1, X08 p2, X09 p3, X10 p4, X11 p5, X12 p6, X13 p7, X14 p8, X15 p9, X16 p10) { }
public void Close() { X11.XCloseDisplay(display); }
class X19 { public X19(X09 p1, X10 p2, X11 p3, X12 p4, X13 p5, X14 p6, X15 p7, X16 p8, X17 p9, X18 p10) { }
public int Show() { return(X11.XMapWindow(display, window)); }
class X21 { public X21(X11 p1, X12 p2, X13 p3, X14 p4, X15 p5, X16 p6, X17 p7, X18 p8, X19 p9, X20 p10) { }
public UnixKeys(IntPtr display) { _display = display; Back = X11.XKeysymToKeycode(_display, 0xff08); Tab = X11.XKeysymToKeycode(_display, 0xff09); Return = X11.XKeysymToKeycode(_display, 0xff0d); Shift = X11.XKeysymToKeycode(_display, 0xffe1); Control = X11.XKeysymToKeycode(_display, 0xffe3); Menu = X11.XKeysymToKeycode(_display, 0xffe9); Pause = X11.XKeysymToKeycode(_display, 0xff6b); Capital = X11.XKeysymToKeycode(_display, 0xffe5); Escape = X11.XKeysymToKeycode(_display, 0xff1b); Space = X11.XKeysymToKeycode(_display, 0x20); PageUp = X11.XKeysymToKeycode(_display, 0xff55); PageDown = X11.XKeysymToKeycode(_display, 0xff56); End = X11.XKeysymToKeycode(_display, 0xff57); Home = X11.XKeysymToKeycode(_display, 0xff58); Left = X11.XKeysymToKeycode(_display, 0x08fb); Up = X11.XKeysymToKeycode(_display, 0x08fc); Right = X11.XKeysymToKeycode(_display, 0x08fd); Down = X11.XKeysymToKeycode(_display, 0x08fe); Insert = X11.XKeysymToKeycode(_display, 0xff63); Delete = X11.XKeysymToKeycode(_display, 0xffff); Help = X11.XKeysymToKeycode(_display, 0xff6a); Key0 = X11.XKeysymToKeycode(_display, 0x30); Key1 = X11.XKeysymToKeycode(_display, 0x31); Key2 = X11.XKeysymToKeycode(_display, 0x32); Key3 = X11.XKeysymToKeycode(_display, 0x33); Key4 = X11.XKeysymToKeycode(_display, 0x34); Key5 = X11.XKeysymToKeycode(_display, 0x35); Key6 = X11.XKeysymToKeycode(_display, 0x36); Key7 = X11.XKeysymToKeycode(_display, 0x37); Key8 = X11.XKeysymToKeycode(_display, 0x38); Key9 = X11.XKeysymToKeycode(_display, 0x39); A = X11.XKeysymToKeycode(_display, 0x41); B = X11.XKeysymToKeycode(_display, 0x42); C = X11.XKeysymToKeycode(_display, 0x43); D = X11.XKeysymToKeycode(_display, 0x44); E = X11.XKeysymToKeycode(_display, 0x45); F = X11.XKeysymToKeycode(_display, 0x46); G = X11.XKeysymToKeycode(_display, 0x47); H = X11.XKeysymToKeycode(_display, 0x48); I = X11.XKeysymToKeycode(_display, 0x49); J = X11.XKeysymToKeycode(_display, 0x4A); K = X11.XKeysymToKeycode(_display, 0x4B); L = X11.XKeysymToKeycode(_display, 0x4C); M = X11.XKeysymToKeycode(_display, 0x4D); N = X11.XKeysymToKeycode(_display, 0x4E); O = X11.XKeysymToKeycode(_display, 0x4F); P = X11.XKeysymToKeycode(_display, 0x50); Q = X11.XKeysymToKeycode(_display, 0x51); R = X11.XKeysymToKeycode(_display, 0x52); S = X11.XKeysymToKeycode(_display, 0x53); T = X11.XKeysymToKeycode(_display, 0x54); U = X11.XKeysymToKeycode(_display, 0x55); V = X11.XKeysymToKeycode(_display, 0x56); W = X11.XKeysymToKeycode(_display, 0x57); X = X11.XKeysymToKeycode(_display, 0x58); Y = X11.XKeysymToKeycode(_display, 0x59); Z = X11.XKeysymToKeycode(_display, 0x5A); Lwin = X11.XKeysymToKeycode(_display, 0xffeb); Rwin = X11.XKeysymToKeycode(_display, 0xffec); Numpad0 = X11.XKeysymToKeycode(_display, 0xffb0); Numpad1 = X11.XKeysymToKeycode(_display, 0xffb1); Numpad2 = X11.XKeysymToKeycode(_display, 0xffb2); Numpad3 = X11.XKeysymToKeycode(_display, 0xffb3); Numpad4 = X11.XKeysymToKeycode(_display, 0xffb4); Numpad5 = X11.XKeysymToKeycode(_display, 0xffb5); Numpad6 = X11.XKeysymToKeycode(_display, 0xffb6); Numpad7 = X11.XKeysymToKeycode(_display, 0xffb7); Numpad8 = X11.XKeysymToKeycode(_display, 0xffb8); Numpad9 = X11.XKeysymToKeycode(_display, 0xffb9); Multiply = X11.XKeysymToKeycode(_display, 0xffaa); Add = X11.XKeysymToKeycode(_display, 0xffab); Separator = X11.XKeysymToKeycode(_display, 0xffac); Subtract = X11.XKeysymToKeycode(_display, 0xffad); Decimal = X11.XKeysymToKeycode(_display, 0xffae); Divide = X11.XKeysymToKeycode(_display, 0xffaf); F1 = X11.XKeysymToKeycode(_display, 0xffbe); F2 = X11.XKeysymToKeycode(_display, 0xffbf); F3 = X11.XKeysymToKeycode(_display, 0xffc0); F4 = X11.XKeysymToKeycode(_display, 0xffc1); F5 = X11.XKeysymToKeycode(_display, 0xffc2); F6 = X11.XKeysymToKeycode(_display, 0xffc3); F7 = X11.XKeysymToKeycode(_display, 0xffc4); F8 = X11.XKeysymToKeycode(_display, 0xffc5); F9 = X11.XKeysymToKeycode(_display, 0xffc6); F10 = X11.XKeysymToKeycode(_display, 0xffc7); F11 = X11.XKeysymToKeycode(_display, 0xffc8); F12 = X11.XKeysymToKeycode(_display, 0xffc9); F13 = X11.XKeysymToKeycode(_display, 0xffca); F14 = X11.XKeysymToKeycode(_display, 0xffcb); F15 = X11.XKeysymToKeycode(_display, 0xffcc); F16 = X11.XKeysymToKeycode(_display, 0xffcd); F17 = X11.XKeysymToKeycode(_display, 0xffce); F18 = X11.XKeysymToKeycode(_display, 0xffcf); F19 = X11.XKeysymToKeycode(_display, 0xffd0); F20 = X11.XKeysymToKeycode(_display, 0xffd1); F21 = X11.XKeysymToKeycode(_display, 0xffd2); F22 = X11.XKeysymToKeycode(_display, 0xffd3); F23 = X11.XKeysymToKeycode(_display, 0xffd4); F24 = X11.XKeysymToKeycode(_display, 0xffd5); Lshift = X11.XKeysymToKeycode(_display, 0xffe1); Rshift = X11.XKeysymToKeycode(_display, 0xffe2); Lcontrol = X11.XKeysymToKeycode(_display, 0xffe3); Rcontrol = X11.XKeysymToKeycode(_display, 0xffe4); Lmenu = X11.XKeysymToKeycode(_display, 0xffe9); Rmenu = X11.XKeysymToKeycode(_display, 0xffea); OemPlus = X11.XKeysymToKeycode(_display, 0x2b); OemComma = X11.XKeysymToKeycode(_display, 0x2c); OemMinus = X11.XKeysymToKeycode(_display, 0x2d); OemPeriod = X11.XKeysymToKeycode(_display, 0x2e); //todo verify Oem1 = 0x22; Oem2 = 0x31; Oem3 = 0x23; Oem4 = 0x14; Oem5 = 0x30; Oem6 = 0x15; Oem7 = 0x30; Oem8 = 0x33; }