def reload(self, gl, full_reload=False): TM = TextureManager() self.texture_ref = TM.get_texture_from_resource(gl, DRAWABLE_LINE) self.vertex_buffer.reload() self.color_buffer.reload() self.text_coord_buffer.reload() self.index_buffer.reload()
def reload(self, gl, bool_full_reload): TM = TextureManager() self.texture_ref = TM.get_texture_from_resource(gl, DRAWABLE_STARS_TEXTURE) for data in self.sky_regions.region_data.values(): data.vertex_buffer.reload() data.color_buffer.reload() data.text_coord_buffer.reload() data.index_buffer.reload()
def __init__(self, debug_mode=None): ''' Constructor ''' QGLWidget.__init__(self) self.DEBUG_MODE = debug_mode self.texture_manager = TextureManager() self.render_state = RenderState() self.projection_matrix = None self.view_matrix = None self.update_closures = [] self.all_managers = [] self.managers_to_reload = [] self.layers_to_managers = {} def queue_for_reload(rom, full_reload): self.managers_to_reload.append(self.ManagerReloadData(rom, full_reload)) self.update_listener = queue_for_reload # The skybox should go behind everything. self.sky_box = SkyBox(0x10000000, self.texture_manager) self.sky_box.enabled = False self.add_object_manager(self.sky_box) #The overlays go on top of everything. self.overlay_manager = OverlayManager(0xEFFFFFFF, self.texture_manager) self.add_object_manager(self.overlay_manager)
def reload(self, gl, full_reload): imgs = self.images reload_buffers = False reload_images = False if full_reload: reload_buffers = True reload_images = True # If this is a full reload, all the textures were automatically deleted, # so just create new arrays so we won't try to delete the old ones again. self.textures = [None] * len(imgs) self.red_textures = [None] * len(imgs) else: # Process any queued updates. reset = self.update_type.Reset in self.updates reload_buffers = reload_buffers or reset or self.update_type.UpdatePositions in self.updates reload_images = reload_images or reset or self.update_type.UpdateImages in self.updates self.updates = set() if reload_buffers: self.vertex_buffer.reload() self.text_coord_buffer.reload() if reload_images: for i in range(0, len(self.textures)): #If the image is already allocated, delete it. if self.textures[i] != None: self.textures[i].delete(gl) self.red_textures[i].delete(gl) bmp = self.images[i].pixmap self.textures[i] = TextureManager().create_texture(gl) self.textures[i].bind(gl) gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR) gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR) gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE) gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE) ''' IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT The image has to be mirrored for some reason ''' q_img = QImage(bmp.toImage()).mirrored() img = QGLWidget.convertToGLFormat(q_img) gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, img.width(), img.height(), 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, str(img.bits())) self.red_textures[i] = TextureManager().create_texture(gl) self.red_textures[i].bind(gl) gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR) gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR) gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE) gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE) red_pixels = self.create_red_image(q_img) red_pixels = QGLWidget.convertToGLFormat(red_pixels) gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, red_pixels.width(), red_pixels.height(), 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, str(red_pixels.bits()))