Ejemplo n.º 1
0
        public Window(int width, int height, string title)
        {
            if (Glfw.Init() < 0)
            {
                Console.WriteLine("unable to initialize glfw");
                Environment.Exit(-1);
            }

            Glfw.WindowHint((int)State.ContextVersionMajor, 3);
            Glfw.WindowHint((int)State.ContextVersionMinor, 3);

            window = Glfw.CreateWindow(width, height, title, null, null);
            if (window == null)
            {
                Console.WriteLine("unable to create window");
                Glfw.Terminate();
                Environment.Exit(-1);
            }

            Gl.Initialize();
            Glfw.MakeContextCurrent(window);

            Glfw.SwapInterval(1);

            Glfw.SetWindowSizeCallback(window, delegate { UpdateViewportSize(); });
            Glfw.SetKeyCallback(window, KeyPress);

            Glfw.SetInputMode(window, (int)State.Cursor, (int)State.CursorDisabled);

            Singleton = this;
        }
        private void initWindow()
        {
            GLFW.glfwInit();

            GLFW.glfwWindowHint(GLFWEnum.GLFW_CLIENT_API, GLFWEnum.GLFW_NO_API);
            GLFW.glfwWindowHint(GLFWEnum.GLFW_RESIZABLE, GLFWEnum.GLFW_FALSE);

            window = GLFW.glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", null, null);
        }
Ejemplo n.º 3
0
        private void initWindow()
        {
            GLFW.glfwInit();

            GLFW.glfwWindowHint(GLFWEnum.GLFW_CLIENT_API, GLFWEnum.GLFW_NO_API);
            GLFW.glfwWindowHint(GLFWEnum.GLFW_RESIZABLE, GLFWEnum.GLFW_FALSE);

            window = GLFW.glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", null, null);
            GLFW.glfwSetWindowUserPointer(window, this);
            GLFW.glfwSetWindowSizeCallback(window, this.onWindowResized);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            GLFW3.ConfigureNativesDirectory("../../../../lib/" + GLFW3.ARCHITECTURE + "/");

            GLFW3.glfwSetErrorCallback(callbackError);

            bool       result = GLFW3.glfwInit();
            GLFWwindow window = GLFW3.glfwCreateWindow(800, 400, "glfw-net/" + GLFW3.glfwGetVersionString(), GLFWmonitor.NULL, GLFWwindow.NULL);

            var imgCursor = new GLFWimage {
                width  = 16, height = 16,
                pixels = new byte[16 * 16 * 4]
            };

            for (int x = 0; x < imgCursor.width; x++)
            {
                for (int y = 0; y < imgCursor.height; y++)
                {
                    imgCursor.pixels[((x * imgCursor.width) + y) * 4 + 0] = 0xFF;
                    imgCursor.pixels[((x * imgCursor.width) + y) * 4 + 1] = 0xFF;
                    imgCursor.pixels[((x * imgCursor.width) + y) * 4 + 2] = 0xFF;
                    imgCursor.pixels[((x * imgCursor.width) + y) * 4 + 3] = 0xFF;
                }
            }

            //var cursor = GLFW3.glfwCreateCursor(imgCursor, 0, 0);
            //GLFW3.glfwSetCursor(window, cursor);

            GLFW3.glfwSetWindowPosCallback(window, callbackWindowPos);
            GLFW3.glfwSetWindowSizeCallback(window, callbackWindowSize);

            var ramp = GLFW3.glfwGetGammaRamp(GLFW3.glfwGetPrimaryMonitor());

            for (int i = 0; i < ramp.size; i++)
            {
                ramp.red[i]   = ramp.green[i];
                ramp.blue[i]  = ramp.green[i];
                ramp.green[i] = ramp.green[i];
            }
            //GLFW3.glfwSetGammaRamp(GLFW3.glfwGetPrimaryMonitor(), ref ramp);

            while (!GLFW3.glfwWindowShouldClose(window))
            {
                GLFW3.glfwSwapBuffers(window);
                GLFW3.glfwPollEvents();
            }

            GLFW3.glfwTerminate();
        }
Ejemplo n.º 5
0
 static void callbackWindowSize(GLFWwindow window, int width, int height)
 {
     Console.WriteLine("[glfw_window_size][ w: {0}, h: {1} ]", width, height);
 }
Ejemplo n.º 6
0
 /*! @brief Makes the specified window visible.
  *
  *  This function makes the specified window visible if it was previously
  *  hidden.  If the window is already visible or is in full screen mode, this
  *  function does nothing.
  *
  *  @param[in] window The window to make visible.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref window_hide
  *  @sa glfwHideWindow
  *
  *  @since Added in GLFW 3.0.
  *
  *  @ingroup window
  */
 internal static extern void glfwShowWindow(GLFWwindow* window);
Ejemplo n.º 7
0
 /*! @brief Returns the monitor that the window uses for full screen mode.
  *
  *  This function returns the handle of the monitor that the specified window is
  *  in full screen on.
  *
  *  @param[in] window The window to query.
  *  @return The monitor, or `NULL` if the window is in windowed mode or an error
  *  occurred.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref window_monitor
  *
  *  @since Added in GLFW 3.0.
  *
  *  @ingroup window
  */
 internal static extern GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
Ejemplo n.º 8
0
 /*! @brief Retrieves the size of the framebuffer of the specified window.
  *
  *  This function retrieves the size, in pixels, of the framebuffer of the
  *  specified window.  If you wish to retrieve the size of the window in screen
  *  coordinates, see @ref glfwGetWindowSize.
  *
  *  Any or all of the size arguments may be `NULL`.  If an error occurs, all
  *  non-`NULL` size arguments will be set to zero.
  *
  *  @param[in] window The window whose framebuffer to query.
  *  @param[out] width Where to store the width, in pixels, of the framebuffer,
  *  or `NULL`.
  *  @param[out] height Where to store the height, in pixels, of the framebuffer,
  *  or `NULL`.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref window_fbsize
  *  @sa glfwSetFramebufferSizeCallback
  *
  *  @since Added in GLFW 3.0.
  *
  *  @ingroup window
  */
 internal static extern void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
Ejemplo n.º 9
0
 /*! @brief Iconifies the specified window.
  *
  *  This function iconifies (minimizes) the specified window if it was
  *  previously restored.  If the window is already iconified, this function does
  *  nothing.
  *
  *  If the specified window is a full screen window, the original monitor
  *  resolution is restored until the window is restored.
  *
  *  @param[in] window The window to iconify.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref window_iconify
  *  @sa glfwRestoreWindow
  *
  *  @since Added in GLFW 2.1.
  *
  *  @par
  *  __GLFW 3:__ Added window handle parameter.
  *
  *  @ingroup window
  */
 internal static extern void glfwIconifyWindow(GLFWwindow* window);
Ejemplo n.º 10
0
 /*! @brief Sets the title of the specified window.
  *
  *  This function sets the window title, encoded as UTF-8, of the specified
  *  window.
  *
  *  @param[in] window The window whose title to change.
  *  @param[in] title The UTF-8 encoded window title.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref window_title
  *
  *  @since Added in GLFW 1.0.
  *
  *  @par
  *  __GLFW 3:__ Added window handle parameter.
  *
  *  @ingroup window
  */
 internal static extern void glfwSetWindowTitle(GLFWwindow* window, const char* title);
Ejemplo n.º 11
0
 /*! @brief Sets the position of the client area of the specified window.
  *
  *  This function sets the position, in screen coordinates, of the upper-left
  *  corner of the client area of the specified windowed mode window.  If the
  *  window is a full screen window, this function does nothing.
  *
  *  __Do not use this function__ to move an already visible window unless you
  *  have very good reasons for doing so, as it will confuse and annoy the user.
  *
  *  The window manager may put limits on what positions are allowed.  GLFW
  *  cannot and should not override these limits.
  *
  *  @param[in] window The window to query.
  *  @param[in] xpos The x-coordinate of the upper-left corner of the client area.
  *  @param[in] ypos The y-coordinate of the upper-left corner of the client area.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref window_pos
  *  @sa glfwGetWindowPos
  *
  *  @since Added in GLFW 1.0.
  *
  *  @par
  *  __GLFW 3:__ Added window handle parameter.
  *
  *  @ingroup window
  */
 internal static extern void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
Ejemplo n.º 12
0
 /*! @brief Sets the mouse button callback.
  *
  *  This function sets the mouse button callback of the specified window, which
  *  is called when a mouse button is pressed or released.
  *
  *  When a window loses input focus, it will generate synthetic mouse button
  *  release events for all pressed mouse buttons.  You can tell these events
  *  from user-generated events by the fact that the synthetic ones are generated
  *  after the focus loss event has been processed, i.e. after the
  *  [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
  *
  *  @param[in] window The window whose callback to set.
  *  @param[in] cbfun The new callback, or `NULL` to remove the currently set
  *  callback.
  *  @return The previously set callback, or `NULL` if no callback was set or the
  *  library had not been [initialized](@ref intro_init).
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref input_mouse_button
  *
  *  @since Added in GLFW 1.0.
  *
  *  @par
  *  __GLFW 3:__ Added window handle parameter.  Updated callback signature.
  *
  *  @ingroup input
  */
 internal static extern GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
Ejemplo n.º 13
0
 /*! @brief Sets the cursor position callback.
  *
  *  This function sets the cursor position callback of the specified window,
  *  which is called when the cursor is moved.  The callback is provided with the
  *  position, in screen coordinates, relative to the upper-left corner of the
  *  client area of the window.
  *
  *  @param[in] window The window whose callback to set.
  *  @param[in] cbfun The new callback, or `NULL` to remove the currently set
  *  callback.
  *  @return The previously set callback, or `NULL` if no callback was set or the
  *  library had not been [initialized](@ref intro_init).
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref cursor_pos
  *
  *  @since Added in GLFW 3.0.  Replaces `glfwSetMousePosCallback`.
  *
  *  @ingroup input
  */
 internal static extern GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun);
Ejemplo n.º 14
0
 /*! @brief Sets the key callback.
  *
  *  This function sets the key callback of the specified window, which is called
  *  when a key is pressed, repeated or released.
  *
  *  The key functions deal with physical keys, with layout independent
  *  [key tokens](@ref keys) named after their values in the standard US keyboard
  *  layout.  If you want to input text, use the
  *  [character callback](@ref glfwSetCharCallback) instead.
  *
  *  When a window loses input focus, it will generate synthetic key release
  *  events for all pressed keys.  You can tell these events from user-generated
  *  events by the fact that the synthetic ones are generated after the focus
  *  loss event has been processed, i.e. after the
  *  [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
  *
  *  The scancode of a key is specific to that platform or sometimes even to that
  *  machine.  Scancodes are intended to allow users to bind keys that don't have
  *  a GLFW key token.  Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
  *  state is not saved and so it cannot be queried with @ref glfwGetKey.
  *
  *  Sometimes GLFW needs to generate synthetic key events, in which case the
  *  scancode may be zero.
  *
  *  @param[in] window The window whose callback to set.
  *  @param[in] cbfun The new key callback, or `NULL` to remove the currently
  *  set callback.
  *  @return The previously set callback, or `NULL` if no callback was set or the
  *  library had not been [initialized](@ref intro_init).
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref input_key
  *
  *  @since Added in GLFW 1.0.
  *
  *  @par
  *  __GLFW 3:__ Added window handle parameter.  Updated callback signature.
  *
  *  @ingroup input
  */
 internal static extern GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun);
Ejemplo n.º 15
0
 /*! @brief Sets the Unicode character with modifiers callback.
  *
  *  This function sets the character with modifiers callback of the specified
  *  window, which is called when a Unicode character is input regardless of what
  *  modifier keys are used.
  *
  *  The character with modifiers callback is intended for implementing custom
  *  Unicode character input.  For regular Unicode text input, see the
  *  [character callback](@ref glfwSetCharCallback).  Like the character
  *  callback, the character with modifiers callback deals with characters and is
  *  keyboard layout dependent.  Characters do not map 1:1 to physical keys, as
  *  a key may produce zero, one or more characters.  If you want to know whether
  *  a specific physical key was pressed or released, see the
  *  [key callback](@ref glfwSetKeyCallback) instead.
  *
  *  @param[in] window The window whose callback to set.
  *  @param[in] cbfun The new callback, or `NULL` to remove the currently set
  *  callback.
  *  @return The previously set callback, or `NULL` if no callback was set or an
  *  error occurred.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref input_char
  *
  *  @since Added in GLFW 3.1.
  *
  *  @ingroup input
  */
 internal static extern GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun cbfun);
Ejemplo n.º 16
0
 /*! @brief Sets the cursor for the window.
  *
  *  This function sets the cursor image to be used when the cursor is over the
  *  client area of the specified window.  The set cursor will only be visible
  *  when the [cursor mode](@ref cursor_mode) of the window is
  *  `GLFW_CURSOR_NORMAL`.
  *
  *  On some platforms, the set cursor may not be visible unless the window also
  *  has input focus.
  *
  *  @param[in] window The window to set the cursor for.
  *  @param[in] cursor The cursor to set, or `NULL` to switch back to the default
  *  arrow cursor.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref cursor_object
  *
  *  @since Added in GLFW 3.1.
  *
  *  @ingroup input
  */
 internal static extern void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
Ejemplo n.º 17
0
 /*! @brief Sets the position of the cursor, relative to the client area of the
  *  window.
  *
  *  This function sets the position, in screen coordinates, of the cursor
  *  relative to the upper-left corner of the client area of the specified
  *  window.  The window must have input focus.  If the window does not have
  *  input focus when this function is called, it fails silently.
  *
  *  __Do not use this function__ to implement things like camera controls.  GLFW
  *  already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
  *  cursor, transparently re-centers it and provides unconstrained cursor
  *  motion.  See @ref glfwSetInputMode for more information.
  *
  *  If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
  *  unconstrained and limited only by the minimum and maximum values of
  *  a `double`.
  *
  *  @param[in] window The desired window.
  *  @param[in] xpos The desired x-coordinate, relative to the left edge of the
  *  client area.
  *  @param[in] ypos The desired y-coordinate, relative to the top edge of the
  *  client area.
  *
  *  @remarks __X11:__ Due to the asynchronous nature of a modern X desktop, it
  *  may take a moment for the window focus event to arrive.  This means you will
  *  not be able to set the cursor position directly after window creation.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref cursor_pos
  *  @sa glfwGetCursorPos
  *
  *  @since Added in GLFW 3.0.  Replaces `glfwSetMousePos`.
  *
  *  @ingroup input
  */
 internal static extern void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
Ejemplo n.º 18
0
 /*! @brief Returns the last reported state of a mouse button for the specified
  *  window.
  *
  *  This function returns the last state reported for the specified mouse button
  *  to the specified window.  The returned state is one of `GLFW_PRESS` or
  *  `GLFW_RELEASE`.
  *
  *  If the `GLFW_STICKY_MOUSE_BUTTONS` input mode is enabled, this function
  *  `GLFW_PRESS` the first time you call it for a mouse button that was pressed,
  *  even if that mouse button has already been released.
  *
  *  @param[in] window The desired window.
  *  @param[in] button The desired [mouse button](@ref buttons).
  *  @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref input_mouse_button
  *
  *  @since Added in GLFW 1.0.
  *
  *  @par
  *  __GLFW 3:__ Added window handle parameter.
  *
  *  @ingroup input
  */
 internal static extern int glfwGetMouseButton(GLFWwindow* window, int button);
Ejemplo n.º 19
0
        private void onWindowResized(GLFWwindow window, int width, int height)
        {
            var app = (HelloTriangleApplication03)GLFW.glfwGetWindowUserPointer(window);

            app.recreateSwapChain();
        }
Ejemplo n.º 20
0
 /*! @brief Sets the cursor enter/exit callback.
  *
  *  This function sets the cursor boundary crossing callback of the specified
  *  window, which is called when the cursor enters or leaves the client area of
  *  the window.
  *
  *  @param[in] window The window whose callback to set.
  *  @param[in] cbfun The new callback, or `NULL` to remove the currently set
  *  callback.
  *  @return The previously set callback, or `NULL` if no callback was set or the
  *  library had not been [initialized](@ref intro_init).
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref cursor_enter
  *
  *  @since Added in GLFW 3.0.
  *
  *  @ingroup input
  */
 internal static extern GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun);
Ejemplo n.º 21
0
 /*! @brief Returns the last reported state of a keyboard key for the specified
  *  window.
  *
  *  This function returns the last state reported for the specified key to the
  *  specified window.  The returned state is one of `GLFW_PRESS` or
  *  `GLFW_RELEASE`.  The higher-level action `GLFW_REPEAT` is only reported to
  *  the key callback.
  *
  *  If the `GLFW_STICKY_KEYS` input mode is enabled, this function returns
  *  `GLFW_PRESS` the first time you call it for a key that was pressed, even if
  *  that key has already been released.
  *
  *  The key functions deal with physical keys, with [key tokens](@ref keys)
  *  named after their use on the standard US keyboard layout.  If you want to
  *  input text, use the Unicode character callback instead.
  *
  *  The [modifier key bit masks](@ref mods) are not key tokens and cannot be
  *  used with this function.
  *
  *  @param[in] window The desired window.
  *  @param[in] key The desired [keyboard key](@ref keys).  `GLFW_KEY_UNKNOWN` is
  *  not a valid key for this function.
  *  @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref input_key
  *
  *  @since Added in GLFW 1.0.
  *
  *  @par
  *  __GLFW 3:__ Added window handle parameter.
  *
  *  @ingroup input
  */
 internal static extern int glfwGetKey(GLFWwindow* window, int key);
Ejemplo n.º 22
0
 /*! @brief Sets the scroll callback.
  *
  *  This function sets the scroll callback of the specified window, which is
  *  called when a scrolling device is used, such as a mouse wheel or scrolling
  *  area of a touchpad.
  *
  *  The scroll callback receives all scrolling input, like that from a mouse
  *  wheel or a touchpad scrolling area.
  *
  *  @param[in] window The window whose callback to set.
  *  @param[in] cbfun The new scroll callback, or `NULL` to remove the currently
  *  set callback.
  *  @return The previously set callback, or `NULL` if no callback was set or the
  *  library had not been [initialized](@ref intro_init).
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref scrolling
  *
  *  @since Added in GLFW 3.0.  Replaces `glfwSetMouseWheelCallback`.
  *
  *  @ingroup input
  */
 internal static extern GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun);
Ejemplo n.º 23
0
 /*! @brief Retrieves the position of the client area of the specified window.
  *
  *  This function retrieves the position, in screen coordinates, of the
  *  upper-left corner of the client area of the specified window.
  *
  *  Any or all of the position arguments may be `NULL`.  If an error occurs, all
  *  non-`NULL` position arguments will be set to zero.
  *
  *  @param[in] window The window to query.
  *  @param[out] xpos Where to store the x-coordinate of the upper-left corner of
  *  the client area, or `NULL`.
  *  @param[out] ypos Where to store the y-coordinate of the upper-left corner of
  *  the client area, or `NULL`.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref window_pos
  *  @sa glfwSetWindowPos
  *
  *  @since Added in GLFW 3.0.
  *
  *  @ingroup window
  */
 internal static extern void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
Ejemplo n.º 24
0
 /*! @brief Sets the file drop callback.
  *
  *  This function sets the file drop callback of the specified window, which is
  *  called when one or more dragged files are dropped on the window.
  *
  *  Because the path array and its strings may have been generated specifically
  *  for that event, they are not guaranteed to be valid after the callback has
  *  returned.  If you wish to use them after the callback returns, you need to
  *  make a deep copy.
  *
  *  @param[in] window The window whose callback to set.
  *  @param[in] cbfun The new file drop callback, or `NULL` to remove the
  *  currently set callback.
  *  @return The previously set callback, or `NULL` if no callback was set or the
  *  library had not been [initialized](@ref intro_init).
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref path_drop
  *
  *  @since Added in GLFW 3.1.
  *
  *  @ingroup input
  */
 internal static extern GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun cbfun);
Ejemplo n.º 25
0
 /*! @brief Sets the size of the client area of the specified window.
  *
  *  This function sets the size, in screen coordinates, of the client area of
  *  the specified window.
  *
  *  For full screen windows, this function selects and switches to the resolution
  *  closest to the specified size, without affecting the window's context.  As
  *  the context is unaffected, the bit depths of the framebuffer remain
  *  unchanged.
  *
  *  The window manager may put limits on what sizes are allowed.  GLFW cannot
  *  and should not override these limits.
  *
  *  @param[in] window The window to resize.
  *  @param[in] width The desired width of the specified window.
  *  @param[in] height The desired height of the specified window.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref window_size
  *  @sa glfwGetWindowSize
  *
  *  @since Added in GLFW 1.0.
  *
  *  @par
  *  __GLFW 3:__ Added window handle parameter.
  *
  *  @ingroup window
  */
 internal static extern void glfwSetWindowSize(GLFWwindow* window, int width, int height);
Ejemplo n.º 26
0
 /*! @brief Sets the clipboard to the specified string.
  *
  *  This function sets the system clipboard to the specified, UTF-8 encoded
  *  string.
  *
  *  @param[in] window The window that will own the clipboard contents.
  *  @param[in] string A UTF-8 encoded string.
  *
  *  @par Pointer Lifetime
  *  The specified string is copied before this function returns.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref clipboard
  *  @sa glfwGetClipboardString
  *
  *  @since Added in GLFW 3.0.
  *
  *  @ingroup input
  */
 internal static extern void glfwSetClipboardString(GLFWwindow* window, const char* string);
Ejemplo n.º 27
0
 /*! @brief Retrieves the size of the frame of the window.
  *
  *  This function retrieves the size, in screen coordinates, of each edge of the
  *  frame of the specified window.  This size includes the title bar, if the
  *  window has one.  The size of the frame may vary depending on the
  *  [window-related hints](@ref window_hints_wnd) used to create it.
  *
  *  Because this function retrieves the size of each window frame edge and not
  *  the offset along a particular coordinate axis, the retrieved values will
  *  always be zero or positive.
  *
  *  Any or all of the size arguments may be `NULL`.  If an error occurs, all
  *  non-`NULL` size arguments will be set to zero.
  *
  *  @param[in] window The window whose frame size to query.
  *  @param[out] left Where to store the size, in screen coordinates, of the left
  *  edge of the window frame, or `NULL`.
  *  @param[out] top Where to store the size, in screen coordinates, of the top
  *  edge of the window frame, or `NULL`.
  *  @param[out] right Where to store the size, in screen coordinates, of the
  *  right edge of the window frame, or `NULL`.
  *  @param[out] bottom Where to store the size, in screen coordinates, of the
  *  bottom edge of the window frame, or `NULL`.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref window_size
  *
  *  @since Added in GLFW 3.1.
  *
  *  @ingroup window
  */
 internal static extern void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
Ejemplo n.º 28
0
 /*! @brief Makes the context of the specified window current for the calling
  *  thread.
  *
  *  This function makes the OpenGL or OpenGL ES context of the specified window
  *  current on the calling thread.  A context can only be made current on
  *  a single thread at a time and each thread can have only a single current
  *  context at a time.
  *
  *  By default, making a context non-current implicitly forces a pipeline flush.
  *  On machines that support `GL_KHR_context_flush_control`, you can control
  *  whether a context performs this flush by setting the
  *  [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref window_hints_ctx) window hint.
  *
  *  @param[in] window The window whose context to make current, or `NULL` to
  *  detach the current context.
  *
  *  @par Thread Safety
  *  This function may be called from any thread.
  *
  *  @sa @ref context_current
  *  @sa glfwGetCurrentContext
  *
  *  @since Added in GLFW 3.0.
  *
  *  @ingroup context
  */
 internal static extern void glfwMakeContextCurrent(GLFWwindow* window);
Ejemplo n.º 29
0
 /*! @brief Restores the specified window.
  *
  *  This function restores the specified window if it was previously iconified
  *  (minimized).  If the window is already restored, this function does nothing.
  *
  *  If the specified window is a full screen window, the resolution chosen for
  *  the window is restored on the selected monitor.
  *
  *  @param[in] window The window to restore.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref window_iconify
  *  @sa glfwIconifyWindow
  *
  *  @since Added in GLFW 2.1.
  *
  *  @par
  *  __GLFW 3:__ Added window handle parameter.
  *
  *  @ingroup window
  */
 internal static extern void glfwRestoreWindow(GLFWwindow* window);
Ejemplo n.º 30
0
 /*! @brief Swaps the front and back buffers of the specified window.
  *
  *  This function swaps the front and back buffers of the specified window.  If
  *  the swap interval is greater than zero, the GPU driver waits the specified
  *  number of screen updates before swapping the buffers.
  *
  *  @param[in] window The window whose buffers to swap.
  *
  *  @par Thread Safety
  *  This function may be called from any thread.
  *
  *  @sa @ref buffer_swap
  *  @sa glfwSwapInterval
  *
  *  @since Added in GLFW 1.0.
  *
  *  @par
  *  __GLFW 3:__ Added window handle parameter.
  *
  *  @ingroup window
  */
 internal static extern void glfwSwapBuffers(GLFWwindow* window);
Ejemplo n.º 31
0
 /*! @brief Hides the specified window.
  *
  *  This function hides the specified window if it was previously visible.  If
  *  the window is already hidden or is in full screen mode, this function does
  *  nothing.
  *
  *  @param[in] window The window to hide.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref window_hide
  *  @sa glfwShowWindow
  *
  *  @since Added in GLFW 3.0.
  *
  *  @ingroup window
  */
 internal static extern void glfwHideWindow(GLFWwindow* window);
Ejemplo n.º 32
0
 static void callbackWindowPos(GLFWwindow window, int xpos, int ypos)
 {
     Console.WriteLine("[glfw_window_pos][ x: {0}, y: {1} ]", xpos, ypos);
 }
Ejemplo n.º 33
0
 /*! @brief Returns the value of an input option for the specified window.
  *
  *  This function returns the value of an input option for the specified window.
  *  The mode must be one of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  *  `GLFW_STICKY_MOUSE_BUTTONS`.
  *
  *  @param[in] window The window to query.
  *  @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  *  `GLFW_STICKY_MOUSE_BUTTONS`.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa glfwSetInputMode
  *
  *  @since Added in GLFW 3.0.
  *
  *  @ingroup input
  */
 internal static extern int glfwGetInputMode(GLFWwindow* window, int mode);
Ejemplo n.º 34
0
 /*! @brief Checks the close flag of the specified window.
  *
  *  This function returns the value of the close flag of the specified window.
  *
  *  @param[in] window The window to query.
  *  @return The value of the close flag.
  *
  *  @par Thread Safety
  *  This function may be called from any thread.  Access is not synchronized.
  *
  *  @sa @ref window_close
  *
  *  @since Added in GLFW 3.0.
  *
  *  @ingroup window
  */
 internal static extern int glfwWindowShouldClose(GLFWwindow* window);
Ejemplo n.º 35
0
 internal OpenGLContext(string name)
 {
     if (GLFW.GlfwInit() == 0)
     {
         Console.Error.WriteLine("GLFW failed to initialize!");
         Environment.Exit(1);
     }
     Window = GLFW.GlfwCreateWindow(1920, 1080, name, null, null);
     if (Window == null)
     {
         Console.Error.WriteLine("GLFW failed to open window!");
         GLFW.GlfwTerminate();
         Environment.Exit(1);
     }
     Input = new InputSource();
     GLFW.GlfwMakeContextCurrent(Window);
     StrongReferences = new List <Delegate>();
     {
         GLFWkeyfun cb = KeyCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetKeyCallback(Window, cb);
     }
     {
         GLFWcharfun cb = CharCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetCharCallback(Window, cb);
     }
     {
         GLFWerrorfun cb = ErrorCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetErrorCallback(cb);
     }
     {
         GLFWscrollfun cb = ScrollCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetScrollCallback(Window, cb);
     }
     {
         GLFWcharmodsfun cb = CharModsCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetCharModsCallback(Window, cb);
     }
     {
         GLFWcursorposfun cb = CursorPosCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetCursorPosCallback(Window, cb);
     }
     {
         GLFWwindowposfun cb = WindowPosCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetWindowPosCallback(Window, cb);
     }
     {
         GLFWwindowsizefun cb = WindowSizeCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetWindowSizeCallback(Window, cb);
     }
     {
         GLFWcursorenterfun cb = CursorEnterCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetCursorEnterCallback(Window, cb);
     }
     {
         GLFWmousebuttonfun cb = MouseButtonCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetMouseButtonCallback(Window, cb);
     }
     {
         GLFWwindowfocusfun cb = WindowFocusCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetWindowFocusCallback(Window, cb);
     }
     {
         GLFWwindowiconifyfun cb = WindowIconifyCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetWindowIconifyCallback(Window, cb);
     }
     {
         GLFWframebuffersizefun cb = FrameBufferSizeCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetFramebufferSizeCallback(Window, cb);
     }
 }
Ejemplo n.º 36
0
 /*! @brief Sets the close flag of the specified window.
  *
  *  This function sets the value of the close flag of the specified window.
  *  This can be used to override the user's attempt to close the window, or
  *  to signal that it should be closed.
  *
  *  @param[in] window The window whose flag to change.
  *  @param[in] value The new value.
  *
  *  @par Thread Safety
  *  This function may be called from any thread.  Access is not synchronized.
  *
  *  @sa @ref window_close
  *
  *  @since Added in GLFW 3.0.
  *
  *  @ingroup window
  */
 internal static extern void glfwSetWindowShouldClose(GLFWwindow* window, int value);
Ejemplo n.º 37
0
 /*! @brief Destroys the specified window and its context.
  *
  *  This function destroys the specified window and its context.  On calling
  *  this function, no further callbacks will be called for that window.
  *
  *  If the context of the specified window is current on the main thread, it is
  *  detached before being destroyed.
  *
  *  @param[in] window The window to destroy.
  *
  *  @note The context of the specified window must not be current on any other
  *  thread when this function is called.
  *
  *  @par Reentrancy
  *  This function may not be called from a callback.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa @ref window_creation
  *  @sa glfwCreateWindow
  *
  *  @since Added in GLFW 3.0.  Replaces `glfwCloseWindow`.
  *
  *  @ingroup window
  */
 internal static extern void glfwDestroyWindow(GLFWwindow* window);
Ejemplo n.º 38
0
 /*! @brief Sets an input option for the specified window.
  *
  *  This function sets an input mode option for the specified window.  The mode
  *  must be one of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  *  `GLFW_STICKY_MOUSE_BUTTONS`.
  *
  *  If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
  *  modes:
  *  - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
  *  - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client
  *    area of the window but does not restrict the cursor from leaving.
  *  - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
  *    and unlimited cursor movement.  This is useful for implementing for
  *    example 3D camera controls.
  *
  *  If the mode is `GLFW_STICKY_KEYS`, the value must be either `GL_TRUE` to
  *  enable sticky keys, or `GL_FALSE` to disable it.  If sticky keys are
  *  enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
  *  the next time it is called even if the key had been released before the
  *  call.  This is useful when you are only interested in whether keys have been
  *  pressed but not when or in which order.
  *
  *  If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
  *  `GL_TRUE` to enable sticky mouse buttons, or `GL_FALSE` to disable it.  If
  *  sticky mouse buttons are enabled, a mouse button press will ensure that @ref
  *  glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even if
  *  the mouse button had been released before the call.  This is useful when you
  *  are only interested in whether mouse buttons have been pressed but not when
  *  or in which order.
  *
  *  @param[in] window The window whose input mode to set.
  *  @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  *  `GLFW_STICKY_MOUSE_BUTTONS`.
  *  @param[in] value The new value of the specified input mode.
  *
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *
  *  @sa glfwGetInputMode
  *
  *  @since Added in GLFW 3.0.  Replaces `glfwEnable` and `glfwDisable`.
  *
  *  @ingroup input
  */
 internal static extern void glfwSetInputMode(GLFWwindow* window, int mode, int value);