void CreateWindow() { GLFW.WindowHint(WindowHint.ClientAPI, (int)ClientAPI.NoAPI); window = GLFW.CreateWindow(height, width, "Hello Triangle", MonitorPtr.Null, WindowPtr.Null); GLFW.SetWindowSizeCallback(window, OnWindowResized); }
public static void ImGui_ImplGlfw_CreateWindow(ImGuiViewportPtr viewport) { // ImGuiViewportDataGlfw* data = CreateViewportData(); // viewport->PlatformUserData = data; // GLFW 3.2 unfortunately always set focus on glfwCreateWindow() if GLFW_VISIBLE is set, regardless of GLFW_FOCUSED // With GLFW 3.3, the hint GLFW_FOCUS_ON_SHOW fixes this problem GLFW.WindowHint(WindowHintBool.Visible, true); GLFW.WindowHint(WindowHintBool.Focused, true); GLFW.WindowHint(WindowHintBool.FocusOnShow, true); GLFW.WindowHint(WindowHintBool.Decorated, !viewport.Flags.HasFlag(ImGuiViewportFlags.NoDecoration)); GLFW.WindowHint(WindowHintBool.Floating, viewport.Flags.HasFlag(ImGuiViewportFlags.TopMost)); Window *share_window = (Window *)GetMainWindowHandle().ToPointer(); var window = GLFW.CreateWindow((int)viewport.Size.X, (int)viewport.Size.Y, "No Title Yet", null, share_window); // data->Window = window; // data->WindowOwned = true; viewport.PlatformHandle = new IntPtr(window); GLFW.SetWindowPos(window, (int)viewport.Pos.X, (int)viewport.Pos.Y); // GLFW.SetMouseButtonCallback(data->Window, ImGui_ImplGlfw_MouseButtonCallback); // GLFW.SetScrollCallback(data->Window, ImGui_ImplGlfw_ScrollCallback); // GLFW.SetKeyCallback(data->Window, ImGui_ImplGlfw_KeyCallback); // GLFW.SetCharCallback(data->Window, ImGui_ImplGlfw_CharCallback); GLFW.SetWindowCloseCallback(window, ImGui_ImplGlfw_WindowCloseCallback); GLFW.SetWindowPosCallback(window, ImGui_ImplGlfw_WindowPosCallback); GLFW.SetWindowSizeCallback(window, ImGui_ImplGlfw_WindowSizeCallback); GLFW.MakeContextCurrent(window); GLFW.SwapInterval(0); }
private void InitWindow() { GLFW.WindowHint(WindowHintBool.SrgbCapable, true); GLFW.WindowHint(WindowHintInt.ContextVersionMajor, MinimumOpenGLVersion.Major); GLFW.WindowHint(WindowHintInt.ContextVersionMinor, MinimumOpenGLVersion.Minor); GLFW.WindowHint(WindowHintBool.OpenGLForwardCompat, true); GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Core); #if DEBUG GLFW.WindowHint(WindowHintBool.OpenGLDebugContext, true); #endif GLFW.WindowHint(WindowHintString.X11ClassName, "SS14"); GLFW.WindowHint(WindowHintString.X11InstanceName, "SS14"); var width = _configurationManager.GetCVar <int>("display.width"); var height = _configurationManager.GetCVar <int>("display.height"); Monitor *monitor = null; if (WindowMode == WindowMode.Fullscreen) { monitor = GLFW.GetPrimaryMonitor(); var mode = GLFW.GetVideoMode(monitor); width = mode->Width; height = mode->Height; } _glfwWindow = GLFW.CreateWindow(width, height, string.Empty, monitor, null); LoadWindowIcon(); GLFW.SetCharCallback(_glfwWindow, _charCallback); GLFW.SetKeyCallback(_glfwWindow, _keyCallback); GLFW.SetWindowCloseCallback(_glfwWindow, _windowCloseCallback); GLFW.SetCursorPosCallback(_glfwWindow, _cursorPosCallback); GLFW.SetWindowSizeCallback(_glfwWindow, _windowSizeCallback); GLFW.SetScrollCallback(_glfwWindow, _scrollCallback); GLFW.SetMouseButtonCallback(_glfwWindow, _mouseButtonCallback); GLFW.SetWindowContentScaleCallback(_glfwWindow, _windowContentScaleCallback); GLFW.MakeContextCurrent(_glfwWindow); VSyncChanged(); GLFW.GetFramebufferSize(_glfwWindow, out var fbW, out var fbH); _screenSize = (fbW, fbH); GLFW.GetWindowContentScale(_glfwWindow, out var scaleX, out var scaleY); _windowScale = (scaleX, scaleY); InitGLContext(); // Initializing OTK 3 seems to mess with the current context, so ensure it's still set. // This took me f*****g *forever* to debug because this manifested differently on nvidia drivers vs intel mesa. // So I thought it was a calling convention issue with the calli OpenTK emits. // Because, in my tests, I had InitGLContext() AFTER the test with a delegate-based invoke of the proc. GLFW.MakeContextCurrent(_glfwWindow); InitOpenGL(); }
public static int Main(string[] args) { if (GLFW.Init() == 0) { return(-1); } GLFW.WindowHint(GLFW.CLIENT_API, GLFW.NO_API); string title = $"GLFW & SharpBgfx"; IntPtr window = GLFW.CreateWindow(640, 480, title, IntPtr.Zero, IntPtr.Zero); if (window == IntPtr.Zero) { GLFW.Terminate(); return(-1); } Bgfx.SetPlatformData(new PlatformData() { WindowHandle = GetWin32Window(window) }); Bgfx.Init(); Bgfx.Reset(640, 480, ResetFlags.Vsync); Bgfx.SetDebugFeatures(DebugFeatures.DisplayText); Bgfx.SetViewClear(0, ClearTargets.Color | ClearTargets.Depth, 0x303030ff); while (GLFW.WindowShouldClose(window) == 0) { GLFW.PollEvents(); Bgfx.Touch(0); // write some debug text Bgfx.DebugTextClear(); Bgfx.DebugTextWrite(0, 1, DebugColor.White, DebugColor.Blue, "GLFWDotNet & SharpBgfx"); Bgfx.DebugTextWrite(0, 2, DebugColor.White, DebugColor.Cyan, "Description: Initialization and debug text."); // advance to the next frame. Rendering thread will be kicked to // process submitted rendering primitives. Bgfx.Frame(); GLFW.SwapBuffers(window); } Bgfx.Shutdown(); GLFW.Terminate(); return(0); }
public unsafe GlfwWindow() { if (_windowCount++ == 0) { GLFW.Init(); } _windowHandle = GLFW.CreateWindow(1028, 720, "voxel engine", null, null); Input = new GlfwInput(_windowHandle); }
public Hob(int windowWidth, int windowHeight) { this.windowWidth = windowWidth; this.windowHeight = windowHeight; GLFW.Initialise(); window = GLFW.CreateWindow(windowWidth, windowHeight, "Test", IntPtr.Zero, IntPtr.Zero); GLFW.MakeContextCurrent(window); Gl.Initialize(); Gl.Viewport(0, 0, windowWidth, windowHeight); }
protected ContextBase(string title) { _window = GLFW.CreateWindow(Config.Width, Config.Height, title, null, null); MakeCurrent(); if (!_hasInitializedOpengl) { _hasInitializedOpengl = true; GL.LoadBindings(new GLFWBindingsContext()); } GL.ClearColor(Config.ClearColor); }
private IntPtr?createWindow(string windowName) { GLFW.WindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 3); GLFW.WindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 3); GLFW.WindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE); // required for getting OpenGL context >= 3.2 on MacOS >= OS X 10.7 // http://stackoverflow.com/a/9017716 GLFW.WindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, 1); GLFW.WindowHint(GLFW.GLFW_RESIZABLE, 0); _window = GLFW.CreateWindow(640, 480, windowName, IntPtr.Zero, IntPtr.Zero); if (_window == IntPtr.Zero) { return(null); } return(_window); }
public static int Main(string[] args) { if (GLFW.Init() == 0) { return(-1); } GLFW.GetVersion(out int major, out int minor, out int revision); GLFW.WindowHint(GLFW.CLIENT_API, GLFW.OPENGL_API); GLFW.WindowHint(GLFW.OPENGL_PROFILE, GLFW.OPENGL_CORE_PROFILE); GLFW.WindowHint(GLFW.CONTEXT_VERSION_MAJOR, 4); GLFW.WindowHint(GLFW.CONTEXT_VERSION_MINOR, 0); string title = $"Hello World! GLFW {major}.{minor}.{revision}"; IntPtr window = GLFW.CreateWindow(640, 480, title, IntPtr.Zero, IntPtr.Zero); if (window == IntPtr.Zero) { GLFW.Terminate(); return(-1); } GLFW.MakeContextCurrent(window); GL gl = new GL(new GLFWPlatformContext(window, 4, 0)); var versionString = gl.GetString(StringName.Version); var rendererString = gl.GetString(StringName.Renderer); GLFW.SetWindowTitle(window, $"{title} {versionString} {rendererString}"); while (GLFW.WindowShouldClose(window) == 0) { GLFW.PollEvents(); GLFW.SwapBuffers(window); } GLFW.Terminate(); return(0); }
private static void CreateWindow(ImGuiViewport *viewport) { PlatformBackend backend = GetPlatformBackend(); ViewportData * viewportData = ViewportData.Allocate(); viewport->PlatformUserData = viewportData; GLFW.WindowHint(WindowHintBool.Visible, false); GLFW.WindowHint(WindowHintBool.Focused, false); GLFW.WindowHint(WindowHintBool.FocusOnShow, false); GLFW.WindowHint(WindowHintBool.Decorated, !viewport->Flags.HasFlag(ImGuiViewportFlags.NoDecoration)); GLFW.WindowHint(WindowHintBool.Floating, viewport->Flags.HasFlag(ImGuiViewportFlags.TopMost)); *viewportData = new ViewportData() { Window = GLFW.CreateWindow((int)viewport->Size.X, (int)viewport->Size.Y, "No Title Yet", null, backend.Window), WindowOwned = true, }; viewport->PlatformHandle = viewportData->Window; if (OperatingSystem.IsWindows()) { viewport->PlatformHandleRaw = (void *)GLFW.GetWin32Window(viewportData->Window); } GLFW.SetWindowPos(viewportData->Window, (int)viewport->Pos.X, (int)viewport->Pos.Y); // Install GLFW callbacks for secondary viewports GlfwNative.glfwSetWindowFocusCallback(viewportData->Window, &WindowFocusCallback); GlfwNative.glfwSetCursorEnterCallback(viewportData->Window, &CursorEnterCallback); GlfwNative.glfwSetCursorPosCallback(viewportData->Window, &CursorPosCallback); GlfwNative.glfwSetMouseButtonCallback(viewportData->Window, &MouseButtonCallback); GlfwNative.glfwSetScrollCallback(viewportData->Window, &ScrollCallback); GlfwNative.glfwSetKeyCallback(viewportData->Window, &KeyCallback); GlfwNative.glfwSetCharCallback(viewportData->Window, &CharCallback); GlfwNative.glfwSetWindowCloseCallback(viewportData->Window, &WindowCloseCallback); GlfwNative.glfwSetWindowPosCallback(viewportData->Window, &WindowPosCallback); GlfwNative.glfwSetWindowSizeCallback(viewportData->Window, &WindowSizeCallback); GLFW.MakeContextCurrent(viewportData->Window); GLFW.SwapInterval(0); }
public Window(int width, int height, string title) { if (Windows.Count == 0) { if (!GLFW.Init()) { throw new Exception("Glfw failed to initialize!"); } } Windows.Add(this); _handle = GLFW.CreateWindow(width, height, title, null, null); if (_handle == null) { throw new Exception("Window failed to create"); } _mouse = new Mouse(_handle); _keyboard = new Keyboard(_handle); _size = new Vector2i(width, height); }
void CreateWindow() { GLFW.WindowHint(WindowHint.ClientAPI, (int)ClientAPI.NoAPI); GLFW.WindowHint(WindowHint.Visible, 0); window = GLFW.CreateWindow(width, height, "Hello Triangle", MonitorPtr.Null, WindowPtr.Null); }
//WndProc del; public override rcode CreateWindowPane(vi2d vWindowPos, vi2d vWindowSize, bool bFullScreen) { //Console.WriteLine("CreateWindowPane-start"); //WNDCLASS wc = new WNDCLASS(); //wc.hIcon = LoadIcon(IntPtr.Zero, IDI_APPLICATION); // IDI_APPLICATION (Default icon) //wc.hCursor = LoadCursor(IntPtr.Zero, IDC_ARROW); // IDC_ARROW (Standard arrow) //wc.style = ClassStyles.HorizontalRedraw | ClassStyles.VerticalRedraw | ClassStyles.OwnDC; //wc.hInstance = GetModuleHandle(null); //wc.lpfnWndProc = del; //wc.cbClsExtra = 0; //wc.cbWndExtra = 0; //wc.lpszMenuName = null; //wc.hbrBackground = IntPtr.Zero; //wc.lpszClassName = "OLC_PIXEL_GAME_ENGINE"; //RegisterClass(ref wc); // Define window furniture //var dwExStyle = WindowStylesEx.WS_EX_APPWINDOW | WindowStylesEx.WS_EX_WINDOWEDGE; //var dwStyle = WindowStyles.WS_CAPTION | WindowStyles.WS_SYSMENU | WindowStyles.WS_VISIBLE | WindowStyles.WS_THICKFRAME; vi2d vTopLeft = vWindowPos; // Handle Fullscreen //if (bFullScreen) //{ // dwExStyle = WindowStylesEx.WS_EX_LEFT; // dwStyle = WindowStyles.WS_VISIBLE | WindowStyles.WS_POPUP; // IntPtr hmon = MonitorFromWindow(olc_hWnd, MONITOR_DEFAULTTONEAREST); // MonitorInfoEx mi = new MonitorInfoEx(); /*= { sizeof(mi) };*/ // if (!GetMonitorInfo(hmon, ref mi)) return rcode.FAIL; // vWindowSize = new vi2d( mi.Monitor.Right, mi.Monitor.Bottom); // vTopLeft.x = 0; // vTopLeft.y = 0; //} // Keep client size as requested //RECT rWndRect = new RECT ( 0, 0, vWindowSize.x, vWindowSize.y ); //AdjustWindowRectEx(ref rWndRect, (uint)dwStyle, false, (uint)dwExStyle); int width = vWindowSize.x; //rWndRect.Right - rWndRect.Left; int height = vWindowSize.y; //rWndRect.Bottom - rWndRect.Top; //olc_hWnd = CreateWindowEx(dwExStyle, "OLC_PIXEL_GAME_ENGINE", "", dwStyle, // fix dwExStyle // vTopLeft.x, vTopLeft.y, width, height, IntPtr.Zero, IntPtr.Zero, GetModuleHandle(null), IntPtr.Zero); // lpParam should have been set to "this" ? GLFW.Init(); GLFW.WindowHint(WindowHintInt.ContextVersionMajor, 3); GLFW.WindowHint(WindowHintInt.ContextVersionMinor, 3); GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Core); GLFW.WindowHint(WindowHintBool.DoubleBuffer, true); olc_hWnd = GLFW.CreateWindow(width, height, "OLC_PIXEL_GAME_ENGINE", null, null); GLFW.SetFramebufferSizeCallback(olc_hWnd, framebufferCallback); GLFW.SetErrorCallback(errorCallback); GLFW.SetMouseButtonCallback(olc_hWnd, mousebuttonCallback); GLFW.SetScrollCallback(olc_hWnd, scrollCallback); GLFW.SetCursorPosCallback(olc_hWnd, cursorposCallback); keyCallback = key_Callback; GLFW.SetKeyCallback(olc_hWnd, keyCallback); //GLFW.MakeContextCurrent((Window*)olc_hWnd); //GLFW.MakeContextCurrent(olc_hWnd); //if (olc_hWnd == null) //{ // Console.WriteLine($"LastError : [{Marshal.GetLastWin32Error()}]"); //} Console.WriteLine("Window Created"); Console.WriteLine("CreateWindowPane-end"); return(rcode.OK); }
void CreateWindow() { GLFW.WindowHint(WindowHint.ClientAPI, (int)ClientAPI.NoAPI); GLFW.WindowHint(WindowHint.Visible, 0); window = GLFW.CreateWindow(width, height, "Texture Mapping", MonitorPtr.Null, WindowPtr.Null); }
void CreateWindow() { GLFW.WindowHint(WindowHint.ClientAPI, (int)ClientAPI.NoAPI); GLFW.WindowHint(WindowHint.Visible, 0); window = GLFW.CreateWindow(width, height, "Vertex Buffer", MonitorPtr.Null, WindowPtr.Null); }
static void Main(string[] args) { // If the library isn't in the environment path we need to set it //Glfw.ConfigureNativesDirectory("./"); // Initialize the library var data = new int[] { 1, 2 }; unsafe { } if (!GLFW.Init()) { Console.Error.WriteLine("ERROR: Could not initialize GLFW, shutting down."); Console.WriteLine(Directory.GetCurrentDirectory()); GLFW.Terminate(); Environment.Exit(1); } GLFW.WindowHint(GLFW.Hint.ContextVersionMajor, 4); GLFW.WindowHint(GLFW.Hint.ContextVersionMinor, 1); // Create a windowed mode window and its OpenGL context var window = GLFW.CreateWindow(640, 480, "Hello World"); if (!window) { Console.Error.WriteLine("ERROR: Could not initialize GLFW window, shutting down."); Environment.Exit(1); GLFW.Terminate(); } // Make the window's context current GLFW.MakeContextCurrent(window); Toolkit.Init(); var context = new GraphicsContext(new ContextHandle(IntPtr.Zero), null); // Loop until the user closes the window while (!GLFW.WindowShouldClose(window)) { // Render GL.Clear(ClearBufferMask.ColorBufferBit); GL.Begin(PrimitiveType.Triangles); GL.Color3(1.0f, 0.0f, 0.0f); GL.Vertex2(0.0f, 0.0f); GL.Color3(0.0f, 1.0f, 0.0f); GL.Vertex2(0.5f, 1.0f); GL.Color3(0.0f, 0.0f, 1.0f); GL.Vertex2(1.0f, 0.0f); GL.End(); // Swap front and back buffers GLFW.SwapBuffers(window); // Poll for and process events GLFW.PollEvents(); } GLFW.Terminate(); }
private Window *CreateGlfwWindowForRenderer( GLContextSpec?spec, WindowCreateParameters parameters, Window *contextShare, Window *ownerWindow) { GLFW.WindowHint(WindowHintString.X11ClassName, "RobustToolbox"); GLFW.WindowHint(WindowHintString.X11InstanceName, "RobustToolbox"); GLFW.WindowHint(WindowHintBool.ScaleToMonitor, true); if (spec == null) { // No OpenGL context requested. GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.NoApi); } else { var s = spec.Value; #if DEBUG GLFW.WindowHint(WindowHintBool.OpenGLDebugContext, true); #endif GLFW.WindowHint(WindowHintInt.ContextVersionMajor, s.Major); GLFW.WindowHint(WindowHintInt.ContextVersionMinor, s.Minor); GLFW.WindowHint(WindowHintBool.OpenGLForwardCompat, s.Profile != GLContextProfile.Compatibility); GLFW.WindowHint(WindowHintBool.SrgbCapable, true); switch (s.Profile) { case GLContextProfile.Compatibility: GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Any); GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlApi); break; case GLContextProfile.Core: GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Core); GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlApi); break; case GLContextProfile.Es: GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Any); GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlEsApi); break; } GLFW.WindowHint(WindowHintContextApi.ContextCreationApi, s.CreationApi == GLContextCreationApi.Egl ? ContextApi.EglContextApi : ContextApi.NativeContextApi); #if !FULL_RELEASE if (s.CreationApi == GLContextCreationApi.Egl && !_eglLoaded && OperatingSystem.IsWindows()) { // On non-published builds (so, development), GLFW can't find libEGL.dll // because it'll be in runtimes/<rid>/native/ instead of next to the actual executable. // We manually preload the library here so that GLFW will find it when it does its thing. NativeLibrary.TryLoad( "libEGL.dll", typeof(Clyde).Assembly, DllImportSearchPath.SafeDirectories, out _); _eglLoaded = true; } #endif } Monitor *monitor = null; if (parameters.Monitor != null && _winThreadMonitors.TryGetValue(parameters.Monitor.Id, out var monitorReg)) { monitor = monitorReg.Ptr; var mode = GLFW.GetVideoMode(monitor); // Set refresh rate to monitor's so that GLFW doesn't manually select one. GLFW.WindowHint(WindowHintInt.RefreshRate, mode->RefreshRate); } else { GLFW.WindowHint(WindowHintInt.RefreshRate, -1); } GLFW.WindowHint(WindowHintBool.Visible, false); GLFW.WindowHint(WindowHintInt.RedBits, 8); GLFW.WindowHint(WindowHintInt.GreenBits, 8); GLFW.WindowHint(WindowHintInt.BlueBits, 8); GLFW.WindowHint(WindowHintInt.AlphaBits, 8); GLFW.WindowHint(WindowHintInt.StencilBits, 8); var window = GLFW.CreateWindow( parameters.Width, parameters.Height, parameters.Title, parameters.Fullscreen ? monitor : null, contextShare); // Check if window failed to create. if (window == null) { return(null); } if (parameters.Maximized) { GLFW.GetMonitorPos(monitor, out var x, out var y); GLFW.SetWindowPos(window, x, y); GLFW.MaximizeWindow(window); } if ((parameters.Styles & OSWindowStyles.NoTitleOptions) != 0) { if (OperatingSystem.IsWindows()) { var hWnd = (HWND)GLFW.GetWin32Window(window); DebugTools.Assert(hWnd != HWND.NULL); Windows.SetWindowLongPtrW( hWnd, GWL.GWL_STYLE, // Cast to long here to work around a bug in rider with nint bitwise operators. (nint)((long)Windows.GetWindowLongPtrW(hWnd, GWL.GWL_STYLE) & ~WS.WS_SYSMENU)); } else { _sawmill.Warning("OSWindowStyles.NoTitleOptions not implemented on this platform"); } } if (ownerWindow != null) { if (OperatingSystem.IsWindows()) { var hWnd = (HWND)GLFW.GetWin32Window(window); var ownerHWnd = (HWND)GLFW.GetWin32Window(ownerWindow); DebugTools.Assert(hWnd != HWND.NULL); Windows.SetWindowLongPtrW( hWnd, GWLP.GWLP_HWNDPARENT, ownerHWnd); } else { _sawmill.Warning("owner windows not implemented on this platform"); } if (parameters.StartupLocation == WindowStartupLocation.CenterOwner) { // TODO: Maybe include window frames in size calculations here? // Figure out frame sizes of both windows. GLFW.GetWindowPos(ownerWindow, out var ownerX, out var ownerY); GLFW.GetWindowSize(ownerWindow, out var ownerW, out var ownerH); // Re-fetch this in case DPI scaling is changing it I guess. GLFW.GetWindowSize(window, out var thisW, out var thisH); GLFW.SetWindowPos(window, ownerX + (ownerW - thisW) / 2, ownerY + (ownerH - thisH) / 2); } } if (parameters.Visible) { GLFW.ShowWindow(window); } return(window); }
private Window *CreateGlfwWindowForRenderer( Renderer r, WindowCreateParameters parameters, Window *contextShare) { #if DEBUG GLFW.WindowHint(WindowHintBool.OpenGLDebugContext, true); #endif GLFW.WindowHint(WindowHintString.X11ClassName, "SS14"); GLFW.WindowHint(WindowHintString.X11InstanceName, "SS14"); if (r == Renderer.OpenGL33) { GLFW.WindowHint(WindowHintInt.ContextVersionMajor, 3); GLFW.WindowHint(WindowHintInt.ContextVersionMinor, 3); GLFW.WindowHint(WindowHintBool.OpenGLForwardCompat, true); GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlApi); GLFW.WindowHint(WindowHintContextApi.ContextCreationApi, ContextApi.NativeContextApi); GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Core); GLFW.WindowHint(WindowHintBool.SrgbCapable, true); } else if (r == Renderer.OpenGL31) { GLFW.WindowHint(WindowHintInt.ContextVersionMajor, 3); GLFW.WindowHint(WindowHintInt.ContextVersionMinor, 1); GLFW.WindowHint(WindowHintBool.OpenGLForwardCompat, false); GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlApi); GLFW.WindowHint(WindowHintContextApi.ContextCreationApi, ContextApi.NativeContextApi); GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Any); GLFW.WindowHint(WindowHintBool.SrgbCapable, true); } else if (r == Renderer.OpenGLES2) { GLFW.WindowHint(WindowHintInt.ContextVersionMajor, 2); GLFW.WindowHint(WindowHintInt.ContextVersionMinor, 0); GLFW.WindowHint(WindowHintBool.OpenGLForwardCompat, true); GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlEsApi); // GLES2 is initialized through EGL to allow ANGLE usage. // (It may be an idea to make this a configuration cvar) GLFW.WindowHint(WindowHintContextApi.ContextCreationApi, ContextApi.EglContextApi); GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Any); GLFW.WindowHint(WindowHintBool.SrgbCapable, false); if (!_eglLoaded && OperatingSystem.IsWindows()) { // On non-published builds (so, development), GLFW can't find libEGL.dll // because it'll be in runtimes/<rid>/native/ instead of next to the actual executable. // We manually preload the library here so that GLFW will find it when it does its thing. NativeLibrary.TryLoad( "libEGL.dll", typeof(Clyde).Assembly, DllImportSearchPath.SafeDirectories, out _); _eglLoaded = true; } } Monitor *monitor = null; if (parameters.Monitor != null && _winThreadMonitors.TryGetValue(parameters.Monitor.Id, out var monitorReg)) { monitor = monitorReg.Ptr; } GLFW.WindowHint(WindowHintBool.Visible, false); var window = GLFW.CreateWindow( parameters.Width, parameters.Height, parameters.Title, parameters.Fullscreen ? monitor : null, contextShare); // Check if window failed to create. if (window == null) { return(null); } if (parameters.Maximized) { GLFW.GetMonitorPos(monitor, out var x, out var y); GLFW.SetWindowPos(window, x, y); GLFW.MaximizeWindow(window); } if (parameters.Visible) { GLFW.ShowWindow(window); } return(window); }
private Window *CreateGlfwWindowForRenderer( Renderer r, WindowCreateParameters parameters, Window *contextShare) { #if DEBUG GLFW.WindowHint(WindowHintBool.OpenGLDebugContext, true); #endif GLFW.WindowHint(WindowHintString.X11ClassName, "SS14"); GLFW.WindowHint(WindowHintString.X11InstanceName, "SS14"); if (r == Renderer.OpenGL33) { GLFW.WindowHint(WindowHintInt.ContextVersionMajor, 3); GLFW.WindowHint(WindowHintInt.ContextVersionMinor, 3); GLFW.WindowHint(WindowHintBool.OpenGLForwardCompat, true); GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlApi); GLFW.WindowHint(WindowHintContextApi.ContextCreationApi, ContextApi.NativeContextApi); GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Core); GLFW.WindowHint(WindowHintBool.SrgbCapable, true); } else if (r == Renderer.OpenGL31) { GLFW.WindowHint(WindowHintInt.ContextVersionMajor, 3); GLFW.WindowHint(WindowHintInt.ContextVersionMinor, 1); GLFW.WindowHint(WindowHintBool.OpenGLForwardCompat, false); GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlApi); GLFW.WindowHint(WindowHintContextApi.ContextCreationApi, ContextApi.NativeContextApi); GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Any); GLFW.WindowHint(WindowHintBool.SrgbCapable, true); } else if (r == Renderer.OpenGLES2) { GLFW.WindowHint(WindowHintInt.ContextVersionMajor, 2); GLFW.WindowHint(WindowHintInt.ContextVersionMinor, 0); GLFW.WindowHint(WindowHintBool.OpenGLForwardCompat, true); GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlEsApi); // GLES2 is initialized through EGL to allow ANGLE usage. // (It may be an idea to make this a configuration cvar) GLFW.WindowHint(WindowHintContextApi.ContextCreationApi, ContextApi.EglContextApi); GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Any); GLFW.WindowHint(WindowHintBool.SrgbCapable, false); } Monitor *monitor = null; if (parameters.Monitor != null && _winThreadMonitors.TryGetValue(parameters.Monitor.Id, out var monitorReg)) { monitor = monitorReg.Ptr; } GLFW.WindowHint(WindowHintBool.Visible, false); var window = GLFW.CreateWindow( parameters.Width, parameters.Height, parameters.Title, parameters.Fullscreen ? monitor : null, contextShare); // Check if window failed to create. if (window == null) { return(null); } if (parameters.Maximized) { GLFW.GetMonitorPos(monitor, out var x, out var y); GLFW.SetWindowPos(window, x, y); GLFW.MaximizeWindow(window); } if (parameters.Visible) { GLFW.ShowWindow(window); } return(window); }