I have a simple program in glfw
, which uses glfw.glfwSetCursorPos
to put the mouse in a certain spot on the screen. However, it was raising a lot of errors, until I found this thread: ctypes.ArgumentError: Don't know how to convert parameter. Now, it works, but one of its parameters is the returned value from glfw.CreateWindow
that you want to center on. But, following the accepted and only answer on that thread, I have no idea what variable in ctypes
I should use to represent the window in the argtypes for that function, if there even is a variable for a glfw window. And if there isn't one, is there any other way to fix my original problem?
Thanks!
EDIT
Here is a minimal reproductible example. The moment you move the mouse, you can see that it starts spamming to sys.stderr
:
import OpenGL
from OpenGL.GL import *
import glfw
glfw.glfwInit()
def onMouseMove(win2, x, y):
print(x, y)
glfw.glfwSetCursorPos.argtypes = [glfw.GLFWwindow,
ctypes.c_float,
ctypes.c_float]
glfw.glfwSetCursorPos(win, float(50), float(50))
glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 3)
glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 3)
glfw.glfwWindowHint(glfw.GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE)
glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_CORE_PROFILE)
win = glfw.glfwCreateWindow()
glfw.glfwMakeContextCurrent(win)
glfw.glfwSetInputMode(win, glfw.GLFW_CURSOR,
glfw.GLFW_CURSOR_DISABLED)
glfw.glfwSetCursorPosCallback(win, onMouseMove)
while not glfw.glfwWindowShouldClose(win):
glfw.glfwPollEvents()
glfw.glfwTerminate()