def paintGL(self): if self.crashFlag: #run cleanup operations glUseProgram(0) glDisableVertexAttribArray(self.attrID) glDeleteBuffers(1,[self.vertexBuffer]) glDeleteVertexArrays(1, [self.vertexArrayID]) glLoadIdentity() gluPerspective(45, self.sizeX / self.sizeY, 0.1, 110.0) #set perspective glTranslatef(0, 0, self.zoomLevel) glRotatef(self.rotateDegreeV + self.vOffset, 1, 0, 0) glRotatef(self.rotateDegreeH, 0, 0, 1) glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) self.vertexData = [ -1, 1, 0, 0, -1, 0, 1, 1, 0 ] arrayType = GLfloat * len(self.vertexData) target = GL_ARRAY_BUFFER offset = 0 size = len(self.vertexData) * ctypes.sizeof(ctypes.c_float) data = arrayType(*self.vertexData) glBufferSubData(target, offset, size, data) glDrawArrays(GL_TRIANGLES, 0, 3)
def resize(self, xres: int, yres: int, spacing: float = 1.0) -> None: self._vertices = [] self._indices = [] self._vertex_count = 0 ystart = -(yres * spacing / 2.0) xstart = -(xres * spacing / 2.0) for j in range(0, yres): y = ystart + (j * spacing) for i in range(0, xres): x = xstart + (i * spacing) self._vertices += [x, y, 0.0] for j in range(0, yres - 1): offset = j * xres for i in range(0, xres - 1): k = offset + i self._indices += [ k, k + 1, k + 1, k + xres + 1, k + xres + 1, k + xres, k + xres, k, ] self._vertex_count = len(self._indices) if self._vao > -1: glDeleteVertexArrays(1, [self._vao]) self._vao = -1
def __del__(self): """Destructor. Destroys the VAO and related buffers associated with mesh. """ glDeleteVertexArrays(1, [self.vao]) glDeleteBuffers(len(self.buffers), self.buffers)
def destroy(self) -> bool: """ Destroy objects self """ if self._vao > -1: glDeleteVertexArrays(1, [self._vao]) return True
def unload(self): """Unload all opengl data""" log.debug(f"unload {self}") if self._vbo is not None: glDeleteBuffers(1, int(self._vbo)) self._vbo = None if self._vao is not None: glDeleteVertexArrays(1, int(self._vao)) self._vao = None
def destroy(self) -> bool: """ Destroy objects self. Returns: bool: `True` on successful destroy of `self`. """ if self.has_vao: glDeleteVertexArrays(1, [self._vao]) self._vao = -1 return True
def destroy(self) -> None: """ Deletes all the VAOs and VBOs from the video-memory when the application is closed. """ for vao in self.__vaos: glDeleteVertexArrays(1, vao) self.__vaos = [] for vbo in self.__vbos: glDeleteBuffers(1, vbo) self.__vbos = []
def dispose_vertex_array(vertex_array): if vertex_array is not None: glDeleteVertexArrays(1, (vertex_array, ))
def __del__(self): glDeleteVertexArrays(1, self.m_RendererID)
def remove_from_vao(self, vao_id: int) -> None: glDeleteVertexArrays(1, vao_id)