class LoadableChunksRenderNode(rendernode.RenderNode): floorTexture = None def compile(self): if self.floorTexture is None: self.floorTexture = Texture(image=floorTexImage, width=2, height=2, minFilter=GL.GL_NEAREST, magFilter=GL.GL_NEAREST, ) self.floorTexture.load() super(LoadableChunksRenderNode, self).compile() def drawSelf(self): with gl.glPushAttrib(GL.GL_FOG_BIT | GL.GL_ENABLE_BIT): GL.glDisable(GL.GL_FOG) GL.glEnable(GL.GL_BLEND) GL.glEnable(GL.GL_POLYGON_OFFSET_FILL) GL.glPolygonOffset(DepthOffsets.ChunkMarkers, DepthOffsets.ChunkMarkers) GL.glEnable(GL.GL_DEPTH_TEST) GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY) GL.glEnable(GL.GL_TEXTURE_2D) GL.glColor(1.0, 1.0, 1.0, 1.0) self.floorTexture.bind() for vertexArray in self.sceneNode.createVertexArrays(): GL.glVertexPointer(3, GL.GL_FLOAT, 0, vertexArray.ravel()) # chunkPositions *= 8 GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, (vertexArray[..., (0, 2)] / 32).ravel()) GL.glDrawArrays(GL.GL_QUADS, 0, len(vertexArray) * 4) GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
def compile(self): if self.floorTexture is None: self.floorTexture = Texture( image=floorTexImage, width=2, height=2, minFilter=GL.GL_NEAREST, magFilter=GL.GL_NEAREST, ) self.floorTexture.load() super(LoadableChunksRenderNode, self).compile()
def compile(self): if self.floorTexture is None: self.floorTexture = Texture(image=floorTexImage, width=2, height=2, minFilter=GL.GL_NEAREST, magFilter=GL.GL_NEAREST, ) self.floorTexture.load() super(LoadableChunksRenderNode, self).compile()
class LoadableChunksRenderNode(rendernode.RenderNode): floorTexture = None def compile(self): if self.floorTexture is None: self.floorTexture = Texture( image=floorTexImage, width=2, height=2, minFilter=GL.GL_NEAREST, magFilter=GL.GL_NEAREST, ) self.floorTexture.load() super(LoadableChunksRenderNode, self).compile() def drawSelf(self): with gl.glPushAttrib(GL.GL_FOG_BIT | GL.GL_ENABLE_BIT): GL.glDisable(GL.GL_FOG) GL.glEnable(GL.GL_BLEND) GL.glEnable(GL.GL_POLYGON_OFFSET_FILL) GL.glPolygonOffset(DepthOffset.ChunkMarkers, DepthOffset.ChunkMarkers) GL.glEnable(GL.GL_DEPTH_TEST) GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY) GL.glEnable(GL.GL_TEXTURE_2D) GL.glColor(1.0, 1.0, 1.0, 1.0) self.floorTexture.bind() for vertexArray in self.sceneNode.createVertexArrays(): GL.glVertexPointer(3, GL.GL_FLOAT, 0, vertexArray.ravel()) # chunkPositions *= 8 GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, (vertexArray[..., (0, 2)] / 32).ravel()) GL.glDrawArrays(GL.GL_QUADS, 0, len(vertexArray) * 4) GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
def getModelTexture(self, texturePath): if texturePath in self.modelTextures: return self.modelTextures[texturePath] try: w, h, rgba = loadPNGData( self.textureAtlas.resourceLoader.openStream( texturePath).read()) except Exception as e: log.exception("Model texture %s could not be loaded", texturePath) else: modelTex = Texture(image=rgba[::-1], width=w, height=h) self.modelTextures[texturePath] = modelTex return modelTex
def getMapTexture(self, mapID): if mapID in self.mapTextures: return self.mapTextures[mapID] try: mapData = self.worldScene.dimension.worldEditor.getMap(mapID) except Exception as e: log.exception( "Map %s could not be loaded (while loading GL texture)", mapID) else: colors = mapData.getColorsAsRGBA() mapTex = Texture(image=colors.ravel(), width=colors.shape[1], height=colors.shape[0]) self.mapTextures[mapID] = mapTex return mapTex
def floorTexture(self): if self._floorTexture is None: self._floorTexture = Texture(makeFloorTex) return self._floorTexture