4 * The freeglut library private include file.
6 * Copyright (c) 2015 Manuel Bachmann. All Rights Reserved.
7 * Written by Manuel Bachmann, <tarnyko@tarnyko.net>
8 * Creation date: Tue Mar 17, 2015
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #ifndef FREEGLUT_INTERNAL_WL_H
29 #define FREEGLUT_INTERNAL_WL_H
32 /* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */
33 #include "egl/fg_internal_egl.h"
34 #include <wayland-egl.h>
35 #include <wayland-client.h>
36 #include <wayland-cursor.h>
37 #include <xkbcommon/xkbcommon.h>
40 /* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
41 /* The structure used by display initialization in fg_init.c */
42 typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
43 struct tagSFG_PlatformDisplay
45 struct tagSFG_PlatformDisplayEGL egl;
47 struct wl_display* display; /* The display we are being run in */
48 struct wl_registry* registry; /* The global interface registry */
49 struct wl_compositor* compositor; /* The compositor */
50 struct wl_shell* shell; /* The shell, AKA window manager */
51 struct wl_seat* seat; /* The seat, references input devices */
53 struct xkb_context* xkb_context; /* The global XKB keyboard context */
54 struct xkb_state* xkb_state; /* The current XKB keyboard state */
55 struct wl_keyboard* keyboard; /* The keyboard input device */
56 struct wl_pointer* pointer; /* The pointer input device (mouse) */
57 struct wl_touch* touch; /* The touchscreen input device */
59 struct wl_shm* shm; /* The software rendering engine */
60 struct wl_cursor_theme* cursor_theme; /* The pointer cursor theme */
64 /* The structure used by window creation in fg_window.c */
65 typedef struct tagSFG_PlatformContext SFG_PlatformContext;
66 struct tagSFG_PlatformContext
68 struct tagSFG_PlatformContextEGL egl;
69 GLboolean pointer_button_pressed;
71 struct wl_surface* surface; /* The drawing surface */
72 struct wl_shell_surface* shsurface; /* The shell surface, has states */
73 struct wl_egl_window* egl_window; /* Binding between WL/EGL surfaces */
75 struct wl_cursor* cursor; /* The active cursor */
76 struct wl_surface* cursor_surface; /* The active cursor surface */
80 /* The window state description. This structure should be kept portable. */
81 typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;
82 struct tagSFG_PlatformWindowState
84 int OldWidth; /* Window width from before a resize */
85 int OldHeight; /* " height " " " " */
89 /* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */
91 * Initial defines from "js.h" starting around line 33 with the existing "fg_joystick.c"
94 # ifdef HAVE_SYS_IOCTL_H
95 # include <sys/ioctl.h>
104 # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
105 /* XXX The below hack is done until freeglut's autoconf is updated. */
106 # define HAVE_USB_JS 1
108 # include <sys/joystick.h>
109 # define JS_DATA_TYPE joystick
110 # define JS_RETURN (sizeof(struct JS_DATA_TYPE))
113 # if defined(__linux__)
114 # include <linux/joystick.h>
116 /* check the joystick driver version */
117 # if defined(JS_VERSION) && JS_VERSION >= 0x010000
120 # else /* Not BSD or Linux */
124 * We'll put these values in and that should
125 * allow the code to at least compile when there is
126 * no support. The JS open routine should error out
127 * and shut off all the code downstream anyway and if
128 * the application doesn't use a joystick we'll be fine.
138 # define JS_RETURN (sizeof(struct JS_DATA_TYPE))
142 /* XXX It might be better to poll the operating system for the numbers of buttons and
143 * XXX axes and then dynamically allocate the arrays.
145 # define _JS_MAX_AXES 16
146 typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
147 struct tagSFG_PlatformJoystick
149 # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
150 struct os_specific_s *os;
156 float tmp_axes [ _JS_MAX_AXES ];
158 struct JS_DATA_TYPE js;
166 /* Menu font and color definitions */
167 #define FREEGLUT_MENU_FONT GLUT_BITMAP_HELVETICA_18
169 #define FREEGLUT_MENU_PEN_FORE_COLORS {0.0f, 0.0f, 0.0f, 1.0f}
170 #define FREEGLUT_MENU_PEN_BACK_COLORS {0.70f, 0.70f, 0.70f, 1.0f}
171 #define FREEGLUT_MENU_PEN_HFORE_COLORS {0.0f, 0.0f, 0.0f, 1.0f}
172 #define FREEGLUT_MENU_PEN_HBACK_COLORS {1.0f, 1.0f, 1.0f, 1.0f}
175 #endif /* FREEGLUT_INTERNAL_WL_H */