public static void applyBorderColor(final Texture texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record) { final ReadOnlyColorRGBA texBorder = texture.getBorderColor(); if (!texRecord.isValid() || !texRecord.borderColor.equals(texBorder)) { TextureRecord.colorBuffer.clear(); TextureRecord.colorBuffer.put(texBorder.getRed()).put(texBorder.getGreen()).put(texBorder.getBlue()) .put(texBorder.getAlpha()); TextureRecord.colorBuffer.rewind(); GL11.glTexParameter(getGLType(texture.getType()), GL11.GL_TEXTURE_BORDER_COLOR, TextureRecord.colorBuffer); texRecord.borderColor.set(texBorder); } }
public static void applyBorderColor(final Texture texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record) { final ReadOnlyColorRGBA texBorder = texture.getBorderColor(); if (!texRecord.isValid() || !texRecord.borderColor.equals(texBorder)) { TextureRecord.colorBuffer.clear(); TextureRecord.colorBuffer.put(texBorder.getRed()).put(texBorder.getGreen()).put(texBorder.getBlue()) .put(texBorder.getAlpha()); TextureRecord.colorBuffer.rewind(); GL11C.glTexParameterfv(getGLType(texture.getType()), GL11C.GL_TEXTURE_BORDER_COLOR, TextureRecord.colorBuffer); texRecord.borderColor.set(texBorder); } }
/** * Check if the wrap mode of this particular texture has been changed and apply as needed. * * @param texture * our texture object * @param texRecord * our record of the last state of the unit in gl * @param record */ public static void applyWrap(final Texture1D texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final int wrapS = getGLWrap(texture.getWrap(WrapAxis.S), caps); if (!texRecord.isValid() || texRecord.wrapS != wrapS) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_WRAP_S, wrapS); texRecord.wrapS = wrapS; } }
/** * Check if the wrap mode of this particular texture has been changed and apply as needed. * * @param texture * our texture object * @param texRecord * our record of the last state of the unit in gl * @param record */ public static void applyWrap(final Texture1D texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final int wrapS = getGLWrap(texture.getWrap(WrapAxis.S), caps); if (!texRecord.isValid() || texRecord.wrapS != wrapS) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameteri(GL11C.GL_TEXTURE_1D, GL11C.GL_TEXTURE_WRAP_S, wrapS); texRecord.wrapS = wrapS; } }
public static void applyBorderColor(final Texture texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final GL gl = GLContext.getCurrentGL(); final ReadOnlyColorRGBA texBorder = texture.getBorderColor(); if (!texRecord.isValid() || !texRecord.borderColor.equals(texBorder)) { TextureRecord.colorBuffer.clear(); TextureRecord.colorBuffer.put(texBorder.getRed()).put(texBorder.getGreen()).put(texBorder.getBlue()) .put(texBorder.getAlpha()); TextureRecord.colorBuffer.rewind(); gl.glTexParameterfv(getGLType(texture.getType()), GL2GL3.GL_TEXTURE_BORDER_COLOR, TextureRecord.colorBuffer); texRecord.borderColor.set(texBorder); } }
/** * Check if the wrap mode of this particular texture has been changed and apply as needed. * * @param texture * our texture object * @param texRecord * our record of the last state of the unit in gl * @param record */ public static void applyWrap(final Texture2D texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final int wrapS = getGLWrap(texture.getWrap(WrapAxis.S), caps); final int wrapT = getGLWrap(texture.getWrap(WrapAxis.T), caps); if (!texRecord.isValid() || texRecord.wrapS != wrapS) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrapS); texRecord.wrapS = wrapS; } if (!texRecord.isValid() || texRecord.wrapT != wrapT) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrapT); texRecord.wrapT = wrapT; } }
/** * Check if the wrap mode of this particular texture has been changed and apply as needed. * * @param texture * our texture object * @param texRecord * our record of the last state of the unit in gl * @param record */ public static void applyWrap(final Texture2D texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final int wrapS = getGLWrap(texture.getWrap(WrapAxis.S), caps); final int wrapT = getGLWrap(texture.getWrap(WrapAxis.T), caps); if (!texRecord.isValid() || texRecord.wrapS != wrapS) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameteri(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_WRAP_S, wrapS); texRecord.wrapS = wrapS; } if (!texRecord.isValid() || texRecord.wrapT != wrapT) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameteri(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_WRAP_T, wrapT); texRecord.wrapT = wrapT; } }
/** * Check if the wrap mode of this particular texture has been changed and apply as needed. * * @param texture * our texture object * @param texRecord * our record of the last state of the unit in gl * @param record */ public static void applyWrap(final Texture3D texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final int wrapS = getGLWrap(texture.getWrap(WrapAxis.S), caps); final int wrapT = getGLWrap(texture.getWrap(WrapAxis.T), caps); final int wrapR = getGLWrap(texture.getWrap(WrapAxis.R), caps); if (!texRecord.isValid() || texRecord.wrapS != wrapS) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameteri(GL12C.GL_TEXTURE_3D, GL11C.GL_TEXTURE_WRAP_S, wrapS); texRecord.wrapS = wrapS; } if (!texRecord.isValid() || texRecord.wrapT != wrapT) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameteri(GL12C.GL_TEXTURE_3D, GL11C.GL_TEXTURE_WRAP_T, wrapT); texRecord.wrapT = wrapT; } if (!texRecord.isValid() || texRecord.wrapR != wrapR) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameteri(GL12C.GL_TEXTURE_3D, GL12C.GL_TEXTURE_WRAP_R, wrapR); texRecord.wrapR = wrapR; } }
/** * Check if the wrap mode of this particular texture has been changed and apply as needed. * * @param cubeMap * our texture object * @param texRecord * our record of the last state of the unit in gl * @param record */ public static void applyWrap(final TextureCubeMap cubeMap, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final int wrapS = getGLWrap(cubeMap.getWrap(WrapAxis.S), caps); final int wrapT = getGLWrap(cubeMap.getWrap(WrapAxis.T), caps); final int wrapR = getGLWrap(cubeMap.getWrap(WrapAxis.R), caps); if (!texRecord.isValid() || texRecord.wrapS != wrapS) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameteri(GL13C.GL_TEXTURE_CUBE_MAP, GL11C.GL_TEXTURE_WRAP_S, wrapS); texRecord.wrapS = wrapS; } if (!texRecord.isValid() || texRecord.wrapT != wrapT) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameteri(GL13C.GL_TEXTURE_CUBE_MAP, GL11C.GL_TEXTURE_WRAP_T, wrapT); texRecord.wrapT = wrapT; } if (!texRecord.isValid() || texRecord.wrapR != wrapR) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameteri(GL13C.GL_TEXTURE_CUBE_MAP, GL12C.GL_TEXTURE_WRAP_R, wrapR); texRecord.wrapR = wrapR; } }
/** * Check if the wrap mode of this particular texture has been changed and apply as needed. * * @param texture * our texture object * @param texRecord * our record of the last state of the unit in gl * @param record */ public static void applyWrap(final Texture1D texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final GL gl = GLContext.getCurrentGL(); final int wrapS = getGLWrap(texture.getWrap(WrapAxis.S), caps); if (!texRecord.isValid() || texRecord.wrapS != wrapS) { checkAndSetUnit(unit, record, caps); gl.glTexParameteri(GL2GL3.GL_TEXTURE_1D, GL.GL_TEXTURE_WRAP_S, wrapS); texRecord.wrapS = wrapS; } }
/** * Check if the wrap mode of this particular texture has been changed and apply as needed. * * @param texture * our texture object * @param texRecord * our record of the last state of the unit in gl * @param record */ public static void applyWrap(final Texture2D texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final GL gl = GLContext.getCurrentGL(); final int wrapS = getGLWrap(texture.getWrap(WrapAxis.S), caps); final int wrapT = getGLWrap(texture.getWrap(WrapAxis.T), caps); if (!texRecord.isValid() || texRecord.wrapS != wrapS) { checkAndSetUnit(unit, record, caps); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, wrapS); texRecord.wrapS = wrapS; } if (!texRecord.isValid() || texRecord.wrapT != wrapT) { checkAndSetUnit(unit, record, caps); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, wrapT); texRecord.wrapT = wrapT; } }
final int wrapR = getGLWrap(cubeMap.getWrap(WrapAxis.R), caps); if (!texRecord.isValid() || texRecord.wrapS != wrapS) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(ARBTextureCubeMap.GL_TEXTURE_CUBE_MAP_ARB, GL11.GL_TEXTURE_WRAP_S, wrapS); texRecord.wrapS = wrapS; if (!texRecord.isValid() || texRecord.wrapT != wrapT) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(ARBTextureCubeMap.GL_TEXTURE_CUBE_MAP_ARB, GL11.GL_TEXTURE_WRAP_T, wrapT); texRecord.wrapT = wrapT; if (!texRecord.isValid() || texRecord.wrapR != wrapR) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(ARBTextureCubeMap.GL_TEXTURE_CUBE_MAP_ARB, GL12.GL_TEXTURE_WRAP_R, wrapR);
final int wrapR = getGLWrap(texture.getWrap(WrapAxis.R), caps); if (!texRecord.isValid() || texRecord.wrapS != wrapS) { checkAndSetUnit(unit, record, caps); gl.glTexParameteri(GL2ES2.GL_TEXTURE_3D, GL.GL_TEXTURE_WRAP_S, wrapS); texRecord.wrapS = wrapS; if (!texRecord.isValid() || texRecord.wrapT != wrapT) { checkAndSetUnit(unit, record, caps); gl.glTexParameteri(GL2ES2.GL_TEXTURE_3D, GL.GL_TEXTURE_WRAP_T, wrapT); texRecord.wrapT = wrapT; if (!texRecord.isValid() || texRecord.wrapR != wrapR) { checkAndSetUnit(unit, record, caps); gl.glTexParameteri(GL2ES2.GL_TEXTURE_3D, GL2ES2.GL_TEXTURE_WRAP_R, wrapR);
final int wrapR = getGLWrap(texture.getWrap(WrapAxis.R), caps); if (!texRecord.isValid() || texRecord.wrapS != wrapS) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL11.GL_TEXTURE_WRAP_S, wrapS); texRecord.wrapS = wrapS; if (!texRecord.isValid() || texRecord.wrapT != wrapT) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL11.GL_TEXTURE_WRAP_T, wrapT); texRecord.wrapT = wrapT; if (!texRecord.isValid() || texRecord.wrapR != wrapR) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL12.GL_TEXTURE_WRAP_R, wrapR);
/** * Check if the filter settings of this particular texture have been changed and apply as needed. * * @param texture * our texture object * @param texRecord * our record of the last state of the texture in gl * @param record */ public static void applyShadow(final Texture texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final Type type = texture.getType(); final int depthCompareMode = Lwjgl3TextureUtils.getGLDepthTextureCompareMode(texture.getDepthCompareMode()); // set up magnification filter if (!texRecord.isValid() || texRecord.depthTextureCompareMode != depthCompareMode) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameteri(getGLType(type), ARBShadow.GL_TEXTURE_COMPARE_MODE_ARB, depthCompareMode); texRecord.depthTextureCompareMode = depthCompareMode; } final int depthCompareFunc = Lwjgl3TextureUtils.getGLDepthTextureCompareFunc(texture.getDepthCompareFunc()); // set up magnification filter if (!texRecord.isValid() || texRecord.depthTextureCompareFunc != depthCompareFunc) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameteri(getGLType(type), ARBShadow.GL_TEXTURE_COMPARE_FUNC_ARB, depthCompareFunc); texRecord.depthTextureCompareFunc = depthCompareFunc; } }
final int wrapR = getGLWrap(cubeMap.getWrap(WrapAxis.R), caps); if (!texRecord.isValid() || texRecord.wrapS != wrapS) { checkAndSetUnit(unit, record, caps); gl.glTexParameteri(GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_WRAP_S, wrapS); texRecord.wrapS = wrapS; if (!texRecord.isValid() || texRecord.wrapT != wrapT) { checkAndSetUnit(unit, record, caps); gl.glTexParameteri(GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_WRAP_T, wrapT); texRecord.wrapT = wrapT; if (!texRecord.isValid() || texRecord.wrapR != wrapR) { checkAndSetUnit(unit, record, caps); gl.glTexParameteri(GL.GL_TEXTURE_CUBE_MAP, GL2ES2.GL_TEXTURE_WRAP_R, wrapR);
if (!texRecord.isValid() || texRecord.magFilter != magFilter) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameteri(getGLType(type), GL11C.GL_TEXTURE_MAG_FILTER, magFilter); if (!texRecord.isValid() || texRecord.minFilter != minFilter) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameteri(getGLType(type), GL11C.GL_TEXTURE_MIN_FILTER, minFilter); float aniso = texture.getAnisotropicFilterPercent() * (caps.getMaxAnisotropic() - 1.0f); aniso += 1.0f; if (!texRecord.isValid() || (texRecord.anisoLevel - aniso > MathUtils.ZERO_TOLERANCE)) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameterf(getGLType(type), GL46C.GL_TEXTURE_MAX_ANISOTROPY, aniso);
if (!texRecord.isValid() || texRecord.magFilter != magFilter) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(getGLType(type), GL11.GL_TEXTURE_MAG_FILTER, magFilter); if (!texRecord.isValid() || texRecord.minFilter != minFilter) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(getGLType(type), GL11.GL_TEXTURE_MIN_FILTER, minFilter); float aniso = texture.getAnisotropicFilterPercent() * (caps.getMaxAnisotropic() - 1.0f); aniso += 1.0f; if (!texRecord.isValid() || (texRecord.anisoLevel - aniso > MathUtils.ZERO_TOLERANCE)) { checkAndSetUnit(unit, record, caps); GL11.glTexParameterf(getGLType(type), EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso);
if (!texRecord.isValid() || texRecord.magFilter != magFilter) { checkAndSetUnit(unit, record, caps); gl.glTexParameteri(getGLType(type), GL.GL_TEXTURE_MAG_FILTER, magFilter); if (!texRecord.isValid() || texRecord.minFilter != minFilter) { checkAndSetUnit(unit, record, caps); gl.glTexParameteri(getGLType(type), GL.GL_TEXTURE_MIN_FILTER, minFilter); float aniso = texture.getAnisotropicFilterPercent() * (caps.getMaxAnisotropic() - 1.0f); aniso += 1.0f; if (!texRecord.isValid() || texRecord.anisoLevel != aniso) { checkAndSetUnit(unit, record, caps); gl.glTexParameterf(getGLType(type), GL.GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso);
final int depthMode = LwjglTextureUtil.getGLDepthTextureMode(texture.getDepthMode()); if (!texRecord.isValid() || texRecord.depthTextureMode != depthMode) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(getGLType(type), ARBDepthTexture.GL_DEPTH_TEXTURE_MODE_ARB, depthMode); final int depthCompareMode = LwjglTextureUtil.getGLDepthTextureCompareMode(texture.getDepthCompareMode()); if (!texRecord.isValid() || texRecord.depthTextureCompareMode != depthCompareMode) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(getGLType(type), ARBShadow.GL_TEXTURE_COMPARE_MODE_ARB, depthCompareMode); if (!texRecord.isValid() || texRecord.depthTextureCompareFunc != depthCompareFunc) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(getGLType(type), ARBShadow.GL_TEXTURE_COMPARE_FUNC_ARB, depthCompareFunc);