forked from IrisShaders/Iris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
IMS212
committed
May 30, 2022
1 parent
0ad73f8
commit b9ff46e
Showing
4 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/main/java/net/coderbot/iris/vertices/IrisTextVertexSinkImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package net.coderbot.iris.vertices; | ||
|
||
import com.mojang.blaze3d.platform.MemoryTracker; | ||
import com.mojang.blaze3d.vertex.VertexFormat; | ||
import me.jellysquid.mods.sodium.client.gl.attribute.BufferVertexFormat; | ||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView; | ||
import net.coderbot.iris.compat.sodium.impl.vertex_format.entity_xhfp.GlyphVertexBufferWriterUnsafe; | ||
import net.irisshaders.iris.api.v0.IrisTextVertexSink; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.function.IntFunction; | ||
|
||
public class IrisTextVertexSinkImpl implements IrisTextVertexSink, VertexBufferView { | ||
static VertexFormat format = IrisVertexFormats.TERRAIN; | ||
private final ByteBuffer buffer; | ||
private int vertexCount; | ||
private int elementOffset; | ||
private GlyphVertexBufferWriterUnsafe drain; | ||
|
||
public IrisTextVertexSinkImpl(int maxQuadSize, IntFunction<ByteBuffer> buffer) { | ||
this.buffer = buffer.apply(format.getVertexSize() * 4 * maxQuadSize); | ||
this.drain = new GlyphVertexBufferWriterUnsafe(this); | ||
} | ||
|
||
@Override | ||
public VertexFormat getUnderlyingVertexFormat() { | ||
return format; | ||
} | ||
|
||
@Override | ||
public void quad(float minX, float minY, float maxX, float maxY, float z, int color, float minU, float minV, float maxU, float maxV, int light) { | ||
drain.writeGlyph(minX, minY, 0.0F, color, minU, minV, light); | ||
drain.writeGlyph(minX, maxY, 0.0F, color, minU, maxV, light); | ||
drain.writeGlyph(maxX, maxY, 0.0F, color, maxU, maxV, light); | ||
drain.writeGlyph(maxX, minY, 0.0F, color, maxU, minV, light); | ||
} | ||
|
||
@Override | ||
public void flush() { | ||
drain.flush(); | ||
} | ||
|
||
@Override | ||
public boolean ensureBufferCapacity(int i) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public ByteBuffer getDirectBuffer() { | ||
return buffer; | ||
} | ||
|
||
@Override | ||
public int getWriterPosition() { | ||
return this.elementOffset; | ||
} | ||
|
||
@Override | ||
public void flush(int i, BufferVertexFormat bufferVertexFormat) { | ||
this.vertexCount += vertexCount; | ||
this.elementOffset += vertexCount * format.getVertexSize(); | ||
} | ||
|
||
@Override | ||
public BufferVertexFormat getVertexFormat() { | ||
return BufferVertexFormat.from(format); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/net/irisshaders/iris/api/v0/IrisTextVertexSink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package net.irisshaders.iris.api.v0; | ||
|
||
import com.mojang.blaze3d.vertex.VertexFormat; | ||
|
||
public interface IrisTextVertexSink { | ||
VertexFormat getUnderlyingVertexFormat(); | ||
void quad(float x1, float y1, float x2, float y2, float z, int rgba, float u1, float v1, float u2, float v2, int light); | ||
void flush(); | ||
} |