internal/glfw: add const definitions

This is one of the steps to merge internal/glfw and internal/goglfw.

Updates #2703
This commit is contained in:
Hajime Hoshi 2023-10-04 03:04:44 +09:00
parent 84030a3f77
commit 0e722669ef
3 changed files with 98 additions and 47 deletions

View File

@ -45,54 +45,100 @@ const (
) )
const ( const (
ModShift = ModifierKey(0x0001)
ModControl = ModifierKey(0x0002)
ModAlt = ModifierKey(0x0004) ModAlt = ModifierKey(0x0004)
ModCapsLock = ModifierKey(0x0010)
ModControl = ModifierKey(0x0002)
ModNumLock = ModifierKey(0x0020)
ModShift = ModifierKey(0x0001)
ModSuper = ModifierKey(0x0008)
) )
const ( const (
MouseButtonLeft = MouseButton(0) MouseButton1 = MouseButton(0)
MouseButtonRight = MouseButton(1) MouseButton2 = MouseButton(1)
MouseButtonMiddle = MouseButton(2) MouseButton3 = MouseButton(2)
MouseButton3 = MouseButton(3) MouseButton4 = MouseButton(3)
MouseButton4 = MouseButton(4) MouseButton5 = MouseButton(4)
MouseButton6 = MouseButton(5)
MouseButton7 = MouseButton(6)
MouseButton8 = MouseButton(7)
MouseButtonLast = MouseButton8
MouseButtonLeft = MouseButton1
MouseButtonRight = MouseButton2
MouseButtonMiddle = MouseButton3
) )
const ( const (
AccumAlphaBits = Hint(0x0002100A)
AccumBlueBits = Hint(0x00021009)
AccumGreenBits = Hint(0x00021008)
AccumRedBits = Hint(0x00021007)
AlphaBits = Hint(0x00021004)
AutoIconify = Hint(0x00020006) AutoIconify = Hint(0x00020006)
AuxBuffers = Hint(0x0002100B)
BlueBits = Hint(0x00021003)
CenterCursor = Hint(0x00020009)
ClientAPI = Hint(0x00022001) ClientAPI = Hint(0x00022001)
ContextCreationAPI = Hint(0x0002200B) ContextCreationAPI = Hint(0x0002200B)
ContextNoError = Hint(0x0002200A)
ContextReleaseBehavior = Hint(0x00022009)
ContextRevision = Hint(0x00022004)
ContextRobustness = Hint(0x00022005)
ContextVersionMajor = Hint(0x00022002) ContextVersionMajor = Hint(0x00022002)
ContextVersionMinor = Hint(0x00022003) ContextVersionMinor = Hint(0x00022003)
Decorated = Hint(0x00020005) Decorated = Hint(0x00020005)
DepthBits = Hint(0x00021005)
DoubleBuffer = Hint(0x00021010)
Floating = Hint(0x00020007) Floating = Hint(0x00020007)
Focused = Hint(0x00020001) Focused = Hint(0x00020001)
FocusOnShow = Hint(0x0002000C) FocusOnShow = Hint(0x0002000C)
GreenBits = Hint(0x00021002)
Hovered = Hint(0x0002000B)
Iconified = Hint(0x00020002) Iconified = Hint(0x00020002)
Maximized = Hint(0x00020008) Maximized = Hint(0x00020008)
MousePassthrough = Hint(0x0002000D) MousePassthrough = Hint(0x0002000D)
OpenGLForwardCompatible = Hint(0x00022006) OpenGLDebugContext = Hint(0x00022007)
OpenGLForwardCompat = Hint(0x00022006)
OpenGLProfile = Hint(0x00022008) OpenGLProfile = Hint(0x00022008)
RedBits = Hint(0x00021001)
RefreshRate = Hint(0x0002100F)
Resizable = Hint(0x00020003) Resizable = Hint(0x00020003)
Samples = Hint(0x0002100D)
ScaleToMonitor = Hint(0x0002200C)
SRGBCapable = Hint(0x0002100E)
StencilBits = Hint(0x00021006)
Stereo = Hint(0x0002100C)
TransparentFramebuffer = Hint(0x0002000A) TransparentFramebuffer = Hint(0x0002000A)
Visible = Hint(0x00020004) Visible = Hint(0x00020004)
) )
const ( const (
CursorMode = InputMode(0x00033001) CursorMode = InputMode(0x00033001)
LockKeyMods = InputMode(0x00033004)
RawMouseMotion = InputMode(0x00033005)
StickyKeysMode = InputMode(0x00033002) StickyKeysMode = InputMode(0x00033002)
StickyMouseButtonsMode = InputMode(0x00033003) StickyMouseButtonsMode = InputMode(0x00033003)
) )
const ( const (
AnyReleaseBehavior = 0
CursorDisabled = 0x00034003 CursorDisabled = 0x00034003
CursorHidden = 0x00034002 CursorHidden = 0x00034002
CursorNormal = 0x00034001 CursorNormal = 0x00034001
EGLContextAPI = 0x00036002 EGLContextAPI = 0x00036002
LoseContextOnReset = 0x00031002
NativeContextAPI = 0x00036001
NoAPI = 0 NoAPI = 0
NoResetNotification = 0x00031001
NoRobustness = 0
OpenGLAPI = 0x00030001 OpenGLAPI = 0x00030001
OpenGLAnyProfile = 0
OpenGLCompatProfile = 0x00032002
OpenGLCoreProfile = 0x00032001 OpenGLCoreProfile = 0x00032001
OpenGLESAPI = 0x00030002 OpenGLESAPI = 0x00030002
OSMesaContextAPI = 0x00036003
ReleaseBehaviorFlush = 0x00035001
ReleaseBehaviorNone = 0x00035002
) )
const ( const (
@ -108,33 +154,38 @@ const (
NoWindowContext = ErrorCode(0x0001000A) NoWindowContext = ErrorCode(0x0001000A)
) )
func (e ErrorCode) String() string { func (e ErrorCode) Error() string {
switch e { switch e {
case NotInitialized: case NotInitialized:
return "not initialized" return "the GLFW library is not initialized"
case NoCurrentContext: case NoCurrentContext:
return "no current context" return "there is no current context"
case InvalidEnum: case InvalidEnum:
return "invalid enum" return "invalid argument for enum parameter"
case InvalidValue: case InvalidValue:
return "invalid value" return "invalid value for parameter"
case OutOfMemory: case OutOfMemory:
return "out of memory" return "out of memory"
case APIUnavailable: case APIUnavailable:
return "API unavailable" return "the requested API is unavailable"
case VersionUnavailable: case VersionUnavailable:
return "version unavailable" return "the requested API version is unavailable"
case PlatformError: case PlatformError:
return "platform error" return "a platform-specific error occurred"
case FormatUnavailable: case FormatUnavailable:
return "format unavailable" return "the requested format is unavailable"
case NoWindowContext: case NoWindowContext:
return "no window context" return "the specified window has no context"
default: default:
return fmt.Sprintf("GLFW error code (%d)", e) return fmt.Sprintf("GLFW error (%d)", e)
} }
} }
const (
Connected = PeripheralEvent(0x00040001)
Disconnected = PeripheralEvent(0x00040002)
)
const ( const (
ArrowCursor = StandardCursor(0x00036001) ArrowCursor = StandardCursor(0x00036001)
IBeamCursor = StandardCursor(0x00036002) IBeamCursor = StandardCursor(0x00036002)

View File

@ -36,7 +36,7 @@ func (g *Graphics) SetGLFWClientAPI() {
glfw.WindowHint(glfw.ContextVersionMinor, 2) glfw.WindowHint(glfw.ContextVersionMinor, 2)
// macOS requires forward-compatible and a core profile. // macOS requires forward-compatible and a core profile.
if runtime.GOOS == "darwin" { if runtime.GOOS == "darwin" {
glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True) glfw.WindowHint(glfw.OpenGLForwardCompat, glfw.True)
glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile) glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
} }
} }

View File

@ -27,8 +27,8 @@ var glfwMouseButtonToMouseButton = map[glfw.MouseButton]MouseButton{
glfw.MouseButtonLeft: MouseButton0, glfw.MouseButtonLeft: MouseButton0,
glfw.MouseButtonMiddle: MouseButton1, glfw.MouseButtonMiddle: MouseButton1,
glfw.MouseButtonRight: MouseButton2, glfw.MouseButtonRight: MouseButton2,
glfw.MouseButton3: MouseButton3, glfw.MouseButton4: MouseButton3,
glfw.MouseButton4: MouseButton4, glfw.MouseButton5: MouseButton4,
} }
func (u *userInterfaceImpl) registerInputCallbacks() { func (u *userInterfaceImpl) registerInputCallbacks() {