Ejemplo n.º 1
0
 def center_pos(self, monitor_id):
     m = glfw.GetMonitors()
     assert monitor_id >= 0 and monitor_id < len(m)
     monitor_pos = glfw.GetMonitorPos(m[monitor_id])
     video_mode = glfw.GetVideoMode(m[monitor_id])
     xpos = monitor_pos[0] + video_mode.width / 2 - self._width / 2
     ypos = monitor_pos[1] + video_mode.height / 2 - self._height / 2
     glfw.SetWindowPos(self._window, xpos, ypos)
Ejemplo n.º 2
0
 def test_get_monitors_test_fullscreen(self):
     monitors = glfw.GetMonitors()
     for monitor in monitors:
         self.assertIsInstance(glfw.GetMonitorName(monitor), str)
         x, y = glfw.GetMonitorPos(monitor)
         width, height = glfw.GetMonitorPhysicalSize(monitor)
         window = glfw.CreateWindow(width, height, 'Monitors', monitor)
         glfw.DestroyWindow(window)
def center_pos(monitor_id, W, H):
    # W, H: window dimensions
    mon = glfw.GetMonitors()
    xpos = glfw.GetMonitorPos(mon[monitor_id])[0]+glfw.GetVideoMode(mon[monitor_id]).width/2-W/2
    ypos = glfw.GetMonitorPos(mon[monitor_id])[1]+glfw.GetVideoMode(mon[monitor_id]).height/2-H/2
    glfw.SetWindowPos(window, xpos, ypos)
def center_pos(monitor_id):
    xpos = glfw.GetMonitorPos(mon[monitor_id])[0] + glfw.GetVideoMode(
        mon[monitor_id]).width / 2 - W / 2
    ypos = glfw.GetMonitorPos(mon[monitor_id])[1] + glfw.GetVideoMode(
        mon[monitor_id]).height / 2 - H / 2
    glfw.SetWindowPos(window, xpos, ypos)

glfw.SetErrorCallback(glfw_error_callback)

if not glfw.Init():
    exit(-1)
    # Handle initialization failure

monitor_id = 0

mon = glfw.GetMonitors()
for m in mon:
    mode = glfw.GetVideoMode(m)
    W, H = glfw.GetMonitorPhysicalSize(m)
    print mode.width, mode.height
    print glfw.GetMonitorPos(m)
    print glfw.GetMonitorName(m)

W = 1024
H = int(W / (16. / 9.))

window = glfw.CreateWindow(W, H, "My Title", None, None)
glfw.MakeContextCurrent(window)


def center_pos(monitor_id):
    xpos = glfw.GetMonitorPos(mon[monitor_id])[0] + glfw.GetVideoMode(
        mon[monitor_id]).width / 2 - W / 2
    ypos = glfw.GetMonitorPos(mon[monitor_id])[1] + glfw.GetVideoMode(
        mon[monitor_id]).height / 2 - H / 2
    glfw.SetWindowPos(window, xpos, ypos)