protected override bool OnStart() { try { SilkManager.Register <GLSymbolLoader>(new SymbolLoader()); _gl = GL.GetApi(new OpenGLNativeContext()); } catch (Exception ex) { XPlane.Trace.WriteLine(ex.ToString()); return(false); } var desktopBounds = Screen.BoundsGlobal; _window = new Window( new Rect(desktopBounds.Left + 50, desktopBounds.Bottom + 450, desktopBounds.Left + 350, desktopBounds.Bottom + 150), decoration: WindowDecoration.RoundRectangle); _window.SetPositioningMode(WindowPositioningMode.PositionFree); _window.SetGravity(0, 1, 0, 1); _window.SetResizingLimits(200, 200, 500, 500); _window.Title = "Sample Window"; _window.DrawWindow += OnDrawWindow; _window.MouseLeftButtonEvent += OnMouseLeftButtonEvent; return(true); }
private unsafe static void Main(string[] args) { glfw = Glfw.GetApi(); Console.WriteLine(glfw.GetVersionString()); glfw.SetErrorCallback(GlfwError); //SilkManager.Register<IWindowPlatform>(glfwPlatform); SilkManager.Register <GLSymbolLoader>(new Silk.NET.GLFW.GlfwLoader()); glfw.Init(); glfw.WindowHint(WindowHintInt.ContextVersionMajor, 3); glfw.WindowHint(WindowHintInt.ContextVersionMinor, 3); glfw.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Core); window = glfw.CreateWindow(800, 600, "3Dtest", null, null); if (window == null) { Console.WriteLine("Window creation failed"); glfw.Terminate(); return; } glfw.MakeContextCurrent(window); glfw.SetWindowSizeCallback(window, OnResize); glfw.SetCursorPosCallback(window, MouseInput); glfw.SetScrollCallback(window, ScrollInput); glfw.SetInputMode(window, CursorStateAttribute.Cursor, CursorModeValue.CursorDisabled); //glfw.SwapInterval(1); OnLoad(); double currentFrame; while (!glfw.WindowShouldClose(window)) { currentFrame = glfw.GetTimerValue(); deltaTime = (currentFrame - lastFrame) / glfw.GetTimerFrequency(); lastFrame = currentFrame; ProcessInput(window); //Console.WriteLine($"Fps: {Math.Round(1f/deltaTime)}"); OnRender(); } glfw.Terminate(); }
/// <summary> /// Attempts to resolve an <see cref="IWindowPlatform" />. /// </summary> /// <exception cref="NotSupportedException"> /// Thrown if no applicable <see cref="IWindowPlatform" /> was found. /// </exception> public static void Init() { var glfwPlatform = new GlfwPlatform(); if (glfwPlatform.IsApplicable) { SilkManager.Register <IWindowPlatform>(glfwPlatform); SilkManager.Register <IGLSymbolLoader>(new GlfwLoader()); return; } // TODO: Mobile if (!SilkManager.IsRegistered <IWindowPlatform>()) { throw new NotSupportedException("Couldn't find a suitable windowing platform. Generally, this means that your GLFW library is missing."); } }
/// <summary> /// Attempts to resolve an <see cref="IWindowPlatform" />. /// </summary> /// <exception cref="NotSupportedException"> /// Thrown if no applicable <see cref="IWindowPlatform" /> was found. /// </exception> public static void Init() { var glfwPlatform = new GlfwPlatform(); if (glfwPlatform.IsApplicable) { SilkManager.Register <IWindowPlatform>(glfwPlatform); SilkManager.Register <IGLSymbolLoader>(new GlfwLoader()); return; } // TODO: Mobile if (!SilkManager.IsRegistered <IWindowPlatform>()) { throw new NotSupportedException ( "Couldn't find a suitable windowing platform. You probably forgot to copy a glfw3 library into " + "your bin/Debug or bin/Release folder (this won't be a problem in Preview 4)" ); } }
/// <summary> /// Attempts to resolve an <see cref="IWindowPlatform" />. /// </summary> /// <exception cref="NotSupportedException"> /// Thrown if no applicable <see cref="IWindowPlatform" /> was found. /// </exception> internal static void Init() { var glfwPlatform = GlfwPlatform.Instance; if (glfwPlatform.IsApplicable) { SilkManager.Register <IWindowPlatform>(glfwPlatform); SilkManager.Register <GLSymbolLoader>(new GlfwLoader()); return; } // TODO: Mobile if (!SilkManager.IsRegistered <IWindowPlatform>()) { var entAsm = Assembly.GetEntryAssembly()?.Location; entAsm = entAsm is null ? "the entry assembly" : Path.GetFileName(entAsm); throw new NotSupportedException ( "Couldn't find a suitable windowing platform. \n" + $"GLFW: Copy a GLFW 3.3 binary into the same directory as {entAsm}\n" ); } }
public bool OpenWindow(string name, Size dimensions) { glfw = Glfw.GetApi(); glfw.SetErrorCallback(GlfwError); SilkManager.Register <GLSymbolLoader>(new Silk.NET.GLFW.GlfwLoader()); glfw.Init(); glfw.WindowHint(WindowHintInt.ContextVersionMajor, 3); glfw.WindowHint(WindowHintInt.ContextVersionMinor, 3); glfw.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Core); window = glfw.CreateWindow(dimensions.Width, dimensions.Height, name, null, null); if (window == null) { Console.WriteLine("Window creation failed"); glfw.Terminate(); return(false); } glfw.MakeContextCurrent(window); glfw.SetWindowSizeLimits(window, dimensions.Width, dimensions.Height, dimensions.Width, dimensions.Height); //glfw.SetWindowSizeCallback(window, OnWindowResize); glfw.SetKeyCallback(window, OnWindowButtonPress); glfw.SetCursorEnterCallback(window, OnWindowCursorEnter); glfw.SetCursorPosCallback(window, OnWindowCursor); glfw.SetMouseButtonCallback(window, OnWindowMouseButton); //glfw.SetScrollCallback(window, ScrollInput); //glfw.SetInputMode(window, CursorStateAttribute.Cursor, CursorModeValue.CursorDisabled); return(true); }
static InputWindowExtensions() { SilkManager.Register <IInputPlatform>(new GlfwInputPlatform()); }
static InputWindowExtensions() { SilkManager.Register <IInputPlatform>(GlfwInputPlatform.Instance); }