Skip to content

glfw.glfwGetVideoMode(monitor) failing #5

Open
@DrLuke

Description

@DrLuke

On python3, glfw.glfwGetVideoMode(monitor) will fail with the following error:

File "/home/drluke/prog/cockamamie/pyglfw/glfw.py", line 576, in glfwGetVideoMode
    return (c_mode.width,
AttributeError: 'LP_GLFWvidmode' object has no attribute 'width'

One working fix is to change the function from

def glfwGetVideoMode(monitor):
    _glfw.glfwGetVideoMode.restype = POINTER(GLFWvidmode)
    c_mode = _glfw.glfwGetVideoMode(monitor)
    return (c_mode.width,
            c_mode.height,
            c_mode.redBits,
            c_mode.blueBits,
            c_mode.greenBits,
            c_mode.refreshRate )

to

def glfwGetVideoMode(monitor):
    _glfw.glfwGetVideoMode.restype = POINTER(GLFWvidmode)
    c_mode = _glfw.glfwGetVideoMode(monitor)
    return (c_mode[0].width,
            c_mode[0].height,
            c_mode[0].redBits,
            c_mode[0].blueBits,
            c_mode[0].greenBits,
            c_mode[0].refreshRate )

I am not certain if this breaks functionality for python2 though, so I didn't yet submit a pullrequest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions