public void copyToTexture(final Texture tex, final int x, final int y, final int width, final int height, final int xoffset, final int yoffset) { LwjglTextureStateUtil.doTextureBind(tex, 0, true); if (tex.getType() == Type.TwoDimensional) { GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, xoffset, yoffset, x, y, width, height); } else if (tex.getType() == Type.CubeMap) { GL11.glCopyTexSubImage2D( LwjglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), 0, xoffset, yoffset, x, y, width, height); } else { throw new IllegalArgumentException("Invalid texture type: " + tex.getType()); } }
public void copyToTexture(final Texture tex, final int x, final int y, final int width, final int height, final int xoffset, final int yoffset) { Lwjgl3TextureStateUtil.doTextureBind(tex, 0, true); if (tex.getType() == Type.TwoDimensional) { GL11C.glCopyTexSubImage2D(GL11C.GL_TEXTURE_2D, 0, xoffset, yoffset, x, y, width, height); } else if (tex.getType() == Type.CubeMap) { GL11C.glCopyTexSubImage2D( Lwjgl3TextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), 0, xoffset, yoffset, x, y, width, height); } else { throw new IllegalArgumentException("Invalid texture type: " + tex.getType()); } }
public void copyToTexture(final Texture tex, final int x, final int y, final int width, final int height, final int xoffset, final int yoffset) { final GL gl = GLContext.getCurrentGL(); JoglTextureStateUtil.doTextureBind(tex, 0, true); if (tex.getType() == Type.TwoDimensional) { gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0, xoffset, yoffset, x, y, width, height); } else if (tex.getType() == Type.CubeMap) { gl.glCopyTexSubImage2D(JoglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), 0, xoffset, yoffset, x, y, width, height); } else { throw new IllegalArgumentException("Invalid texture type: " + tex.getType()); } }
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); } }
@Override protected void takedownForSingleTexDraw(final Texture tex) { // automatically generate mipmaps for our texture. if (tex.getMinificationFilter().usesMipMapLevels()) { LwjglTextureStateUtil.doTextureBind(tex, 0, true); EXTFramebufferObject.glGenerateMipmapEXT(LwjglTextureStateUtil.getGLType(tex.getType())); } }
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); } }
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); } }
if (tex.getType() == Type.TwoDimensional) { gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_TEXTURE_2D, textureId, 0); } else if (tex.getType() == Type.CubeMap) { gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, JoglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), textureId, 0); } else { throw new IllegalArgumentException("Can not render to texture of type: " + tex.getType()); } else { if (tex.getType() == Type.TwoDimensional) { gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_TEXTURE_2D, textureId, 0); } else if (tex.getType() == Type.CubeMap) { gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, JoglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), textureId, 0); } else { throw new IllegalArgumentException("Can not render to texture of type: " + tex.getType());
@Override protected void takedownForSingleTexDraw(final Texture tex) { final GL gl = GLContext.getCurrentGL(); // automatically generate mipmaps for our texture. if (tex.getMinificationFilter().usesMipMapLevels()) { JoglTextureStateUtil.doTextureBind(tex, 0, true); gl.glGenerateMipmap(JoglTextureStateUtil.getGLType(tex.getType())); } }
public static void applyLodBias(final Texture texture, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final float bias = texture.getLodBias() < caps.getMaxLodBias() ? texture.getLodBias() : caps.getMaxLodBias(); if (!unitRecord.isValid() || unitRecord.lodBias != bias) { checkAndSetUnit(unit, record, caps); GL11C.glTexParameterf(getGLType(texture.getType()), GL14C.GL_TEXTURE_LOD_BIAS, bias); unitRecord.lodBias = bias; } }
@Override protected void takedownForSingleTexDraw(final Texture tex) { if (isEnableMipGeneration()) { // automatically generate mipmaps for our texture, if supported. if (tex.getMinificationFilter().usesMipMapLevels()) { Lwjgl3TextureStateUtil.doTextureBind(tex, 0, true); GL30C.glGenerateMipmap(Lwjgl3TextureStateUtil.getGLType(tex.getType())); } } tex.getTextureKey().markClean(ContextManager.getCurrentContext()); }
if (tex.getType() != Type.TwoDimensional) { throw new IllegalArgumentException("Unsupported type: " + tex.getType()); final TextureRecord texRecord = record.getTextureRecord(textureId, tex.getType()); LwjglTextureStateUtil.applyFilter(tex, texRecord, 0, record, context.getCapabilities()); LwjglTextureStateUtil.applyWrap(tex, texRecord, 0, record, context.getCapabilities());
if (tex.getType() != Type.TwoDimensional) { throw new IllegalArgumentException("Unsupported type: " + tex.getType()); final TextureRecord texRecord = record.getTextureRecord(textureId, tex.getType()); JoglTextureStateUtil.applyFilter(tex, texRecord, 0, record, context.getCapabilities()); JoglTextureStateUtil.applyWrap(tex, texRecord, 0, record, context.getCapabilities());
/** * Useful for external lwjgl based classes that need to safely set the current texture. */ public static void doTextureBind(final Texture texture, final int unit, final boolean invalidateState) { // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); final TextureStateRecord record = (TextureStateRecord) context.getStateRecord(StateType.Texture); if (invalidateState) { // Set this to null because no current state really matches anymore context.setCurrentState(StateType.Texture, null); } checkAndSetUnit(unit, record, caps); final int id = texture.getTextureIdForContext(context); GL11C.glBindTexture(getGLType(texture.getType()), id); if (Constants.stats) { StatCollector.addStat(StatType.STAT_TEXTURE_BINDS, 1); } if (record != null) { record.units[unit].boundTexture = id; } }
/** * Useful for external lwjgl based classes that need to safely set the current texture. */ public static void doTextureBind(final Texture texture, final int unit, final boolean invalidateState) { // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); final TextureStateRecord record = (TextureStateRecord) context.getStateRecord(StateType.Texture); if (invalidateState) { // Set this to null because no current state really matches anymore context.setCurrentState(StateType.Texture, null); } checkAndSetUnit(unit, record, caps); final int id = texture.getTextureIdForContext(context.getGlContextRep()); GL11.glBindTexture(getGLType(texture.getType()), id); if (Constants.stats) { StatCollector.addStat(StatType.STAT_TEXTURE_BINDS, 1); } if (record != null) { record.units[unit].boundTexture = id; } }
/** * Useful for external jogl based classes that need to safely set the current texture. */ public static void doTextureBind(final Texture texture, final int unit, final boolean invalidateState) { final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); final TextureStateRecord record = (TextureStateRecord) context.getStateRecord(StateType.Texture); if (invalidateState) { // Set this to null because no current state really matches anymore context.setCurrentState(StateType.Texture, null); } checkAndSetUnit(unit, record, caps); final int id = texture.getTextureIdForContext(context.getGlContextRep()); gl.glBindTexture(getGLType(texture.getType()), id); if (Constants.stats) { StatCollector.addStat(StatType.STAT_TEXTURE_BINDS, 1); } if (record != null) { record.units[unit].boundTexture = id; } }
/** * 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 GL gl = GLContext.getCurrentGL(); final Type type = texture.getType();
final Type type = texture.getType();
final GL gl = GLContext.getCurrentGL(); final Type type = texture.getType();