glfw: Remove some suspicious codes depending on the memory layout

This commit is contained in:
Hajime Hoshi 2020-09-04 01:10:39 +09:00
parent a3b41515a9
commit ee15e06c50

View File

@ -24,15 +24,6 @@ import (
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )
type glfwVidMode struct {
width int32
height int32
redBits int32
greenBits int32
blueBits int32
refreshRate int32
}
type glfwImage struct { type glfwImage struct {
width int32 width int32
height int32 height int32
@ -87,14 +78,13 @@ func (m *Monitor) GetPos() (int, int) {
func (m *Monitor) GetVideoMode() *VidMode { func (m *Monitor) GetVideoMode() *VidMode {
v := glfwDLL.call("glfwGetVideoMode", m.m) v := glfwDLL.call("glfwGetVideoMode", m.m)
panicError() panicError()
vv := (*glfwVidMode)(unsafe.Pointer(v))
return &VidMode{ return &VidMode{
Width: int(vv.width), Width: int(*(*int32)(unsafe.Pointer(v))),
Height: int(vv.height), Height: int(*(*int32)(unsafe.Pointer(v + 4))),
RedBits: int(vv.redBits), RedBits: int(*(*int32)(unsafe.Pointer(v + 8))),
GreenBits: int(vv.greenBits), GreenBits: int(*(*int32)(unsafe.Pointer(v + 12))),
BlueBits: int(vv.blueBits), BlueBits: int(*(*int32)(unsafe.Pointer(v + 16))),
RefreshRate: int(vv.refreshRate), RefreshRate: int(*(*int32)(unsafe.Pointer(v + 20))),
} }
} }