More hacky changes to texture coordinates, to allow 1024-slot texture sheets.

This commit is contained in:
David Vierra 2014-01-02 18:47:44 -10:00
parent 8607c37dfb
commit e718755dd4
2 changed files with 15 additions and 6 deletions

View File

@ -33,17 +33,21 @@ class BlockView(GLOrtho):
GL.glEnable(GL.GL_TEXTURE_2D)
GL.glEnable(GL.GL_ALPHA_TEST)
self.materials.terrainTexture.bind()
pixelScale = 0.5 if self.materials.name in ("Pocket", "Alpha") else 1.0
texSize = 16 * pixelScale
GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
GL.glVertexPointer(2, GL.GL_FLOAT, 0, array([-1, -1,
- 1, 1,
1, 1,
1, -1, ], dtype='float32'))
texOrigin = self.materials.blockTextures[blockInfo.ID, blockInfo.blockData, 0]
texOrigin = array(self.materials.blockTextures[blockInfo.ID, blockInfo.blockData, 0])
texOrigin *= pixelScale
GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, array([texOrigin[0], texOrigin[1] + 16,
GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, array([texOrigin[0], texOrigin[1] + texSize,
texOrigin[0], texOrigin[1],
texOrigin[0] + 16, texOrigin[1],
texOrigin[0] + 16, texOrigin[1] + 16], dtype='float32'))
texOrigin[0] + texSize, texOrigin[1],
texOrigin[0] + texSize, texOrigin[1] + texSize], dtype='float32'))
GL.glDrawArrays(GL.GL_QUADS, 0, 4)

View File

@ -481,8 +481,13 @@ class PlayerSpawnPositionTool(PlayerPositionTool):
GL.glDisable(GL.GL_DEPTH_TEST)
def drawCage(self, x, y, z):
cageTexVerts = pymclevel.MCInfdevOldLevel.materials.blockTextures[52, 0]
cageTexVerts = numpy.array([((tx, ty), (tx + 16, ty), (tx + 16, ty + 16), (tx, ty + 16)) for (tx, ty) in cageTexVerts], dtype='float32')
cageTexVerts = numpy.array(pymclevel.MCInfdevOldLevel.materials.blockTextures[52, 0])
pixelScale = 0.5 if self.editor.level.materials.name in ("Pocket", "Alpha") else 1.0
texSize = 16 * pixelScale
cageTexVerts *= pixelScale
cageTexVerts = numpy.array([((tx, ty), (tx + texSize, ty), (tx + texSize, ty + texSize), (tx, ty + texSize)) for (tx, ty) in cageTexVerts], dtype='float32')
GL.glEnable(GL.GL_ALPHA_TEST)
drawCube(BoundingBox((x, y, z), (1, 1, 1)), texture=pymclevel.alphaMaterials.terrainTexture, textureVertices=cageTexVerts)