Ejemplo n.º 1
0
        public static MonitorPtr GetWindowMonitor(WindowPtr window)
        {
            var result = glfwGetWindowMonitor(window);

            CheckError();
            return(result);
        }
Ejemplo n.º 2
0
        public static void SetWindowIcon(WindowPtr window, Image[] images)
        {
            unsafe
            {
                if (images == null || images.Length == 0)
                {
                    glfwSetWindowIcon(window, 0, null);
                    return;
                }

                NativeImage[] nimgs = new NativeImage[images.Length];
                fixed(NativeImage *ptr = &nimgs[0])
                {
                    for (int i = 0; i < images.Length; i++)
                    {
                        fixed(byte *data = &images[i].data[0])
                        {
                            nimgs[i] = new NativeImage(images[i].width, images[i].height, data);
                        }
                    }
                    glfwSetWindowIcon(window, images.Length, ptr);
                    CheckError();
                }
            }
        }
Ejemplo n.º 3
0
 public static void SetWindowSizeLimits(WindowPtr window,
                                        int minWidth, int minHeight,
                                        int maxWidth, int maxHeight)
 {
     glfwSetWindowSizeLimits(window, minWidth, minHeight, maxWidth, maxHeight);
     CheckError();
 }
Ejemplo n.º 4
0
        void CreateWindow()
        {
            GLFW.WindowHint(WindowHint.ClientAPI, (int)ClientAPI.NoAPI);
            window = GLFW.CreateWindow(height, width, "Hello Triangle", MonitorPtr.Null, WindowPtr.Null);

            GLFW.SetWindowSizeCallback(window, OnWindowResized);
        }
Ejemplo n.º 5
0
        public static bool WindowShouldClose(WindowPtr window)
        {
            var result = glfwWindowShouldClose(window);

            CheckError();
            return(result);
        }
Ejemplo n.º 6
0
 public static void SetWindowMonitor(WindowPtr window, MonitorPtr monitor,
                                     int x, int y,
                                     int width, int height,
                                     int refreshRate)
 {
     glfwSetWindowMonitor(window, monitor, x, y, width, height, refreshRate);
     CheckError();
 }
Ejemplo n.º 7
0
 void OnWindowResized(WindowPtr window, int width, int height)
 {
     if (width == 0 || height == 0)
     {
         return;
     }
     recreateSwapchainFlag = true;
 }
Ejemplo n.º 8
0
        void CreateSurface(WindowPtr window)
        {
            var result = (VkResult)GLFW.GLFW.CreateWindowSurface(Instance.Native.native, window, Instance.AllocationCallbacks, out surface.native);

            if (result != VkResult.Success)
            {
                throw new SurfaceException(string.Format("Error creating surface: {0}", result));
            }
        }
Ejemplo n.º 9
0
        public Surface(PhysicalDevice device, WindowPtr window)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }
            if (window == WindowPtr.Null)
            {
                throw new ArgumentNullException(nameof(window));
            }

            Init(device, window);
        }
Ejemplo n.º 10
0
        void Init(PhysicalDevice device, WindowPtr window)
        {
            physicalDevice = device;
            Instance       = device.Instance;

            getCapabilities = Instance.Commands.getCapabilities;
            getFormats      = Instance.Commands.getFormats;
            getModes        = Instance.Commands.getModes;

            CreateSurface(window);

            GetFormats();
            GetModes();
        }
Ejemplo n.º 11
0
        public static GLWindow GetCurrentContext()
        {
            lock (windowMap) {
                WindowPtr ptr = GLFW.GLFW.GetCurrentContext();

                //current context may not have been created with this class, return null in that case
                if (windowMap.ContainsKey(ptr))
                {
                    return(windowMap[GLFW.GLFW.GetCurrentContext()]);
                }
                else
                {
                    return(null);
                }
            }
        }