mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-22 05:12:16 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61f6aa19a8 |
No files matched your search
@@ -241,6 +241,9 @@ public class DisplayListManager {
|
||||
public static void recordStencilMask(int mask) { if (currentRecorder != null) currentRecorder.recordStencilMask(mask); }
|
||||
public static void recordStencilMaskSeparate(int face, int mask) { if (currentRecorder != null) currentRecorder.recordStencilMaskSeparate(face, mask); }
|
||||
public static void recordCallList(int listId) { if (currentRecorder != null) currentRecorder.recordCallList(listId); }
|
||||
public static void recordDrawBuffer(int mode) { if (currentRecorder != null) currentRecorder.recordDrawBuffer(mode); }
|
||||
public static void recordDrawBuffers(int count, int buf) { if (currentRecorder != null) currentRecorder.recordDrawBuffers(count, buf); }
|
||||
public static void recordDrawBuffers(int count, java.nio.IntBuffer bufs) { if (currentRecorder != null) currentRecorder.recordDrawBuffers(count, bufs); }
|
||||
public static void recordComplexCommand(DisplayListCommand cmd) { if (currentRecorder != null) currentRecorder.recordComplexCommand(cmd); }
|
||||
|
||||
/**
|
||||
|
||||
@@ -1745,7 +1745,7 @@ public class GLStateManager {
|
||||
|
||||
public static void glDrawBuffer(int mode) {
|
||||
if (DisplayListManager.isRecording()) {
|
||||
throw new UnsupportedOperationException("glDrawBuffer in display lists not yet implemented");
|
||||
DisplayListManager.recordDrawBuffer(mode);
|
||||
}
|
||||
trySyncProgram();
|
||||
GL11.glDrawBuffer(mode);
|
||||
@@ -3409,9 +3409,16 @@ public class GLStateManager {
|
||||
}
|
||||
|
||||
// Draw Buffer Commands (GL 2.0+)
|
||||
public static void glDrawBuffers(int buffer) {
|
||||
if (DisplayListManager.isRecording()) {
|
||||
DisplayListManager.recordDrawBuffers(1, buffer);
|
||||
}
|
||||
GL20.glDrawBuffers(buffer);
|
||||
}
|
||||
|
||||
public static void glDrawBuffers(IntBuffer bufs) {
|
||||
if (DisplayListManager.isRecording()) {
|
||||
throw new UnsupportedOperationException("glDrawBuffers in display lists not yet implemented - if you see this, please report!");
|
||||
DisplayListManager.recordDrawBuffers(bufs.remaining(), bufs);
|
||||
}
|
||||
GL20.glDrawBuffers(bufs);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.joml.Matrix4f;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -564,6 +565,39 @@ public final class CommandBuffer {
|
||||
writeInt(listId);
|
||||
}
|
||||
|
||||
public void writeDrawBuffer(int mode) {
|
||||
ensureCapacity(8);
|
||||
writeInt(GLCommand.DRAW_BUFFER);
|
||||
writeInt(mode);
|
||||
}
|
||||
|
||||
private static final int MAX_DRAW_BUFFERS = 8;
|
||||
// cmd (4) + count (4) + buffers (4 * MAX_DRAW_BUFFERS)
|
||||
private static final int DRAW_BUFFERS_SIZE = 4 + 4 + 4 * MAX_DRAW_BUFFERS;
|
||||
|
||||
public void writeDrawBuffers(int count, int buffer) {
|
||||
ensureCapacity(DRAW_BUFFERS_SIZE);
|
||||
writeInt(GLCommand.DRAW_BUFFERS);
|
||||
writeInt(count);
|
||||
writeInt(buffer);
|
||||
for (int i = 1; i < MAX_DRAW_BUFFERS; i++) {
|
||||
writeInt(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeDrawBuffers(int count, IntBuffer bufs) {
|
||||
ensureCapacity(DRAW_BUFFERS_SIZE);
|
||||
writeInt(GLCommand.DRAW_BUFFERS);
|
||||
writeInt(count);
|
||||
final int pos = bufs.position();
|
||||
for (int i = 0; i < count && i < MAX_DRAW_BUFFERS; i++) {
|
||||
writeInt(bufs.get(pos + i));
|
||||
}
|
||||
for (int i = count; i < MAX_DRAW_BUFFERS; i++) {
|
||||
writeInt(0);
|
||||
}
|
||||
}
|
||||
|
||||
// === Complex object reference ===
|
||||
|
||||
public void writeComplexRef(DisplayListCommand cmd) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.lwjgl.BufferUtils;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
@@ -21,6 +22,9 @@ public final class CommandBufferExecutor {
|
||||
private static final FloatBuffer MATRIX_BUFFER = BufferUtils.createFloatBuffer(16);
|
||||
// Static reusable buffer for fog/light/material params
|
||||
private static final FloatBuffer PARAMS_BUFFER = BufferUtils.createFloatBuffer(4);
|
||||
// Static reusable buffer for draw buffers
|
||||
private static final int MAX_DRAW_BUFFERS = 8;
|
||||
private static final IntBuffer DRAW_BUFFERS_BUFFER = BufferUtils.createIntBuffer(MAX_DRAW_BUFFERS);
|
||||
|
||||
/**
|
||||
* Execute all commands in the buffer.
|
||||
@@ -495,6 +499,21 @@ public final class CommandBufferExecutor {
|
||||
ptr += 4;
|
||||
DisplayListManager.glCallList(listId);
|
||||
}
|
||||
case GLCommand.DRAW_BUFFER -> {
|
||||
GLStateManager.glDrawBuffer(memGetInt(ptr));
|
||||
ptr += 4;
|
||||
}
|
||||
case GLCommand.DRAW_BUFFERS -> {
|
||||
final int count = memGetInt(ptr);
|
||||
ptr += 4;
|
||||
DRAW_BUFFERS_BUFFER.clear();
|
||||
for (int i = 0; i < count; i++) {
|
||||
DRAW_BUFFERS_BUFFER.put(memGetInt(ptr + i * 4));
|
||||
}
|
||||
DRAW_BUFFERS_BUFFER.flip();
|
||||
ptr += 4 * MAX_DRAW_BUFFERS;
|
||||
GLStateManager.glDrawBuffers(DRAW_BUFFERS_BUFFER);
|
||||
}
|
||||
|
||||
// === Complex object reference ===
|
||||
case GLCommand.COMPLEX_REF -> {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.gtnewhorizons.angelica.glsm.recording.commands.DisplayListCommand;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
/**
|
||||
* Records GL commands to a CommandBuffer during display list compilation.
|
||||
@@ -336,6 +337,21 @@ public class CommandRecorder {
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordDrawBuffer(int mode) {
|
||||
buffer.writeDrawBuffer(mode);
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordDrawBuffers(int count, int buf) {
|
||||
buffer.writeDrawBuffers(count, buf);
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordDrawBuffers(int count, IntBuffer bufs) {
|
||||
buffer.writeDrawBuffers(count, bufs);
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordComplexCommand(DisplayListCommand cmd) {
|
||||
buffer.writeComplexRef(cmd);
|
||||
commandCount++;
|
||||
|
||||
@@ -90,6 +90,8 @@ public final class GLCommand {
|
||||
// === Draw commands ===
|
||||
public static final int DRAW_RANGE = 100; // [cmd:4][vboIndex:4][start:4][count:4][hasBrightness:4] = 20 bytes
|
||||
public static final int CALL_LIST = 101; // [cmd:4][listId:4] = 8 bytes
|
||||
public static final int DRAW_BUFFER = 102; // [cmd:4][mode:4] = 8 bytes
|
||||
public static final int DRAW_BUFFERS = 103; // [cmd:4][count:4][bufs:4*8] = 40 bytes (up to 8 buffers)
|
||||
|
||||
// === Complex object reference ===
|
||||
public static final int COMPLEX_REF = 255; // [cmd:4][index:4] = 8 bytes
|
||||
@@ -161,6 +163,8 @@ public final class GLCommand {
|
||||
case MATERIAL -> "MATERIAL";
|
||||
case DRAW_RANGE -> "DRAW_RANGE";
|
||||
case CALL_LIST -> "CALL_LIST";
|
||||
case DRAW_BUFFER -> "DRAW_BUFFER";
|
||||
case DRAW_BUFFERS -> "DRAW_BUFFERS";
|
||||
case COMPLEX_REF -> "COMPLEX_REF";
|
||||
default -> "UNKNOWN(" + opcode + ")";
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user