Java Code Examples for com.jme3.texture.Texture#getWrap()
The following examples show how to use
com.jme3.texture.Texture#getWrap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: J3MOutputCapsule.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected static String formatWrapMode(Texture texVal, Texture.WrapAxis axis) { WrapMode mode; try { mode = texVal.getWrap(axis); } catch (IllegalArgumentException e) { //this axis doesn't exist on the texture return ""; } if (mode != WrapMode.EdgeClamp) { return "Wrap" + mode.name() + "_" + axis.name() + " "; } return ""; }
Example 2
Source File: MatParam.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private String getWrapMode(Texture texVal, Texture.WrapAxis axis) { WrapMode mode = WrapMode.EdgeClamp; try{ mode = texVal.getWrap(axis); }catch (IllegalArgumentException e){ //this axis doesn't exist on the texture return ""; } if(mode != WrapMode.EdgeClamp){ return"Wrap"+ mode.name() + "_" + axis.name() + " "; } return ""; }
Example 3
Source File: GLRenderer.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@SuppressWarnings("fallthrough") private void setupTextureParams(int unit, Texture tex) { Image image = tex.getImage(); int samples = image != null ? image.getMultiSamples() : 1; int target = convertTextureType(tex.getType(), samples, -1); if (samples > 1) { bindTextureOnly(target, image, unit); return; } boolean haveMips = true; if (image != null) { haveMips = image.isGeneratedMipmapsRequired() || image.hasMipmaps(); } LastTextureState curState = image.getLastTextureState(); if (curState.magFilter != tex.getMagFilter()) { bindTextureAndUnit(target, image, unit); gl.glTexParameteri(target, GL.GL_TEXTURE_MAG_FILTER, convertMagFilter(tex.getMagFilter())); curState.magFilter = tex.getMagFilter(); } if (curState.minFilter != tex.getMinFilter()) { bindTextureAndUnit(target, image, unit); gl.glTexParameteri(target, GL.GL_TEXTURE_MIN_FILTER, convertMinFilter(tex.getMinFilter(), haveMips)); curState.minFilter = tex.getMinFilter(); } int desiredAnisoFilter = tex.getAnisotropicFilter() == 0 ? defaultAnisotropicFilter : tex.getAnisotropicFilter(); if (caps.contains(Caps.TextureFilterAnisotropic) && curState.anisoFilter != desiredAnisoFilter) { bindTextureAndUnit(target, image, unit); gl.glTexParameterf(target, GLExt.GL_TEXTURE_MAX_ANISOTROPY_EXT, desiredAnisoFilter); curState.anisoFilter = desiredAnisoFilter; } switch (tex.getType()) { case ThreeDimensional: case CubeMap: // cubemaps use 3D coords if (gl2 != null && (caps.contains(Caps.OpenGL20) || caps.contains(Caps.OpenGLES30)) && curState.rWrap != tex.getWrap(WrapAxis.R)) { bindTextureAndUnit(target, image, unit); gl.glTexParameteri(target, GL2.GL_TEXTURE_WRAP_R, convertWrapMode(tex.getWrap(WrapAxis.R))); curState.rWrap = tex.getWrap(WrapAxis.R); } //There is no break statement on purpose here case TwoDimensional: case TwoDimensionalArray: if (curState.tWrap != tex.getWrap(WrapAxis.T)) { bindTextureAndUnit(target, image, unit); gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_T, convertWrapMode(tex.getWrap(WrapAxis.T))); image.getLastTextureState().tWrap = tex.getWrap(WrapAxis.T); } if (curState.sWrap != tex.getWrap(WrapAxis.S)) { bindTextureAndUnit(target, image, unit); gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_S, convertWrapMode(tex.getWrap(WrapAxis.S))); curState.sWrap = tex.getWrap(WrapAxis.S); } break; default: throw new UnsupportedOperationException("Unknown texture type: " + tex.getType()); } ShadowCompareMode texCompareMode = tex.getShadowCompareMode(); if ( (gl2 != null || caps.contains(Caps.OpenGLES30)) && curState.shadowCompareMode != texCompareMode) { bindTextureAndUnit(target, image, unit); if (texCompareMode != ShadowCompareMode.Off) { gl.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL2.GL_COMPARE_REF_TO_TEXTURE); if (texCompareMode == ShadowCompareMode.GreaterOrEqual) { gl.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_GEQUAL); } else { gl.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_LEQUAL); } } else { gl.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL.GL_NONE); } curState.shadowCompareMode = texCompareMode; } // If at this point we didn't bind the texture, bind it now bindTextureOnly(target, image, unit); }
Example 4
Source File: GLRenderer.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Validates if a potentially NPOT texture is supported by the hardware. * <p> * Textures with power-of-2 dimensions are supported on all hardware, however * non-power-of-2 textures may or may not be supported depending on which * texturing features are used. * * @param tex The texture to validate. * @throws RendererException If the texture is not supported by the hardware */ private void checkNonPowerOfTwo(Texture tex) { if (!tex.getImage().isNPOT()) { // Texture is power-of-2, safe to use. return; } if (caps.contains(Caps.NonPowerOfTwoTextures)) { // Texture is NPOT but it is supported by video hardware. return; } // Maybe we have some / partial support for NPOT? if (!caps.contains(Caps.PartialNonPowerOfTwoTextures)) { // Cannot use any type of NPOT texture (uncommon) throw new RendererException("non-power-of-2 textures are not " + "supported by the video hardware"); } // Partial NPOT supported.. if (tex.getMinFilter().usesMipMapLevels()) { throw new RendererException("non-power-of-2 textures with mip-maps " + "are not supported by the video hardware"); } switch (tex.getType()) { case CubeMap: case ThreeDimensional: if (tex.getWrap(WrapAxis.R) != Texture.WrapMode.EdgeClamp) { throw new RendererException("repeating non-power-of-2 textures " + "are not supported by the video hardware"); } // fallthrough intentional!!! case TwoDimensionalArray: case TwoDimensional: if (tex.getWrap(WrapAxis.S) != Texture.WrapMode.EdgeClamp || tex.getWrap(WrapAxis.T) != Texture.WrapMode.EdgeClamp) { throw new RendererException("repeating non-power-of-2 textures " + "are not supported by the video hardware"); } break; default: throw new UnsupportedOperationException("unrecongized texture type"); } }