Stop assuming that our render pipeline will only process RGB frames
For one, we have already switched to RGBA some time ago, so the name was technically incorrect already. But the main reason is that we'll want to use them for depth maps as well (and potentially maybe even for HDR images if that's possible with canvas?).
This commit is contained in:
40
src/main/java/com/replaymod/render/frame/BitmapFrame.java
Normal file
40
src/main/java/com/replaymod/render/frame/BitmapFrame.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.replaymod.render.frame;
|
||||
|
||||
import com.replaymod.render.rendering.Frame;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class BitmapFrame implements Frame {
|
||||
private final int frameId;
|
||||
private final ReadableDimension size;
|
||||
private final int bytesPerPixel;
|
||||
private final ByteBuffer byteBuffer;
|
||||
|
||||
public BitmapFrame(int frameId, ReadableDimension size, int bytesPerPixel, ByteBuffer byteBuffer) {
|
||||
Validate.isTrue(size.getWidth() * size.getHeight() * bytesPerPixel == byteBuffer.remaining(),
|
||||
"Buffer size is %d (cap: %d) but should be %d",
|
||||
byteBuffer.remaining(), byteBuffer.capacity(), size.getWidth() * size.getHeight() * bytesPerPixel);
|
||||
this.frameId = frameId;
|
||||
this.size = size;
|
||||
this.bytesPerPixel = bytesPerPixel;
|
||||
this.byteBuffer = byteBuffer;
|
||||
}
|
||||
|
||||
public int getFrameId() {
|
||||
return this.frameId;
|
||||
}
|
||||
|
||||
public ReadableDimension getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public int getBytesPerPixel() {
|
||||
return bytesPerPixel;
|
||||
}
|
||||
|
||||
public ByteBuffer getByteBuffer() {
|
||||
return this.byteBuffer;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user