47 lines
1.0 KiB
Java
47 lines
1.0 KiB
Java
package speiger.src.coreengine.rendering.shader.uniforms;
|
|
|
|
import org.lwjgl.opengl.GL20;
|
|
|
|
import speiger.src.coreengine.math.misc.ColorUtils;
|
|
import speiger.src.coreengine.math.vector.floats.Vec3f;
|
|
import speiger.src.coreengine.rendering.utils.AllocationTracker;
|
|
|
|
public class UniformVec3f extends UniformBase<Vec3f>
|
|
{
|
|
static final Vec3f STORAGE = Vec3f.newMutable();
|
|
|
|
public UniformVec3f(String id)
|
|
{
|
|
super(id);
|
|
}
|
|
|
|
public void storeData(Vec3f data)
|
|
{
|
|
if(hasChanged(data))
|
|
{
|
|
GL20.glUniform3f(getPosition(), data.getX(), data.getY(), data.getZ());
|
|
AllocationTracker.INSTANCE.addGPUBytes(12L);
|
|
}
|
|
}
|
|
|
|
public void storeData(int color)
|
|
{
|
|
storeData(STORAGE.set(ColorUtils.getRF(color), ColorUtils.getGF(color), ColorUtils.getBF(color)));
|
|
}
|
|
|
|
public void storeData(float x, float y, float z)
|
|
{
|
|
storeData(STORAGE.set(x, y, z));
|
|
}
|
|
|
|
@Override
|
|
protected Vec3f setValue(Vec3f oldValue, Vec3f newValue)
|
|
{
|
|
if(oldValue != null)
|
|
{
|
|
return oldValue.set(newValue);
|
|
}
|
|
return Vec3f.newMutable(newValue);
|
|
}
|
|
}
|