GLFW++の延長
守矢諏訪子 <suwako@076.moe>、2026-06-24 21:56
コミット 21fbc5ce2ab5659bc786eadfa25c72cf429a5c85
・親 d968d04
・ファイルを見る
7個のファイル、+687 -278
変更
.gitignore
| @@ -1,1 +1,3 @@ | ||
| 1 | 1 | build |
| 2 | +.vs | |
| 3 | +shaderplayground.db |
追加
CHANGELOG.md
| @@ -0,0 +1,2 @@ | ||
| 1 | +# 1.0.0 (2026/0?/??) | |
| 2 | +* 最初リリース |
削除
include/util/glfw.hh
| @@ -1,135 +0,0 @@ | ||
| 1 | -/* | |
| 2 | -Copyright (c) テクニカル諏訪子 | |
| 3 | - | |
| 4 | -Permission is hereby granted to any person obtaining a copy of the software | |
| 5 | -Shader Playground (the "Software") to use, modify, merge, copy, publish, distribute, | |
| 6 | -sublicense, and/or sell copies of the Software, subject to the following conditions: | |
| 7 | - | |
| 8 | - 1. **Origin Attribution**: | |
| 9 | - - You must not misrepresent the origin of the Software; you must not claim | |
| 10 | - you created the original Software. | |
| 11 | - - If the Software is used in a product, you must either: | |
| 12 | - a. Provide clear attribution in the product's documentation, user interface, | |
| 13 | - or other visible areas, **OR** | |
| 14 | - b. Pay the original developers a fee they specify in writing. | |
| 15 | - 2. **Usage Restriction**: | |
| 16 | - - The Software, or any derivative works, dependencies, or libraries | |
| 17 | - incorporating it, must not be used for censorship or to suppress freedom of | |
| 18 | - speech, expression, or creativity. Prohibited uses include, but are not | |
| 19 | - limited to: | |
| 20 | - - Censorship of so-called "hate speech", visuals, non-mainstream opinions, | |
| 21 | - ideas, or objective reality. | |
| 22 | - - Tools or systems designed to restrict access to information or | |
| 23 | - artistic works. | |
| 24 | - 3. **Notice Preservation**: | |
| 25 | - - This license and the above copyright notice must remain intact in all copies | |
| 26 | - of the source code. | |
| 27 | - | |
| 28 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |
| 29 | -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 30 | -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |
| 31 | -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
| 32 | -CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |
| 33 | -OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| 34 | -*/ | |
| 35 | -#ifndef GLFW_HH | |
| 36 | -#define GLFW_HH | |
| 37 | - | |
| 38 | -#include <glfw/glfw3.h> | |
| 39 | -#include "types.hh" | |
| 40 | - | |
| 41 | -namespace glfw { | |
| 42 | - enum class Context { | |
| 43 | - VersionMajor = 0x00022002, | |
| 44 | - VersionMinor = 0x00022003, | |
| 45 | - }; | |
| 46 | - | |
| 47 | - enum class Api { | |
| 48 | - None = 0, | |
| 49 | - OpenGL = 0x00032001, | |
| 50 | - OpenGLES = 0x00032002, | |
| 51 | - }; | |
| 52 | - | |
| 53 | - enum class Robustness { | |
| 54 | - None = 0, | |
| 55 | - NoResetNotification = 0x00032001, | |
| 56 | - LoseContextOnReset = 0x00032002, | |
| 57 | - }; | |
| 58 | - | |
| 59 | - enum OpenGLProfile { | |
| 60 | - Any = 0, | |
| 61 | - Core = 0x00032001, | |
| 62 | - Compat = 0x00032002, | |
| 63 | - }; | |
| 64 | - | |
| 65 | - enum class ButtonMode { | |
| 66 | - Cursor = 0x00032001, | |
| 67 | - StickyKeys = 0x00032002, | |
| 68 | - StickyMouseButtons = 0x00032003, | |
| 69 | - LockKeyMods = 0x00032004, | |
| 70 | - RawMouseMotion = 0x00032005, | |
| 71 | - }; | |
| 72 | - | |
| 73 | - enum class Cursor { | |
| 74 | - Normal = 0x00032001, | |
| 75 | - Hidden = 0x00032002, | |
| 76 | - Disabled = 0x00032003, | |
| 77 | - }; | |
| 78 | - | |
| 79 | - enum class ReleaseBehavior { | |
| 80 | - Any = 0, | |
| 81 | - Flush = 0x00032001, | |
| 82 | - None = 0x00032002, | |
| 83 | - }; | |
| 84 | - | |
| 85 | - enum class ContextApi { | |
| 86 | - Native = 0x00032001, | |
| 87 | - EGL = 0x00032002, | |
| 88 | - OSMESA = 0x00032003, | |
| 89 | - }; | |
| 90 | - | |
| 91 | - class Instance { | |
| 92 | - public: | |
| 93 | - Instance(); | |
| 94 | - ~Instance(); | |
| 95 | - | |
| 96 | - void SetContextMajorVersion(int major); | |
| 97 | - void SetContextMinorVersion(int minor); | |
| 98 | - void SetOpenGLProfile(int profile); | |
| 99 | - void SetForwardCompatibility(bool fc); | |
| 100 | - void CreateWindowHints(); | |
| 101 | - | |
| 102 | - private: | |
| 103 | - int m_Major = 0; | |
| 104 | - int m_Minor = 0; | |
| 105 | - int m_Profile = 0; | |
| 106 | - bool m_ForwardCompat = false; | |
| 107 | - }; // class Instance | |
| 108 | - | |
| 109 | - class Window { | |
| 110 | - public: | |
| 111 | - Window(int width, int height, string title); | |
| 112 | - ~Window(); | |
| 113 | - | |
| 114 | - GLFWwindow *GetWindow() const { return window; } | |
| 115 | - GLFWframebuffersizefun SetFramebufferSizeCallback(); | |
| 116 | - | |
| 117 | - bool ShouldClose() const; | |
| 118 | - void SwapBuffers(); | |
| 119 | - void PollEvents(); | |
| 120 | - | |
| 121 | - void SetClipboardString(string str); | |
| 122 | - string GetClipboardString(); | |
| 123 | - double GetTime(); | |
| 124 | - void SetTime(double time); | |
| 125 | - u64 GetTimerValue(); | |
| 126 | - u64 GetTimerFrequency(); | |
| 127 | - | |
| 128 | - private: | |
| 129 | - GLFWwindow *window = {}; | |
| 130 | - int width = 0; | |
| 131 | - int height = 0; | |
| 132 | - }; // class Window | |
| 133 | -} // namespace glfw | |
| 134 | - | |
| 135 | -#endif |
| @@ -0,0 +1,279 @@ | ||
| 1 | +/* | |
| 2 | +Copyright (c) テクニカル諏訪子 | |
| 3 | + | |
| 4 | +Permission is hereby granted to any person obtaining a copy of the software | |
| 5 | +Shader Playground (the "Software") to use, modify, merge, copy, publish, distribute, | |
| 6 | +sublicense, and/or sell copies of the Software, subject to the following conditions: | |
| 7 | + | |
| 8 | + 1. **Origin Attribution**: | |
| 9 | + - You must not misrepresent the origin of the Software; you must not claim | |
| 10 | + you created the original Software. | |
| 11 | + - If the Software is used in a product, you must either: | |
| 12 | + a. Provide clear attribution in the product's documentation, user interface, | |
| 13 | + or other visible areas, **OR** | |
| 14 | + b. Pay the original developers a fee they specify in writing. | |
| 15 | + 2. **Usage Restriction**: | |
| 16 | + - The Software, or any derivative works, dependencies, or libraries | |
| 17 | + incorporating it, must not be used for censorship or to suppress freedom of | |
| 18 | + speech, expression, or creativity. Prohibited uses include, but are not | |
| 19 | + limited to: | |
| 20 | + - Censorship of so-called "hate speech", visuals, non-mainstream opinions, | |
| 21 | + ideas, or objective reality. | |
| 22 | + - Tools or systems designed to restrict access to information or | |
| 23 | + artistic works. | |
| 24 | + 3. **Notice Preservation**: | |
| 25 | + - This license and the above copyright notice must remain intact in all copies | |
| 26 | + of the source code. | |
| 27 | + | |
| 28 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |
| 29 | +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 30 | +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |
| 31 | +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
| 32 | +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |
| 33 | +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| 34 | +*/ | |
| 35 | +#ifndef GLFWPP_HH | |
| 36 | +#define GLFWPP_HH | |
| 37 | + | |
| 38 | +#include <glfw/glfw3.h> | |
| 39 | +#include "types.hh" | |
| 40 | +#include <span> | |
| 41 | + | |
| 42 | +namespace glfwpp { | |
| 43 | + enum ErrorCodes { | |
| 44 | + NotInitialized = 0x00010001, | |
| 45 | + NoCurrentContext = 0x00010002, | |
| 46 | + InvalidEnum = 0x00010003, | |
| 47 | + InvalidValue = 0x00010004, | |
| 48 | + OutOfMemory = 0x00010005, | |
| 49 | + ApiUnavailable = 0x00010006, | |
| 50 | + VersionUnavailable = 0x00010007, | |
| 51 | + PlatformError = 0x00010008, | |
| 52 | + FormatUnavailable = 0x00010009, | |
| 53 | + NoWindowContent = 0x0001000A, | |
| 54 | + }; | |
| 55 | + | |
| 56 | + enum Attributes { | |
| 57 | + Focused = 0x00020001, | |
| 58 | + Iconified = 0x00020002, | |
| 59 | + Resizable = 0x00020003, | |
| 60 | + visible = 0x00020004, | |
| 61 | + Decorated = 0x00020005, | |
| 62 | + AutoNotify = 0x00020006, | |
| 63 | + Floating = 0x00020007, | |
| 64 | + Maximized = 0x00020008, | |
| 65 | + | |
| 66 | + RedBits = 0x00021001, | |
| 67 | + GreenBits = 0x00021002, | |
| 68 | + BlueBits = 0x00021003, | |
| 69 | + AlphaBits = 0x00021004, | |
| 70 | + DepthBits = 0x00021005, | |
| 71 | + StencilBits = 0x00021006, | |
| 72 | + AccumRedBits = 0x00021007, | |
| 73 | + AccumGreenBits = 0x00021008, | |
| 74 | + AccumBlueBits = 0x00021009, | |
| 75 | + AccumAlphaBits = 0x0002100A, | |
| 76 | + AuxBuffers = 0x0002100B, | |
| 77 | + Stereo = 0x0002100C, | |
| 78 | + Samples = 0x0002100D, | |
| 79 | + SrgbCapable = 0x0002100E, | |
| 80 | + RefreshRate = 0x0002100F, | |
| 81 | + Doublebuffer = 0x00021010, | |
| 82 | + | |
| 83 | + ClientApi = 0x00022001, | |
| 84 | + ContextVersionMajor = 0x00022002, | |
| 85 | + ContextVersionMinor = 0x00022003, | |
| 86 | + ContextRevision = 0x00022004, | |
| 87 | + ContextRobustness = 0x00022005, | |
| 88 | + OpenGLForwardCompatable = 0x00022006, | |
| 89 | + OpenGLDebugContext = 0x00022007, | |
| 90 | + OpenGLProfile = 0x00022008, | |
| 91 | + ContextReleaseBehavior = 0x00022009, | |
| 92 | + ContextNoError = 0x0002200A, | |
| 93 | + | |
| 94 | + NoApi = 0, | |
| 95 | + OpenGLApi = 0x00030001, | |
| 96 | + OpenGLESApi = 0x00030002, | |
| 97 | + | |
| 98 | + NoRobustness = 0, | |
| 99 | + NoResetNotification = 0x00031001, | |
| 100 | + LoseContextOnReset = 0x00031002, | |
| 101 | + | |
| 102 | + AnyOpenGLProfile = 0, | |
| 103 | + OpenGLCore = 0x00032001, | |
| 104 | + OpenGLCompat = 0x00032002, | |
| 105 | + | |
| 106 | + Cursor = 0x00033001, | |
| 107 | + StickyKeys = 0x00033002, | |
| 108 | + StickyMouseButtons = 0x00033003, | |
| 109 | + | |
| 110 | + CursorNormal = 0x00034001, | |
| 111 | + CursorHidden = 0x00034002, | |
| 112 | + CursorDisabled = 0x00034003, | |
| 113 | + | |
| 114 | + AnyReleaseBehavior = 0, | |
| 115 | + ReleaseBehaviorFlush = 0x00035001, | |
| 116 | + ReleaseBehaviorNone = 0x00035002, | |
| 117 | + }; | |
| 118 | + | |
| 119 | + enum CursorShapes { | |
| 120 | + ArrowCursor = 0x00036001, | |
| 121 | + IbeamCursor = 0x00036002, | |
| 122 | + CrosshairCursor = 0x00036003, | |
| 123 | + HandCursor = 0x00036004, | |
| 124 | + HResizeCursor = 0x00036005, | |
| 125 | + VResizeCursor = 0x00036006, | |
| 126 | + }; | |
| 127 | + | |
| 128 | + enum Connection { | |
| 129 | + Connected = 0x00040001, | |
| 130 | + Disconnected = 0x00040002, | |
| 131 | + DontCare = -1, | |
| 132 | + }; | |
| 133 | + | |
| 134 | + enum ButtonMode { | |
| 135 | + LockKeyMods = 0x00032004, | |
| 136 | + RawMouseMotion = 0x00032005, | |
| 137 | + }; | |
| 138 | + | |
| 139 | + enum ContextApi { | |
| 140 | + Native = 0x00032001, | |
| 141 | + EGL = 0x00032002, | |
| 142 | + OSMESA = 0x00032003, | |
| 143 | + }; | |
| 144 | + | |
| 145 | + class Instance { | |
| 146 | + public: | |
| 147 | + Instance(); | |
| 148 | + ~Instance(); | |
| 149 | + | |
| 150 | + GLFWerrorfun SetErrorCallback(); | |
| 151 | + | |
| 152 | + void SetContextMajorVersion(int major); | |
| 153 | + void SetContextMinorVersion(int minor); | |
| 154 | + void SetOpenGLProfile(int profile); | |
| 155 | + void SetForwardCompatibility(bool fc); | |
| 156 | + | |
| 157 | + void CreateWindowHints(); | |
| 158 | + void PollEvents(); | |
| 159 | + | |
| 160 | + void SwapInterval(int interval); | |
| 161 | + double GetTime(); | |
| 162 | + void SetTime(double time); | |
| 163 | + u64 GetTimerValue(); | |
| 164 | + u64 GetTimerFrequency(); | |
| 165 | + | |
| 166 | + void InitHint(int hint, int value); | |
| 167 | + void GetVersion(int *major, int *minor, int *rev); | |
| 168 | + cstr GetVersionString(void); | |
| 169 | + | |
| 170 | + int GetError(cstr *description); | |
| 171 | + GLFWerrorfun SetErrorCallback(GLFWerrorfun cbfun); | |
| 172 | + | |
| 173 | + private: | |
| 174 | + int m_Major = 0; | |
| 175 | + int m_Minor = 0; | |
| 176 | + int m_Profile = 0; | |
| 177 | + bool m_ForwardCompat = false; | |
| 178 | + }; // class Instance | |
| 179 | + | |
| 180 | + class Window { | |
| 181 | + public: | |
| 182 | + Window(int width, int height, string title); | |
| 183 | + ~Window(); | |
| 184 | + | |
| 185 | + GLFWwindow *Get() const { return m_Window; } | |
| 186 | + GLFWframebuffersizefun SetFramebufferSizeCallback(); | |
| 187 | + | |
| 188 | + bool ShouldClose() const; | |
| 189 | + void SwapBuffers(); | |
| 190 | + | |
| 191 | + void SetClipboardString(string str); | |
| 192 | + string GetClipboardString(); | |
| 193 | + void MakeContextCurrent(); | |
| 194 | + int GetAttrib(int attrib); | |
| 195 | + int GetInputMode(int mode); | |
| 196 | + void SetInputMode(int mode, int value); | |
| 197 | + int RawMouseMotionSupported(); | |
| 198 | + cstr GetKeyName(int key, int scancode); | |
| 199 | + int GetKeyScancode(int key); | |
| 200 | + int GetKey(int key); | |
| 201 | + int GetMouseButton(int button); | |
| 202 | + void GetCursorPos(double *xpos, double *ypos); | |
| 203 | + void SetCursorPos(double xpos, double ypos); | |
| 204 | + | |
| 205 | + GLFWwindow *GetCurrentContext(); | |
| 206 | + bool IsExtensionSupported(cstr ext); | |
| 207 | + GLFWglproc GetProcAddress(cstr procname); | |
| 208 | + | |
| 209 | + GLFWkeyfun SetKeyCallback(GLFWkeyfun cbfun); | |
| 210 | + GLFWcharfun SetCharCallback(GLFWcharfun cbfun); | |
| 211 | + GLFWcharmodsfun SetCharModsCallback(GLFWcharmodsfun cbfun); | |
| 212 | + GLFWmousebuttonfun SetMouseButtonCallback(GLFWmousebuttonfun cbfun); | |
| 213 | + GLFWcursorposfun SetCursorPosCallback(GLFWcursorposfun cbfun); | |
| 214 | + GLFWcursorenterfun SetCursorEnterCallback(GLFWcursorenterfun cbfun); | |
| 215 | + GLFWscrollfun SetScrollCallback(GLFWscrollfun cbfun); | |
| 216 | + GLFWdropfun SetDropCallback(GLFWdropfun cbfun); | |
| 217 | + | |
| 218 | + int JoystickPresent(int jid); | |
| 219 | + const f32 *GetJoystickAxes(int jid, int *count); | |
| 220 | + const unsigned char *GetJoystickButtons(int jid, int *count); | |
| 221 | + const unsigned char *GetJoystickHats(int jid, int *count); | |
| 222 | + cstr GetJoystickName(int jid); | |
| 223 | + cstr GetJoystickGUID(int jid); | |
| 224 | + void SetJoystickUserPointer(int jid, any ptr); | |
| 225 | + any GetJoystickUserPointer(int jid); | |
| 226 | + GLFWjoystickfun SetJoystickCallback(GLFWjoystickfun cbfun); | |
| 227 | + int UpdateGamepadMappings(string str); | |
| 228 | + int JoystickIsGamepad(int jid); | |
| 229 | + cstr GetGamepadName(int jid); | |
| 230 | + int GetGamepadState(int jid, GLFWgamepadstate *state); | |
| 231 | + | |
| 232 | + private: | |
| 233 | + GLFWwindow *m_Window = {}; | |
| 234 | + int m_Width = 0; | |
| 235 | + int m_Height = 0; | |
| 236 | + }; // class Window | |
| 237 | + | |
| 238 | + class Monitor { | |
| 239 | + public: | |
| 240 | + Monitor(); | |
| 241 | + ~Monitor(); | |
| 242 | + | |
| 243 | + GLFWmonitor *Get() const { return m_Monitor; } | |
| 244 | + std::span<GLFWmonitor *> GetMonitors(int *count); | |
| 245 | + GLFWmonitor *GetPrimary(); | |
| 246 | + void GetPos(int *xpos, int *ypos); | |
| 247 | + void GetWorkarea(int *xpos, int *ypos, int *width, int *height); | |
| 248 | + void GetPhysicalSize(int *width, int *height); | |
| 249 | + void GetContentScale(float *xscale, float *yscale); | |
| 250 | + cstr GetName(); | |
| 251 | + void SetUserPointer(any ptr); | |
| 252 | + any GetUserPointer(); | |
| 253 | + GLFWmonitorfun SetCallback(GLFWmonitorfun cbfun); | |
| 254 | + const GLFWvidmode *GetVideoModes(int *count); | |
| 255 | + const GLFWvidmode *GetVideoMode(); | |
| 256 | + void SetGamma(float gamma); | |
| 257 | + const GLFWgammaramp *GetGammaRamp(); | |
| 258 | + void SetGammaRamp(const GLFWgammaramp *ramp); | |
| 259 | + | |
| 260 | + private: | |
| 261 | + GLFWmonitor *m_Monitor = {}; | |
| 262 | + }; // class Monitor | |
| 263 | + | |
| 264 | + class Cursor { | |
| 265 | + public: | |
| 266 | + Cursor(GLFWimage *img, int xhot, int yhot); | |
| 267 | + ~Cursor(); | |
| 268 | + | |
| 269 | + GLFWcursor *Get() const { return m_Cursor; } | |
| 270 | + GLFWcursor *CreateStandardCursor(int shape); | |
| 271 | + void Set(Window window); | |
| 272 | + | |
| 273 | + private: | |
| 274 | + GLFWimage *m_Image; | |
| 275 | + GLFWcursor *m_Cursor; | |
| 276 | + }; // class Cursor | |
| 277 | +} // namespace glfwpp | |
| 278 | + | |
| 279 | +#endif // GLFWPP_HH |
変更
main.cc
| @@ -33,7 +33,7 @@ | ||
| 33 | 33 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 34 | 34 | */ |
| 35 | 35 | #include <glad/glad.h> |
| 36 | -#include <util/glfw.hh> | |
| 36 | +#include <util/glfwpp.hh> | |
| 37 | 37 | #include <iostream> |
| 38 | 38 | #include <version.hh> |
| 39 | 39 | #include <util/types.hh> |
| @@ -47,22 +47,25 @@ | ||
| 47 | 47 | |
| 48 | 48 | #include <sol.hpp> |
| 49 | 49 | |
| 50 | -constexpr int windowWidth = 800; | |
| 51 | -constexpr int windowHeight = 600; | |
| 50 | +constexpr int windowWidth = 1280; | |
| 51 | +constexpr int windowHeight = 720; | |
| 52 | 52 | string sofname = "Shader Playground"; |
| 53 | 53 | |
| 54 | 54 | int main(void) { |
| 55 | 55 | // GLFWを初期化 |
| 56 | - glfw::Instance glfwInstance; | |
| 57 | - glfwInstance.SetContextMajorVersion(4); | |
| 58 | - glfwInstance.SetContextMinorVersion(6); | |
| 59 | - glfwInstance.SetOpenGLProfile(glfw::OpenGLProfile::Core); | |
| 60 | - glfwInstance.SetForwardCompatibility(true); | |
| 61 | - glfwInstance.CreateWindowHints(); | |
| 56 | + glfwpp::Instance glfw; | |
| 57 | + glfw.SetErrorCallback(); | |
| 58 | + glfw.SetContextMajorVersion(4); | |
| 59 | + glfw.SetContextMinorVersion(6); | |
| 60 | + glfw.SetOpenGLProfile(glfwpp::Attributes::OpenGLCore); | |
| 61 | + glfw.SetForwardCompatibility(true); | |
| 62 | + glfw.CreateWindowHints(); | |
| 62 | 63 | |
| 63 | 64 | // ウィンドウを作成 |
| 64 | 65 | string winName = sofname + " " + version::full; |
| 65 | - glfw::Window window(windowWidth, windowHeight, winName); | |
| 66 | + glfwpp::Window window(windowWidth, windowHeight, winName); | |
| 67 | + window.MakeContextCurrent(); | |
| 68 | + glfw.SwapInterval(1); | |
| 66 | 69 | |
| 67 | 70 | // GLADを初期化 |
| 68 | 71 | if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { |
| @@ -125,7 +128,7 @@ | ||
| 125 | 128 | shaderProgram.Use(); |
| 126 | 129 | |
| 127 | 130 | // 時間に基づいて色をアニメーション |
| 128 | - f32 time = (f32)window.GetTime(); | |
| 131 | + f32 time = (f32)glfw.GetTime(); | |
| 129 | 132 | f32 speed = 1.0f; // アニメーションの速度 |
| 130 | 133 | f32 phase = 2.0f * 3.14159f / 3.0f; // // 120度の位相差(3色用) |
| 131 | 134 | |
| @@ -158,7 +161,7 @@ | ||
| 158 | 161 | |
| 159 | 162 | // バッファをスワップし、イベントを処理 |
| 160 | 163 | window.SwapBuffers(); |
| 161 | - window.PollEvents(); | |
| 164 | + glfw.PollEvents(); | |
| 162 | 165 | } |
| 163 | 166 | |
| 164 | 167 | return 0; |
削除
src/util/glfw.cc
| @@ -1,131 +0,0 @@ | ||
| 1 | -/* | |
| 2 | -Copyright (c) テクニカル諏訪子 | |
| 3 | - | |
| 4 | -Permission is hereby granted to any person obtaining a copy of the software | |
| 5 | -Shader Playground (the "Software") to use, modify, merge, copy, publish, distribute, | |
| 6 | -sublicense, and/or sell copies of the Software, subject to the following conditions: | |
| 7 | - | |
| 8 | - 1. **Origin Attribution**: | |
| 9 | - - You must not misrepresent the origin of the Software; you must not claim | |
| 10 | - you created the original Software. | |
| 11 | - - If the Software is used in a product, you must either: | |
| 12 | - a. Provide clear attribution in the product's documentation, user interface, | |
| 13 | - or other visible areas, **OR** | |
| 14 | - b. Pay the original developers a fee they specify in writing. | |
| 15 | - 2. **Usage Restriction**: | |
| 16 | - - The Software, or any derivative works, dependencies, or libraries | |
| 17 | - incorporating it, must not be used for censorship or to suppress freedom of | |
| 18 | - speech, expression, or creativity. Prohibited uses include, but are not | |
| 19 | - limited to: | |
| 20 | - - Censorship of so-called "hate speech", visuals, non-mainstream opinions, | |
| 21 | - ideas, or objective reality. | |
| 22 | - - Tools or systems designed to restrict access to information or | |
| 23 | - artistic works. | |
| 24 | - 3. **Notice Preservation**: | |
| 25 | - - This license and the above copyright notice must remain intact in all copies | |
| 26 | - of the source code. | |
| 27 | - | |
| 28 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |
| 29 | -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 30 | -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |
| 31 | -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
| 32 | -CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |
| 33 | -OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| 34 | -*/ | |
| 35 | -#include <util/glfw.hh> | |
| 36 | -#include <iostream> | |
| 37 | - | |
| 38 | -namespace glfw { | |
| 39 | - Instance::Instance() { | |
| 40 | - if (!glfwInit()) { | |
| 41 | - throw "GLFWの初期化に失敗しました"; | |
| 42 | - } | |
| 43 | - } | |
| 44 | - | |
| 45 | - Instance::~Instance() { | |
| 46 | - glfwTerminate(); | |
| 47 | - } | |
| 48 | - | |
| 49 | - void Instance::SetContextMajorVersion(int major) { | |
| 50 | - m_Major = major; | |
| 51 | - } | |
| 52 | - | |
| 53 | - void Instance::SetContextMinorVersion(int minor) { | |
| 54 | - m_Minor = minor; | |
| 55 | - } | |
| 56 | - | |
| 57 | - void Instance::SetOpenGLProfile(int profile) { | |
| 58 | - m_Profile = profile; | |
| 59 | - } | |
| 60 | - | |
| 61 | - void Instance::SetForwardCompatibility(bool fc) { | |
| 62 | - m_ForwardCompat = fc; | |
| 63 | - } | |
| 64 | - | |
| 65 | - void Instance::CreateWindowHints() { | |
| 66 | - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, m_Major); | |
| 67 | - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, m_Minor); | |
| 68 | - glfwWindowHint(GLFW_OPENGL_PROFILE, m_Profile); | |
| 69 | - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, m_ForwardCompat); | |
| 70 | - } | |
| 71 | - | |
| 72 | - ///////////// | |
| 73 | - | |
| 74 | - Window::Window(int width, int height, string title) { | |
| 75 | - window = glfwCreateWindow(width, height, title.c_str(), nullptr, nullptr); | |
| 76 | - if (!window) { | |
| 77 | - throw "GLFWウィンドウの作成に失敗しました"; | |
| 78 | - } | |
| 79 | - | |
| 80 | - glfwMakeContextCurrent(window); | |
| 81 | - } | |
| 82 | - | |
| 83 | - Window::~Window() { | |
| 84 | - glfwDestroyWindow(window); | |
| 85 | - } | |
| 86 | - | |
| 87 | - void framebuffer_size_callback(GLFWwindow *window, int width, int height) { | |
| 88 | - (void)window; | |
| 89 | - glViewport(0, 0, width, height); | |
| 90 | - } | |
| 91 | - | |
| 92 | - GLFWframebuffersizefun Window::SetFramebufferSizeCallback() { | |
| 93 | - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); | |
| 94 | - return nullptr; | |
| 95 | - } | |
| 96 | - | |
| 97 | - bool Window::ShouldClose() const { | |
| 98 | - return glfwWindowShouldClose(window); | |
| 99 | - } | |
| 100 | - | |
| 101 | - void Window::SwapBuffers() { | |
| 102 | - glfwSwapBuffers(window); | |
| 103 | - } | |
| 104 | - void Window::PollEvents() { | |
| 105 | - glfwPollEvents(); | |
| 106 | - } | |
| 107 | - | |
| 108 | - void Window::SetClipboardString(string str) { | |
| 109 | - glfwSetClipboardString(window, str.c_str()); | |
| 110 | - } | |
| 111 | - | |
| 112 | - string Window::GetClipboardString() { | |
| 113 | - return string(glfwGetClipboardString(window)); | |
| 114 | - } | |
| 115 | - | |
| 116 | - double Window::GetTime() { | |
| 117 | - return glfwGetTime(); | |
| 118 | - } | |
| 119 | - | |
| 120 | - void Window::SetTime(double time) { | |
| 121 | - return glfwSetTime(time); | |
| 122 | - } | |
| 123 | - | |
| 124 | - u64 Window::GetTimerValue() { | |
| 125 | - return glfwGetTimerValue(); | |
| 126 | - } | |
| 127 | - | |
| 128 | - u64 Window::GetTimerFrequency() { | |
| 129 | - return glfwGetTimerFrequency(); | |
| 130 | - } | |
| 131 | -} // namespace glfw |
| @@ -0,0 +1,389 @@ | ||
| 1 | +/* | |
| 2 | +Copyright (c) テクニカル諏訪子 | |
| 3 | + | |
| 4 | +Permission is hereby granted to any person obtaining a copy of the software | |
| 5 | +Shader Playground (the "Software") to use, modify, merge, copy, publish, distribute, | |
| 6 | +sublicense, and/or sell copies of the Software, subject to the following conditions: | |
| 7 | + | |
| 8 | + 1. **Origin Attribution**: | |
| 9 | + - You must not misrepresent the origin of the Software; you must not claim | |
| 10 | + you created the original Software. | |
| 11 | + - If the Software is used in a product, you must either: | |
| 12 | + a. Provide clear attribution in the product's documentation, user interface, | |
| 13 | + or other visible areas, **OR** | |
| 14 | + b. Pay the original developers a fee they specify in writing. | |
| 15 | + 2. **Usage Restriction**: | |
| 16 | + - The Software, or any derivative works, dependencies, or libraries | |
| 17 | + incorporating it, must not be used for censorship or to suppress freedom of | |
| 18 | + speech, expression, or creativity. Prohibited uses include, but are not | |
| 19 | + limited to: | |
| 20 | + - Censorship of so-called "hate speech", visuals, non-mainstream opinions, | |
| 21 | + ideas, or objective reality. | |
| 22 | + - Tools or systems designed to restrict access to information or | |
| 23 | + artistic works. | |
| 24 | + 3. **Notice Preservation**: | |
| 25 | + - This license and the above copyright notice must remain intact in all copies | |
| 26 | + of the source code. | |
| 27 | + | |
| 28 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |
| 29 | +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 30 | +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |
| 31 | +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
| 32 | +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |
| 33 | +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| 34 | +*/ | |
| 35 | +#include <util/glfwpp.hh> | |
| 36 | +#include <iostream> | |
| 37 | + | |
| 38 | +namespace glfwpp { | |
| 39 | + Instance::Instance() { | |
| 40 | + if (!glfwInit()) { | |
| 41 | + throw "GLFWの初期化に失敗しました"; | |
| 42 | + } | |
| 43 | + } | |
| 44 | + | |
| 45 | + Instance::~Instance() { | |
| 46 | + glfwTerminate(); | |
| 47 | + } | |
| 48 | + | |
| 49 | + static void glfw_error_callback(int error, cstr description) { | |
| 50 | + std::cerr << "GLFWエラー " << error << ":\n" << description << std::endl; | |
| 51 | + } | |
| 52 | + | |
| 53 | + GLFWerrorfun Instance::SetErrorCallback() { | |
| 54 | + return nullptr; | |
| 55 | + } | |
| 56 | + | |
| 57 | + void Instance::SetContextMajorVersion(int major) { | |
| 58 | + m_Major = major; | |
| 59 | + } | |
| 60 | + | |
| 61 | + void Instance::SetContextMinorVersion(int minor) { | |
| 62 | + m_Minor = minor; | |
| 63 | + } | |
| 64 | + | |
| 65 | + void Instance::SetOpenGLProfile(int profile) { | |
| 66 | + m_Profile = profile; | |
| 67 | + } | |
| 68 | + | |
| 69 | + void Instance::SetForwardCompatibility(bool fc) { | |
| 70 | + m_ForwardCompat = fc; | |
| 71 | + } | |
| 72 | + | |
| 73 | + void Instance::CreateWindowHints() { | |
| 74 | + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, m_Major); | |
| 75 | + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, m_Minor); | |
| 76 | + glfwWindowHint(GLFW_OPENGL_PROFILE, m_Profile); | |
| 77 | + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, m_ForwardCompat); | |
| 78 | + } | |
| 79 | + | |
| 80 | + void Instance::PollEvents() { | |
| 81 | + glfwPollEvents(); | |
| 82 | + } | |
| 83 | + | |
| 84 | + void Instance::SwapInterval(int interval) { | |
| 85 | + glfwSwapInterval(interval); | |
| 86 | + } | |
| 87 | + | |
| 88 | + double Instance::GetTime() { | |
| 89 | + return glfwGetTime(); | |
| 90 | + } | |
| 91 | + | |
| 92 | + void Instance::SetTime(double time) { | |
| 93 | + return glfwSetTime(time); | |
| 94 | + } | |
| 95 | + | |
| 96 | + u64 Instance::GetTimerValue() { | |
| 97 | + return glfwGetTimerValue(); | |
| 98 | + } | |
| 99 | + | |
| 100 | + u64 Instance::GetTimerFrequency() { | |
| 101 | + return glfwGetTimerFrequency(); | |
| 102 | + } | |
| 103 | + | |
| 104 | + void Instance::InitHint(int hint, int value) { | |
| 105 | + return glfwInitHint(hint, value); | |
| 106 | + } | |
| 107 | + | |
| 108 | + void Instance::GetVersion(int *major, int *minor, int *rev) { | |
| 109 | + glfwGetVersion(major, minor, rev); | |
| 110 | + } | |
| 111 | + | |
| 112 | + cstr Instance::GetVersionString(void) { | |
| 113 | + return glfwGetVersionString(); | |
| 114 | + } | |
| 115 | + | |
| 116 | + int Instance::GetError(cstr *description) { | |
| 117 | + return glfwGetError(description); | |
| 118 | + } | |
| 119 | + | |
| 120 | + GLFWerrorfun Instance::SetErrorCallback(GLFWerrorfun cbfun) { | |
| 121 | + return glfwSetErrorCallback(cbfun); | |
| 122 | + } | |
| 123 | + | |
| 124 | + ///////////// | |
| 125 | + | |
| 126 | + Window::Window(int width, int height, string title) { | |
| 127 | + m_Window = glfwCreateWindow(width, height, title.c_str(), nullptr, nullptr); | |
| 128 | + m_Width = width; | |
| 129 | + m_Height = height; | |
| 130 | + if (!m_Window) { | |
| 131 | + throw "GLFWウィンドウの作成に失敗しました"; | |
| 132 | + } | |
| 133 | + | |
| 134 | + glfwMakeContextCurrent(m_Window); | |
| 135 | + } | |
| 136 | + | |
| 137 | + Window::~Window() { | |
| 138 | + glfwDestroyWindow(m_Window); | |
| 139 | + } | |
| 140 | + | |
| 141 | + void framebuffer_size_callback(GLFWwindow *window, int width, int height) { | |
| 142 | + (void)window; | |
| 143 | + glViewport(0, 0, width, height); | |
| 144 | + } | |
| 145 | + | |
| 146 | + GLFWframebuffersizefun Window::SetFramebufferSizeCallback() { | |
| 147 | + glfwSetFramebufferSizeCallback(m_Window, framebuffer_size_callback); | |
| 148 | + return nullptr; | |
| 149 | + } | |
| 150 | + | |
| 151 | + bool Window::ShouldClose() const { | |
| 152 | + return glfwWindowShouldClose(m_Window); | |
| 153 | + } | |
| 154 | + | |
| 155 | + void Window::SwapBuffers() { | |
| 156 | + glfwSwapBuffers(m_Window); | |
| 157 | + } | |
| 158 | + | |
| 159 | + void Window::SetClipboardString(string str) { | |
| 160 | + glfwSetClipboardString(m_Window, str.c_str()); | |
| 161 | + } | |
| 162 | + | |
| 163 | + string Window::GetClipboardString() { | |
| 164 | + return string(glfwGetClipboardString(m_Window)); | |
| 165 | + } | |
| 166 | + | |
| 167 | + void Window::MakeContextCurrent() { | |
| 168 | + glfwMakeContextCurrent(m_Window); | |
| 169 | + } | |
| 170 | + | |
| 171 | + int Window::GetAttrib(int attrib) { | |
| 172 | + return glfwGetWindowAttrib(m_Window, attrib); | |
| 173 | + } | |
| 174 | + | |
| 175 | + int Window::GetInputMode(int mode) { | |
| 176 | + return glfwGetInputMode(m_Window, mode); | |
| 177 | + } | |
| 178 | + | |
| 179 | + void Window::SetInputMode(int mode, int value) { | |
| 180 | + glfwSetInputMode(m_Window, mode, value); | |
| 181 | + } | |
| 182 | + | |
| 183 | + int Window::RawMouseMotionSupported() { | |
| 184 | + return RawMouseMotionSupported(); | |
| 185 | + } | |
| 186 | + | |
| 187 | + cstr Window::GetKeyName(int key, int scancode) { | |
| 188 | + return glfwGetKeyName(key, scancode); | |
| 189 | + } | |
| 190 | + | |
| 191 | + int Window::GetKeyScancode(int key) { | |
| 192 | + return glfwGetKeyScancode(key); | |
| 193 | + } | |
| 194 | + | |
| 195 | + int Window::GetKey(int key) { | |
| 196 | + return glfwGetKey(m_Window, key); | |
| 197 | + } | |
| 198 | + | |
| 199 | + int Window::GetMouseButton(int button) { | |
| 200 | + return glfwGetMouseButton(m_Window, button); | |
| 201 | + } | |
| 202 | + | |
| 203 | + void Window::GetCursorPos(double *xpos, double *ypos) { | |
| 204 | + return glfwGetCursorPos(m_Window, xpos, ypos); | |
| 205 | + } | |
| 206 | + | |
| 207 | + void Window::SetCursorPos(double xpos, double ypos) { | |
| 208 | + return glfwSetCursorPos(m_Window, xpos, ypos); | |
| 209 | + } | |
| 210 | + | |
| 211 | + GLFWwindow *Window::GetCurrentContext() { | |
| 212 | + return glfwGetCurrentContext(); | |
| 213 | + } | |
| 214 | + | |
| 215 | + bool Window::IsExtensionSupported(cstr ext) { | |
| 216 | + return glfwExtensionSupported(ext); | |
| 217 | + } | |
| 218 | + | |
| 219 | + GLFWglproc Window::GetProcAddress(cstr procname) { | |
| 220 | + return glfwGetProcAddress(procname); | |
| 221 | + } | |
| 222 | + | |
| 223 | + GLFWkeyfun Window::SetKeyCallback(GLFWkeyfun cbfun) { | |
| 224 | + return glfwSetKeyCallback(m_Window, cbfun); | |
| 225 | + } | |
| 226 | + | |
| 227 | + GLFWcharfun Window::SetCharCallback(GLFWcharfun cbfun) { | |
| 228 | + return glfwSetCharCallback(m_Window, cbfun); | |
| 229 | + } | |
| 230 | + | |
| 231 | + GLFWcharmodsfun Window::SetCharModsCallback(GLFWcharmodsfun cbfun) { | |
| 232 | + return glfwSetCharModsCallback(m_Window, cbfun); | |
| 233 | + } | |
| 234 | + | |
| 235 | + GLFWmousebuttonfun Window::SetMouseButtonCallback(GLFWmousebuttonfun cbfun) { | |
| 236 | + return glfwSetMouseButtonCallback(m_Window, cbfun); | |
| 237 | + } | |
| 238 | + | |
| 239 | + GLFWcursorposfun Window::SetCursorPosCallback(GLFWcursorposfun cbfun) { | |
| 240 | + return glfwSetCursorPosCallback(m_Window, cbfun); | |
| 241 | + } | |
| 242 | + | |
| 243 | + GLFWcursorenterfun Window::SetCursorEnterCallback(GLFWcursorenterfun cbfun) { | |
| 244 | + return glfwSetCursorEnterCallback(m_Window, cbfun); | |
| 245 | + } | |
| 246 | + | |
| 247 | + GLFWscrollfun Window::SetScrollCallback(GLFWscrollfun cbfun) { | |
| 248 | + return glfwSetScrollCallback(m_Window, cbfun); | |
| 249 | + } | |
| 250 | + | |
| 251 | + GLFWdropfun Window::SetDropCallback(GLFWdropfun cbfun) { | |
| 252 | + return glfwSetDropCallback(m_Window, cbfun); | |
| 253 | + } | |
| 254 | + | |
| 255 | + int Window::JoystickPresent(int jid) { | |
| 256 | + return glfwJoystickPresent(jid); | |
| 257 | + } | |
| 258 | + | |
| 259 | + const f32 *Window::GetJoystickAxes(int jid, int *count) { | |
| 260 | + return glfwGetJoystickAxes(jid, count); | |
| 261 | + } | |
| 262 | + | |
| 263 | + const unsigned char *Window::GetJoystickButtons(int jid, int *count) { | |
| 264 | + return glfwGetJoystickButtons(jid, count); | |
| 265 | + } | |
| 266 | + | |
| 267 | + const unsigned char *Window::GetJoystickHats(int jid, int *count) { | |
| 268 | + return glfwGetJoystickHats(jid, count); | |
| 269 | + } | |
| 270 | + | |
| 271 | + cstr Window::GetJoystickName(int jid) { | |
| 272 | + return glfwGetJoystickName(jid); | |
| 273 | + } | |
| 274 | + | |
| 275 | + cstr Window::GetJoystickGUID(int jid) { | |
| 276 | + return glfwGetJoystickGUID(jid); | |
| 277 | + } | |
| 278 | + | |
| 279 | + void Window::SetJoystickUserPointer(int jid, any ptr) { | |
| 280 | + return glfwSetJoystickUserPointer(jid, ptr); | |
| 281 | + } | |
| 282 | + | |
| 283 | + any Window::GetJoystickUserPointer(int jid) { | |
| 284 | + return glfwGetJoystickUserPointer(jid); | |
| 285 | + } | |
| 286 | + | |
| 287 | + GLFWjoystickfun Window::SetJoystickCallback(GLFWjoystickfun cbfun) { | |
| 288 | + return glfwSetJoystickCallback(cbfun); | |
| 289 | + } | |
| 290 | + | |
| 291 | + int Window::UpdateGamepadMappings(string str) { | |
| 292 | + return glfwUpdateGamepadMappings(str.c_str()); | |
| 293 | + } | |
| 294 | + | |
| 295 | + int Window::JoystickIsGamepad(int jid) { | |
| 296 | + return glfwJoystickIsGamepad(jid); | |
| 297 | + } | |
| 298 | + | |
| 299 | + cstr Window::GetGamepadName(int jid) { | |
| 300 | + return glfwGetGamepadName(jid); | |
| 301 | + } | |
| 302 | + | |
| 303 | + int Window::GetGamepadState(int jid, GLFWgamepadstate *state) { | |
| 304 | + return glfwGetGamepadState(jid, state); | |
| 305 | + } | |
| 306 | + | |
| 307 | + /////////////////// | |
| 308 | + | |
| 309 | + std::span<GLFWmonitor *> Monitor::GetMonitors(int *count) { | |
| 310 | + if (count) *count = 0; | |
| 311 | + GLFWmonitor **mon = glfwGetMonitors(count); | |
| 312 | + if (mon == nullptr || count == nullptr || *count <= 0) return {}; | |
| 313 | + return std::span<GLFWmonitor *>(mon, mon + *count); | |
| 314 | + } | |
| 315 | + | |
| 316 | + GLFWmonitor *Monitor::GetPrimary() { | |
| 317 | + return glfwGetPrimaryMonitor(); | |
| 318 | + } | |
| 319 | + | |
| 320 | + void Monitor::GetPos(int *xpos, int *ypos) { | |
| 321 | + glfwGetMonitorPos(m_Monitor, xpos, ypos); | |
| 322 | + } | |
| 323 | + | |
| 324 | + void Monitor::GetWorkarea(int *xpos, int *ypos, int *width, int *height) { | |
| 325 | + glfwGetMonitorWorkarea(m_Monitor, xpos, ypos, width, height); | |
| 326 | + } | |
| 327 | + | |
| 328 | + void Monitor::GetPhysicalSize(int *width, int *height) { | |
| 329 | + glfwGetMonitorPhysicalSize(m_Monitor, width, height); | |
| 330 | + } | |
| 331 | + | |
| 332 | + void Monitor::GetContentScale(float *xscale, float *yscale) { | |
| 333 | + glfwGetMonitorContentScale(m_Monitor, xscale, yscale); | |
| 334 | + } | |
| 335 | + | |
| 336 | + cstr Monitor::GetName() { | |
| 337 | + return glfwGetMonitorName(m_Monitor); | |
| 338 | + } | |
| 339 | + | |
| 340 | + void Monitor::SetUserPointer(any ptr) { | |
| 341 | + glfwSetMonitorUserPointer(m_Monitor, ptr); | |
| 342 | + } | |
| 343 | + | |
| 344 | + any Monitor::GetUserPointer() { | |
| 345 | + return glfwGetMonitorUserPointer(m_Monitor); | |
| 346 | + } | |
| 347 | + | |
| 348 | + GLFWmonitorfun Monitor::SetCallback(GLFWmonitorfun cbfun) { | |
| 349 | + return glfwSetMonitorCallback(cbfun); | |
| 350 | + } | |
| 351 | + | |
| 352 | + const GLFWvidmode *Monitor::GetVideoModes(int *count) { | |
| 353 | + return glfwGetVideoModes(m_Monitor, count); | |
| 354 | + } | |
| 355 | + | |
| 356 | + const GLFWvidmode *Monitor::GetVideoMode() { | |
| 357 | + return glfwGetVideoMode(m_Monitor); | |
| 358 | + } | |
| 359 | + | |
| 360 | + void Monitor::SetGamma(float gamma) { | |
| 361 | + return glfwSetGamma(m_Monitor, gamma); | |
| 362 | + } | |
| 363 | + | |
| 364 | + const GLFWgammaramp *Monitor::GetGammaRamp() { | |
| 365 | + return glfwGetGammaRamp(m_Monitor); | |
| 366 | + } | |
| 367 | + | |
| 368 | + void Monitor::SetGammaRamp(const GLFWgammaramp *ramp) { | |
| 369 | + return glfwSetGammaRamp(m_Monitor, ramp); | |
| 370 | + } | |
| 371 | + | |
| 372 | + ///////////// | |
| 373 | + | |
| 374 | + Cursor::Cursor(GLFWimage *img, int xhot, int yhot) : m_Image(img) { | |
| 375 | + m_Cursor = glfwCreateCursor(m_Image, xhot, yhot); | |
| 376 | + } | |
| 377 | + | |
| 378 | + Cursor::~Cursor() { | |
| 379 | + glfwDestroyCursor(m_Cursor); | |
| 380 | + } | |
| 381 | + | |
| 382 | + GLFWcursor *Cursor::CreateStandardCursor(int shape) { | |
| 383 | + return glfwCreateStandardCursor(shape); | |
| 384 | + } | |
| 385 | + | |
| 386 | + void Cursor::Set(Window window) { | |
| 387 | + glfwSetCursor(window.Get(), m_Cursor); | |
| 388 | + } | |
| 389 | +} // namespace glfwpp |