use of com.jme3.texture.Texture in project jmonkeyengine by jMonkeyEngine.
the class J3MLoaderTest method newStyleTextureParameters_shouldBeSupported.
@Test
public void newStyleTextureParameters_shouldBeSupported() throws Exception {
when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/texture-parameters-newstyle.j3m"));
final Texture textureNoParameters = Mockito.mock(Texture.class);
final Texture textureFlip = Mockito.mock(Texture.class);
final Texture textureRepeat = Mockito.mock(Texture.class);
final Texture textureRepeatAxis = Mockito.mock(Texture.class);
final Texture textureMin = Mockito.mock(Texture.class);
final Texture textureMag = Mockito.mock(Texture.class);
final Texture textureCombined = Mockito.mock(Texture.class);
final Texture textureLooksLikeOldStyle = Mockito.mock(Texture.class);
final TextureKey textureKeyNoParameters = setupMockForTexture("Empty", "empty.png", false, textureNoParameters);
final TextureKey textureKeyFlip = setupMockForTexture("Flip", "flip.png", true, textureFlip);
setupMockForTexture("Repeat", "repeat.png", false, textureRepeat);
setupMockForTexture("RepeatAxis", "repeat-axis.png", false, textureRepeatAxis);
setupMockForTexture("Min", "min.png", false, textureMin);
setupMockForTexture("Mag", "mag.png", false, textureMag);
setupMockForTexture("Combined", "combined.png", true, textureCombined);
setupMockForTexture("LooksLikeOldStyle", "oldstyle.png", true, textureLooksLikeOldStyle);
j3MLoader.load(assetInfo);
verify(assetManager).loadTexture(textureKeyNoParameters);
verify(assetManager).loadTexture(textureKeyFlip);
verify(textureRepeat).setWrap(Texture.WrapMode.Repeat);
verify(textureRepeatAxis).setWrap(Texture.WrapAxis.T, Texture.WrapMode.Repeat);
verify(textureMin).setMinFilter(Texture.MinFilter.Trilinear);
verify(textureMag).setMagFilter(Texture.MagFilter.Bilinear);
verify(textureCombined).setMagFilter(Texture.MagFilter.Nearest);
verify(textureCombined).setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
verify(textureCombined).setWrap(Texture.WrapMode.Repeat);
}
use of com.jme3.texture.Texture in project jmonkeyengine by jMonkeyEngine.
the class HDRLoader method load.
public Object load(AssetInfo info) throws IOException {
if (!(info.getKey() instanceof TextureKey))
throw new IllegalArgumentException("Texture assets must be loaded using a TextureKey");
boolean flip = ((TextureKey) info.getKey()).isFlipY();
InputStream in = null;
try {
in = info.openStream();
Image img = load(in, flip);
return img;
} finally {
if (in != null) {
in.close();
}
}
}
use of com.jme3.texture.Texture in project jmonkeyengine by jMonkeyEngine.
the class JmeBatchRenderBackend method createAtlasTextureInternal.
// internal implementations
private Texture2D createAtlasTextureInternal(final int width, final int height) throws Exception {
ByteBuffer initialData = BufferUtils.createByteBuffer(width * height * 4);
for (int i = 0; i < width * height * 4; i++) {
initialData.put((byte) 0x00);
}
initialData.rewind();
Texture2D texture = new Texture2D(new com.jme3.texture.Image(Format.RGBA8, width, height, initialData, ColorSpace.sRGB));
texture.setMinFilter(MinFilter.NearestNoMipMaps);
texture.setMagFilter(MagFilter.Nearest);
return texture;
}
use of com.jme3.texture.Texture in project jmonkeyengine by jMonkeyEngine.
the class JmeBatchRenderBackend method loadImage.
@Override
public Image loadImage(final String filename) {
TextureKey key = new TextureKey(filename, false);
key.setAnisotropy(0);
key.setGenerateMips(false);
Texture2D texture = (Texture2D) display.getAssetManager().loadTexture(key);
return new ImageImpl(texture.getImage());
}
use of com.jme3.texture.Texture in project jmonkeyengine by jMonkeyEngine.
the class JmeBatchRenderBackend method createNonAtlasTexture.
@Override
public int createNonAtlasTexture(final Image image) {
ImageImpl imageImpl = (ImageImpl) image;
Texture2D texture = new Texture2D(imageImpl.image);
texture.setMinFilter(MinFilter.NearestNoMipMaps);
texture.setMagFilter(MagFilter.Nearest);
return addTexture(texture);
}
Aggregations