/** * Checks to see if the given ColorRGBA is equals to the data stored in the buffer at the given data index. * * @param check * the color to check against - null will return false. * @param buf * the buffer to compare data with * @param index * the position (in terms of colors, not floats) of the color in the buffer to check against * @return */ public static boolean equals(final ReadOnlyColorRGBA check, final FloatBuffer buf, final int index) { final ColorRGBA temp = new ColorRGBA(); populateFromBuffer(temp, buf, index); return temp.equals(check); }
/** * Checks to see if the given ColorRGBA is equals to the data stored in the buffer at the given data index. * * @param check * the color to check against - null will return false. * @param buf * the buffer to compare data with * @param index * the position (in terms of colors, not floats) of the color in the buffer to check against * @return */ public static boolean equals(final ReadOnlyColorRGBA check, final FloatBuffer buf, final int index) { final ColorRGBA temp = new ColorRGBA(); populateFromBuffer(temp, buf, index); return temp.equals(check); }
private static void setAmbient(final int index, final LightStateRecord record, final ReadOnlyColorRGBA ambient, final LightRecord lr) { if (!record.isValid() || !lr.ambient.equals(ambient)) { record.lightBuffer.clear(); record.lightBuffer.put(ambient.getRed()); record.lightBuffer.put(ambient.getGreen()); record.lightBuffer.put(ambient.getBlue()); record.lightBuffer.put(ambient.getAlpha()); record.lightBuffer.flip(); GL11.glLight(GL11.GL_LIGHT0 + index, GL11.GL_AMBIENT, record.lightBuffer); lr.ambient.set(ambient); } }
private static void setModelAmbient(final LightStateRecord record, final ReadOnlyColorRGBA color) { if (!record.isValid() || !record.globalAmbient.equals(color)) { record.lightBuffer.clear(); record.lightBuffer.put(color.getRed()); record.lightBuffer.put(color.getGreen()); record.lightBuffer.put(color.getBlue()); record.lightBuffer.put(color.getAlpha()); record.lightBuffer.flip(); GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, record.lightBuffer); record.globalAmbient.set(color); } }
private static void setSpecular(final int index, final LightStateRecord record, final ReadOnlyColorRGBA specular, final LightRecord lr) { if (!record.isValid() || !lr.specular.equals(specular)) { record.lightBuffer.clear(); record.lightBuffer.put(specular.getRed()); record.lightBuffer.put(specular.getGreen()); record.lightBuffer.put(specular.getBlue()); record.lightBuffer.put(specular.getAlpha()); record.lightBuffer.flip(); GL11.glLight(GL11.GL_LIGHT0 + index, GL11.GL_SPECULAR, record.lightBuffer); lr.specular.set(specular); } }
private static void setDiffuse(final int index, final LightStateRecord record, final ReadOnlyColorRGBA diffuse, final LightRecord lr) { if (!record.isValid() || !lr.diffuse.equals(diffuse)) { record.lightBuffer.clear(); record.lightBuffer.put(diffuse.getRed()); record.lightBuffer.put(diffuse.getGreen()); record.lightBuffer.put(diffuse.getBlue()); record.lightBuffer.put(diffuse.getAlpha()); record.lightBuffer.flip(); GL11.glLight(GL11.GL_LIGHT0 + index, GL11.GL_DIFFUSE, record.lightBuffer); lr.diffuse.set(diffuse); } }
private static void setModelAmbient(final LightStateRecord record, final ReadOnlyColorRGBA globalAmbient) { final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || !record.globalAmbient.equals(globalAmbient)) { record.lightBuffer.clear(); record.lightBuffer.put(globalAmbient.getRed()); record.lightBuffer.put(globalAmbient.getGreen()); record.lightBuffer.put(globalAmbient.getBlue()); record.lightBuffer.put(globalAmbient.getAlpha()); record.lightBuffer.flip(); gl.getGL2().glLightModelfv(GL2ES1.GL_LIGHT_MODEL_AMBIENT, record.lightBuffer); // TODO Check for float record.globalAmbient.set(globalAmbient); } }
public static void applyBlendColor(final Texture texture, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final ReadOnlyColorRGBA texBlend = texture.getConstantColor(); if (!unitRecord.isValid() || !unitRecord.blendColor.equals(texBlend)) { checkAndSetUnit(unit, record, caps); TextureRecord.colorBuffer.clear(); TextureRecord.colorBuffer.put(texBlend.getRed()).put(texBlend.getGreen()).put(texBlend.getBlue()) .put(texBlend.getAlpha()); TextureRecord.colorBuffer.rewind(); GL11.glTexEnv(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_COLOR, TextureRecord.colorBuffer); unitRecord.blendColor.set(texBlend); } }
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); } }
private static void setSpecular(final int index, final LightStateRecord record, final ReadOnlyColorRGBA specular, final LightRecord lr) { final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || !lr.specular.equals(specular)) { record.lightBuffer.clear(); record.lightBuffer.put(specular.getRed()); record.lightBuffer.put(specular.getGreen()); record.lightBuffer.put(specular.getBlue()); record.lightBuffer.put(specular.getAlpha()); record.lightBuffer.flip(); gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPECULAR, record.lightBuffer); // TODO // Check // for // float lr.specular.set(specular); } }
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); } }
private static void setAmbient(final int index, final LightStateRecord record, final ReadOnlyColorRGBA ambient, final LightRecord lr) { final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || !lr.ambient.equals(ambient)) { record.lightBuffer.clear(); record.lightBuffer.put(ambient.getRed()); record.lightBuffer.put(ambient.getGreen()); record.lightBuffer.put(ambient.getBlue()); record.lightBuffer.put(ambient.getAlpha()); record.lightBuffer.flip(); gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_AMBIENT, record.lightBuffer); // TODO // Check // for // float lr.ambient.set(ambient); } }
private static void setDiffuse(final int index, final LightStateRecord record, final ReadOnlyColorRGBA diffuse, final LightRecord lr) { final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || !lr.diffuse.equals(diffuse)) { record.lightBuffer.clear(); record.lightBuffer.put(diffuse.getRed()); record.lightBuffer.put(diffuse.getGreen()); record.lightBuffer.put(diffuse.getBlue()); record.lightBuffer.put(diffuse.getAlpha()); record.lightBuffer.flip(); gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_DIFFUSE, record.lightBuffer); // TODO // Check // for // float lr.diffuse.set(diffuse); } }
public static void applyBlendColor(final Texture texture, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final GL gl = GLContext.getCurrentGL(); final ReadOnlyColorRGBA texBlend = texture.getConstantColor(); if (!unitRecord.isValid() || !unitRecord.blendColor.equals(texBlend)) { checkAndSetUnit(unit, record, caps); TextureRecord.colorBuffer.clear(); TextureRecord.colorBuffer.put(texBlend.getRed()).put(texBlend.getGreen()).put(texBlend.getBlue()) .put(texBlend.getAlpha()); TextureRecord.colorBuffer.rewind(); gl.getGL2ES1().glTexEnvfv(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_COLOR, TextureRecord.colorBuffer); unitRecord.blendColor.set(texBlend); } }
@Override public boolean equals(final Object other) { if (other == this) { return true; } if (!(other instanceof Texture)) { return false; } final Texture that = (Texture) other; if (getImage() != null && !getImage().equals(that.getImage())) { return false; } if (getImage() == null && that.getImage() != null) { return false; } if (getAnisotropicFilterPercent() != that.getAnisotropicFilterPercent()) { return false; } if (getMagnificationFilter() != that.getMagnificationFilter()) { return false; } if (getMinificationFilter() != that.getMinificationFilter()) { return false; } if (!_borderColor.equals(that._borderColor)) { return false; } return true; }
protected static void applyBlendColor(final boolean enabled, final BlendState state, final BlendStateRecord record, final ContextCapabilities caps) { if (enabled) { final boolean applyConstant = state.getDestinationFunctionRGB().usesConstantColor() || state.getSourceFunctionRGB().usesConstantColor() || ((state.getDestinationFunctionAlpha().usesConstantColor() || state.getSourceFunctionAlpha() .usesConstantColor())); if (applyConstant) { final ReadOnlyColorRGBA constant = state.getConstantColor(); if (!record.isValid() || (!record.blendColor.equals(constant))) { GL14C.glBlendColor(constant.getRed(), constant.getGreen(), constant.getBlue(), constant.getAlpha()); record.blendColor.set(constant); } } } }
protected static void applyBlendColor(final boolean enabled, final BlendState state, final BlendStateRecord record, final ContextCapabilities caps) { if (enabled) { final boolean applyConstant = state.getDestinationFunctionRGB().usesConstantColor() || state.getSourceFunctionRGB().usesConstantColor() || (caps.isConstantBlendColorSupported() && (state.getDestinationFunctionAlpha() .usesConstantColor() || state.getSourceFunctionAlpha().usesConstantColor())); if (applyConstant && caps.isConstantBlendColorSupported()) { final ReadOnlyColorRGBA constant = state.getConstantColor(); if (!record.isValid() || (caps.isConstantBlendColorSupported() && !record.blendColor.equals(constant))) { ARBImaging.glBlendColor(constant.getRed(), constant.getGreen(), constant.getBlue(), constant.getAlpha()); record.blendColor.set(constant); } } } }
private static void applyBlendColor(final GL gl, final boolean enabled, final BlendState state, final BlendStateRecord record, final ContextCapabilities caps) { if (enabled) { final boolean applyConstant = state.getDestinationFunctionRGB().usesConstantColor() || state.getSourceFunctionRGB().usesConstantColor() || (caps.isConstantBlendColorSupported() && (state.getDestinationFunctionAlpha() .usesConstantColor() || state.getSourceFunctionAlpha().usesConstantColor())); if (applyConstant && caps.isConstantBlendColorSupported()) { final ReadOnlyColorRGBA constant = state.getConstantColor(); if (!record.isValid() || (caps.isConstantBlendColorSupported() && !record.blendColor.equals(constant))) { if (gl.isGL2ES2()) { gl.getGL2ES2().glBlendColor(constant.getRed(), constant.getGreen(), constant.getBlue(), constant.getAlpha()); } record.blendColor.set(constant); } } } }
assertFalse(clr1.equals(null)); assertFalse(clr1.equals(new Vector2())); assertFalse(clr1.equals(new ColorRGBA(4, 4, 4, 4))); assertFalse(clr1.equals(new ColorRGBA(0, 4, 4, 4))); assertFalse(clr1.equals(new ColorRGBA(0, 1, 4, 4))); assertFalse(clr1.equals(new ColorRGBA(0, 1, 2, 4))); assertTrue(clr1.equals(new ColorRGBA(0, 1, 2, 3)));