def render(self, context): t = context.timer.elapsed #model = transforms.identity() #view = transforms.identity() #projection = transforms.identity() #tex_coord_transform = transforms.identity() gl.clear_color(self._background) gl.clear() with gl.bound(self._program), gl.bound(self._vao): self._program.uniforms[ "iResolution"] = context.video.global_.resolution self._program.uniforms["iTime"] = t ''' self._program.uniforms["model"] = model self._program.uniforms["view"] = view self._program.uniforms["projection"] = projection ''' self._program.uniforms[ "tex_coord_transform"] = self._tex_coord_transform gl.depth_mask(False) GL.glDrawArrays(GL.GL_POINTS, 0, 1) gl.depth_mask(True)
def debugLogInfo(): _logger.info("PC: %s", applications.hostname()) _logger.info("Qt: %s", QtCore.QT_VERSION_STR) _logger.info("GL: %s", str(GL.glGetString(GL.GL_VERSION), "utf-8")) _logger.info("GLSL: %s", str(GL.glGetString(GL.GL_SHADING_LANGUAGE_VERSION), "utf-8")) screen = QtGui.QGuiApplication.primaryScreen() _logger.info("Screen: %.2f Hz", screen.refreshRate())
def debugLogExtensions(): _logger.info("Extensions:") for i in range(GL.glGetIntegerv(GL.GL_NUM_EXTENSIONS)): _logger.info(str(GL.glGetStringi(GL.GL_EXTENSIONS, i), "utf-8")) ''' hdc = wgl.get_current_dc() for name in str(wgl.get_extension_string(hdc), "utf-8").split(): _logger.info(name) ''' '''
def draw_arrays(self, mode=Unspecified, first=Unspecified, count=Unspecified, patch_vertices=Unspecified, renderer=Unspecified): mode = getspecified(mode, self._mode) first = getspecified(first, getspecified(self._first, 0)) count = getspecified(count, getspecified(self._count, 0)) patch_vertices = getspecified(patch_vertices, self._patch_vertices) if mode == GL.GL_PATCHES: GL.glPatchParameteri(GL.GL_PATCH_VERTICES, patch_vertices) GL.glDrawArrays(mode, first, count)
def save_screenshot(self, path, *args, **kwargs): import PIL.Image w, h = self.window.size GL.glReadBuffer(GL.GL_FRONT) data = GL.glReadPixels(0, 0, w, h, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE) image = PIL.Image.frombytes(mode="RGBA", size=(w, h), data=data) image = image.transpose(PIL.Image.FLIP_TOP_BOTTOM) image.save(path, 'PNG')
def draw_indices_instanced(self, instances, mode=Unspecified, first=Unspecified, count=Unspecified, patch_vertices=Unspecified, renderer=Unspecified): renderer.activate(self._ibo) _type = self._ibo.type _count = self._ibo.count mode = getspecified(mode, self._mode) first = getspecified(first, getspecified(self._first, 0)) count = getspecified(count, getspecified(self._count, _count)) patch_vertices = getspecified(patch_vertices, self._patch_vertices) if mode == GL.GL_PATCHES: GL.glPatchParameteri(GL.GL_PATCH_VERTICES, patch_vertices) GL.glDrawElementsInstanced(mode, count, _type.dtype.type, ctypes.c_void_p(first * _type.dtype.nbytes), instances)
def activate(self, renderer): if self.prepare(renderer=renderer): self._value.bind(self._value) GL.glDrawBuffers(self._draw_buffers)