# (c) Tuomas J. Lukka from __future__ import nested_scopes import java import vob import org from test.tools.gfx import * needGL() def testSingleGetsLoaded_nosynch(): """Test with separate copies of a single image that the image gets loaded to the right levels of detail. XXX Make this test not use compressed textures... """ indirectMipzipManager = org.nongnu.libvob.gl.virtualtexture.NonDeletingIndirectMipzipManager( "COMPRESSED_RGB_S3TC_DXT1_EXT", 1024, 1024) indirectMipzipManager.glBackground = vob.util.ExplicitBackground(); indirectMipzipManager.background = vob.util.ExplicitBackground(); indirectMipzipManager.setAllocations([ 1, 2, 4,6, 8, 0, 0, 0, 0, 0, 0]) virtualTextures = [ org.nongnu.libvob.gl.virtualtexture.VirtualTexture(vob.gl.GL.createIndirectTexture(), vob.gl.MipzipFile(java.io.File("testdata/modularspace.mipzip"))) for i in range(0, 20)] def vt(*ar): def mvt(i): if i == None: return None return virtualTextures[i] return [mvt(i) for i in ar] indirectMipzipManager.setSlotContents([ vt(0), vt(1,2), vt(3,4,5,6), vt(7,8,9,10,11,12), vt(13,14,15,16,17,18,19,None), [], [], [], [], [], [] ]) def gb(i): """Get the base level of the given texture. 100 = not loaded. """ tex = virtualTextures[i].indirectTexture.getTexture() if tex == None: return 100 return tex.getParameter("TEXTURE_BASE_LEVEL")[0] def totlev(i, l): """Whether the virtualtexture i is totally loaded at level l. """ if gb(i) != 0: return 0 tex = virtualTextures[i].indirectTexture.getTexture() wid = tex.getLevelParameter(0, "TEXTURE_WIDTH")[0] if wid != (1024 >> l): return 0 return 1 done = 0 for i in range(0, 10000): indirectMipzipManager.glBackground.performOneTask() indirectMipzipManager.background.performOneTask() if totlev(0,0) and totlev(1,1) and totlev(10,3) and totlev(19,4): done = 1 break assert done, (gb(0), gb(1), gb(10), gb(19)) indirectMipzipManager.setSlotContents([ vt(1), vt(3,0), vt(4,2,5,6), vt(7,8,9,10,11,12), vt(13,14,15,16,17,18,19,None), [], [], [], [], [], [] ]) done = 0 for i in range(0, 10000): indirectMipzipManager.glBackground.performOneTask() indirectMipzipManager.background.performOneTask() if totlev(0,1) and totlev(1,0) and totlev(3, 1) \ and totlev(10,3) and totlev(19,4): done = 1 break assert done, (gb(0), gb(1), gb(10), gb(19)) # vim: set syntax=python :