use of org.terasology.engine.rendering.assets.texture.Texture in project Terasology by MovingBlocks.
the class LwjglGraphicsManager method registerCoreAssetTypes.
public void registerCoreAssetTypes(ModuleAwareAssetTypeManager assetTypeManager) {
// cast lambdas explicitly to avoid inconsistent compiler behavior wrt. type inference
assetTypeManager.createAssetType(Font.class, FontImpl::new, "fonts");
AssetType<Texture, TextureData> texture = assetTypeManager.createAssetType(Texture.class, (urn, assetType, data) -> (OpenGLTexture.create(urn, assetType, data, this)), "textures", "fonts");
assetTypeManager.getAssetFileDataProducer(texture).addAssetFormat(new PNGTextureFormat(Texture.FilterMode.NEAREST, path -> {
if (path.getPath().get(0).equals(ModuleAssetScanner.OVERRIDE_FOLDER)) {
return path.getPath().get(2).equals("textures");
} else {
return path.getPath().get(1).equals("textures");
}
}));
assetTypeManager.getAssetFileDataProducer(texture).addAssetFormat(new PNGTextureFormat(Texture.FilterMode.LINEAR, path -> {
if (path.getPath().get(0).equals(ModuleAssetScanner.OVERRIDE_FOLDER)) {
return path.getPath().get(2).equals("fonts");
} else {
return path.getPath().get(1).equals("fonts");
}
}));
assetTypeManager.createAssetType(Shader.class, (urn, assetType, data) -> GLSLShader.create(urn, assetType, data, this), "shaders");
assetTypeManager.createAssetType(Material.class, (urn, assetType, data) -> GLSLMaterial.create(urn, this, assetType, data), "materials");
assetTypeManager.createAssetType(Mesh.class, (urn, assetType, data) -> OpenGLMesh.create(urn, assetType, data, this), "mesh");
assetTypeManager.createAssetType(SkeletalMesh.class, (urn, assetType, data) -> OpenGLSkeletalMesh.create(urn, assetType, data, this), "skeletalMesh");
assetTypeManager.createAssetType(MeshAnimation.class, MeshAnimationImpl::new, "animations", "skeletalMesh");
assetTypeManager.createAssetType(Atlas.class, Atlas::new, "atlas");
assetTypeManager.createAssetType(MeshAnimationBundle.class, MeshAnimationBundle::new, "skeletalMesh", "animations");
assetTypeManager.createAssetType(Subtexture.class, Subtexture::new);
}
use of org.terasology.engine.rendering.assets.texture.Texture in project Terasology by MovingBlocks.
the class HeadlessGraphics method registerCoreAssetTypes.
@Override
public void registerCoreAssetTypes(ModuleAwareAssetTypeManager assetTypeManager) {
assetTypeManager.createAssetType(Font.class, FontImpl::new, "fonts");
AssetType<Texture, TextureData> texture = assetTypeManager.createAssetType(Texture.class, (urn, assetType, data) -> new HeadlessTexture(urn, assetType, data, new HeadlessTexture.DisposalAction()), "textures", "fonts");
assetTypeManager.getAssetFileDataProducer(texture).addAssetFormat(new PNGTextureFormat(Texture.FilterMode.NEAREST, path -> path.getPath().get(1).equals("textures")));
assetTypeManager.getAssetFileDataProducer(texture).addAssetFormat(new PNGTextureFormat(Texture.FilterMode.LINEAR, path -> path.getPath().get(1).equals("fonts")));
assetTypeManager.createAssetType(Shader.class, HeadlessShader::new, "shaders");
assetTypeManager.createAssetType(Material.class, HeadlessMaterial::new, "materials");
assetTypeManager.createAssetType(Mesh.class, HeadlessMesh::new, "mesh");
assetTypeManager.createAssetType(SkeletalMesh.class, HeadlessSkeletalMesh::new, "skeletalMesh");
assetTypeManager.createAssetType(MeshAnimation.class, MeshAnimationImpl::new, "animations");
assetTypeManager.createAssetType(Atlas.class, Atlas::new, "atlas");
assetTypeManager.createAssetType(Subtexture.class, Subtexture::new);
}
use of org.terasology.engine.rendering.assets.texture.Texture in project Terasology by MovingBlocks.
the class FontDataBuilder method endCharacter.
public FontDataBuilder endCharacter() {
Texture page = pages.get(characterPage);
FontCharacter character = new FontCharacter(((float) characterX / page.getWidth()), ((float) characterY / page.getHeight()), characterWidth, characterHeight, characterXOffset, characterYOffset, characterXAdvance, page, pageMats.get(characterPage));
characters.put(currentCharacterId, character);
return this;
}
use of org.terasology.engine.rendering.assets.texture.Texture in project Terasology by MovingBlocks.
the class PreviewWorldScreen method genTexture.
private void genTexture() {
int imgWidth = 384;
int imgHeight = 384;
ByteBuffer buffer = ByteBuffer.allocateDirect(imgWidth * imgHeight * Integer.BYTES);
ByteBuffer[] data = new ByteBuffer[] { buffer };
ResourceUrn uri = new ResourceUrn("engine:terrainPreview");
TextureData texData = new TextureData(imgWidth, imgHeight, data, Texture.WrapMode.CLAMP, Texture.FilterMode.LINEAR);
texture = Assets.generateAsset(uri, texData, Texture.class);
previewImage = find("preview", UIImage.class);
previewImage.setImage(texture);
}
use of org.terasology.engine.rendering.assets.texture.Texture in project Terasology by MovingBlocks.
the class GLSLMaterial method bindTextures.
@Override
public void bindTextures() {
if (isDisposed()) {
return;
}
enable();
for (int slot : textureMap.keys()) {
Texture texture = textureMap.get(slot);
if (texture.isDisposed()) {
textureMap.remove(slot);
logger.error("Attempted to bind disposed texture {}", texture);
} else {
shaderManager.bindTexture(slot, texture);
}
}
}
Aggregations