def getGammaRamp(self): # get the current gamma ramp win = glfw.get_window_user_pointer(self.winHandle) # if not fullscreen, we get an access violation (bug?) if not win._isFullScr: return None monitor = glfw.get_window_monitor(self.winHandle) currentGammaRamp = glfw.get_gamma_ramp(monitor) return np.asarray(currentGammaRamp, dtype=np.float32)
def __init__( self, size_pix=(760, 760), colour=(0.5, 0.5, 0.5), event_buffer_size=20, gamma=None, close_on_exit=True, global_quit=True, ): self._global_quit = global_quit self.close_on_exit = close_on_exit self._event_buffer = collections.deque(maxlen=event_buffer_size) glfw.init() glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3) glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3) glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, 1) glfw.window_hint(glfw.DOUBLEBUFFER, glfw.TRUE) self.monitor = glfw.get_primary_monitor() self._orig_gamma = glfw.get_gamma_ramp(self.monitor) if gamma is not None: glfw.set_gamma(monitor=self.monitor, gamma=gamma) self.win = glfw.create_window( width=size_pix[0], height=size_pix[1], title="window", monitor=None, share=None, ) glfw.make_context_current(self.win) glfw.swap_interval(0) glfw.set_key_callback(self.win, self.key_event_callback) glfw.set_window_close_callback(self.win, self.window_close_callback) self.colour = colour self.flip() glfw.set_time(0.0) self.nests = 0
def getGammaRampSize(self): """Get the gamma ramp size for the current display. The size of the ramp depends on the bits-per-color of the current video mode. :return: """ # get the current gamma ramp win = glfw.get_window_user_pointer(self.winHandle) if not win._isFullScr: return None monitor = glfw.get_window_monitor(self.winHandle) currentGammaRamp = glfw.get_gamma_ramp(monitor) # get the gamma ramps for each color channel red_ramp = currentGammaRamp[0] green_ramp = currentGammaRamp[1] blue_ramp = currentGammaRamp[2] return max(len(red_ramp), len(green_ramp), len(blue_ramp))