Skip to content

Commit 5b129e2

Browse files
feat: extend DirectDraw to support more types
1 parent 02dce80 commit 5b129e2

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

src/main/java/cam72cam/mod/render/opengl/DirectDraw.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,19 @@
99

1010
public class DirectDraw {
1111
private final List<VertexBuilder> verts = new ArrayList<>();
12+
private Mode mode;
13+
14+
public DirectDraw() {
15+
this(Mode.QUADS);
16+
}
17+
18+
public DirectDraw(Mode mode) {
19+
this.mode = mode;
20+
}
1221

1322
public void draw(RenderState state) {
1423
try (With ctx = RenderContext.apply(state)) {
15-
GL11.glBegin(GL11.GL_QUADS);
24+
GL11.glBegin(mode.asGlMode());
1625
for (VertexBuilder vert : verts) {
1726
vert.draw();
1827
}
@@ -84,4 +93,24 @@ private void draw() {
8493
GL11.glVertex3d(x, y, z);
8594
}
8695
}
96+
97+
public enum Mode {
98+
LINES(GL11.GL_LINES),
99+
LINE_STRIP(GL11.GL_LINE_STRIP),
100+
TRIANGLES(GL11.GL_TRIANGLES),
101+
TRIANGLE_STRIP(GL11.GL_TRIANGLE_STRIP),
102+
TRIANGLE_FAN(GL11.GL_TRIANGLE_FAN),
103+
QUADS(GL11.GL_QUADS),
104+
;
105+
106+
private final int glMode;
107+
108+
Mode(int glMode) {
109+
this.glMode = glMode;
110+
}
111+
112+
int asGlMode() {
113+
return glMode;
114+
}
115+
}
87116
}

0 commit comments

Comments
 (0)