windowEventQueue = new ConcurrentHashMap<>();
public void windowTitle(String title) {
@@ -9683,7 +9729,8 @@ public void windowResize(int newWidth, int newHeight) {
* only the notification that the resize has happened.
*/
public void postWindowResized(int newWidth, int newHeight) {
- windowEventQueue.put("wh", new WindowEventValuePairs(newWidth, newHeight));
+ windowEventQueue.put("w", newWidth);
+ windowEventQueue.put("h", newHeight);
}
@@ -9723,7 +9770,8 @@ public void postWindowMoved(int newX, int newY) {
frameMoved(newX, newY);
}
- windowEventQueue.put("xy", new WindowEventValuePairs(newX, newY));
+ windowEventQueue.put("x", newX);
+ windowEventQueue.put("y", newY);
}
@@ -9732,28 +9780,21 @@ public void windowMoved() { }
private void dequeueWindowEvents() {
- if (windowEventQueue.containsKey("xy")) {
- WindowEventValuePairs xy = windowEventQueue.remove("xy");
- windowX = xy.num1;
- windowY = xy.num2;
+ if (windowEventQueue.containsKey("x")) {
+ windowX = windowEventQueue.remove("x");
+ windowY = windowEventQueue.remove("y");
windowMoved();
}
- if (windowEventQueue.containsKey("wh")) {
- WindowEventValuePairs wh = windowEventQueue.remove("wh");
+ if (windowEventQueue.containsKey("w")) {
+ // these should already match width/height
+ //windowResized(windowEventQueue.remove("w"),
+ // windowEventQueue.remove("h"));
+ windowEventQueue.remove("w");
+ windowEventQueue.remove("h");
windowResized();
}
}
- protected class WindowEventValuePairs {
-
- public int num1;
- public int num2;
-
- public WindowEventValuePairs(int num1, int num2) {
- this.num1 = num1;
- this.num2 = num2;
- }
- }
/**
* Scale the sketch as if it fits this specific width and height.
diff --git a/core/src/processing/core/PConstants.java b/core/src/processing/core/PConstants.java
index af17c1fbfb..2c1949dc5b 100644
--- a/core/src/processing/core/PConstants.java
+++ b/core/src/processing/core/PConstants.java
@@ -62,6 +62,11 @@ public interface PConstants {
String P2D = "processing.opengl.PGraphics2D";
String P3D = "processing.opengl.PGraphics3D";
+ String PV2D = "processing.vulkan.PVKGraphics2D";
+ String PV3D = "processing.vulkan.PVKGraphics3D";
+
+ int AUTO = -101;
+
// When will it be time to remove this?
@Deprecated
String OPENGL = P3D;
diff --git a/core/src/processing/opengl/FrameBuffer.java b/core/src/processing/opengl/FrameBuffer.java
index a5426c52d1..fa04636c0b 100644
--- a/core/src/processing/opengl/FrameBuffer.java
+++ b/core/src/processing/opengl/FrameBuffer.java
@@ -71,14 +71,14 @@ public class FrameBuffer implements PConstants {
protected IntBuffer pixelBuffer;
- FrameBuffer(PGraphicsOpenGL pg) {
+ public FrameBuffer(PGraphicsOpenGL pg) {
this.pg = pg;
pgl = pg.pgl;
context = pgl.createEmptyContext();
}
- FrameBuffer(PGraphicsOpenGL pg, int w, int h, int samples, int colorBuffers,
+ public FrameBuffer(PGraphicsOpenGL pg, int w, int h, int samples, int colorBuffers,
int depthBits, int stencilBits, boolean packedDepthStencil,
boolean screen) {
this(pg);
@@ -141,12 +141,12 @@ public class FrameBuffer implements PConstants {
}
- FrameBuffer(PGraphicsOpenGL pg, int w, int h) {
+ public FrameBuffer(PGraphicsOpenGL pg, int w, int h) {
this(pg, w, h, 1, 1, 0, 0, false, false);
}
- FrameBuffer(PGraphicsOpenGL pg, int w, int h, boolean screen) {
+ public FrameBuffer(PGraphicsOpenGL pg, int w, int h, boolean screen) {
this(pg, w, h, 1, 1, 0, 0, false, screen);
}
diff --git a/core/src/processing/opengl/PGL.java b/core/src/processing/opengl/PGL.java
index 8f8418e16b..51719db066 100644
--- a/core/src/processing/opengl/PGL.java
+++ b/core/src/processing/opengl/PGL.java
@@ -2752,7 +2752,7 @@ protected interface Tessellator {
}
- protected interface TessellatorCallback {
+ public interface TessellatorCallback {
void begin(int type);
void end();
void vertex(Object data);
diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java
index 88164f43e1..638f4546bd 100644
--- a/core/src/processing/opengl/PGraphicsOpenGL.java
+++ b/core/src/processing/opengl/PGraphicsOpenGL.java
@@ -1380,7 +1380,6 @@ protected boolean pointBuffersContextIsOutdated() {
return !pgl.contextIsCurrent(pointBuffersContext);
}
-
@Override
public void beginDraw() {
if (primaryGraphics) {
@@ -1433,6 +1432,17 @@ public void beginDraw() {
drawing = true;
report("bot beginDraw()");
+
+ if (tessGeo != null) {
+ tessGeo.resetIndex();
+ }
+
+ }
+
+ protected void enableMultipleBuffers() {
+ if (tessGeo != null) {
+ tessGeo.enableMultipleBuffers();
+ }
}
@@ -4289,7 +4299,6 @@ public void camera() {
0, 0, 1, 0);
}
-
/**
* More flexible method for dealing with camera().
*
@@ -5556,7 +5565,7 @@ protected void processImageBeforeAsyncSave(PImage image) {
}
- protected static void completeFinishedPixelTransfers() {
+ public static void completeFinishedPixelTransfers() {
ongoingPixelTransfersIterable.addAll(ongoingPixelTransfers);
for (AsyncPixelReader pixelReader : ongoingPixelTransfersIterable) {
// if the getter was not called this frame,
@@ -5592,7 +5601,7 @@ protected void awaitAsyncSaveCompletion(String filename) {
}
- protected class AsyncPixelReader {
+ public class AsyncPixelReader {
// PImage formats used internally to offload
// color format conversion to save threads
@@ -9089,17 +9098,39 @@ static protected class TessGeometry {
int polyVertexCount;
int firstPolyVertex;
int lastPolyVertex;
- FloatBuffer polyVerticesBuffer;
- IntBuffer polyColorsBuffer;
- FloatBuffer polyNormalsBuffer;
- FloatBuffer polyTexCoordsBuffer;
+
+ int MAX_BUFFERS = 256;
+
+ int verticesIndex = 0;
+ int colorsIndex = 0;
+ int normalsIndex = 0;
+ int texCoordsIndex = 0;
+ int ambientIndex = 0;
+ int specularIndex = 0;
+ int emissiveIndex = 0;
+ int shininessIndex = 0;
+ int polyIndicesIndex = 0;
+ int lineVerticesIndex = 0;
+ int lineColorsIndex = 0;
+ int lineDirectionsIndex = 0;
+ int lineIndiciesIndex = 0;
+ int pointVerticesIndex = 0;
+ int pointColorsIndex = 0;
+ int pointDirectionsIndex = 0;
+ int pointIndiciesIndex = 0;
+
+
+ FloatBuffer[] polyVerticesBuffer;
+ IntBuffer[] polyColorsBuffer;
+ FloatBuffer[] polyNormalsBuffer;
+ FloatBuffer[] polyTexCoordsBuffer;
// Polygon material properties (polyColors is used
// as the diffuse color when lighting is enabled)
- IntBuffer polyAmbientBuffer;
- IntBuffer polySpecularBuffer;
- IntBuffer polyEmissiveBuffer;
- FloatBuffer polyShininessBuffer;
+ IntBuffer[] polyAmbientBuffer;
+ IntBuffer[] polySpecularBuffer;
+ IntBuffer[] polyEmissiveBuffer;
+ FloatBuffer[] polyShininessBuffer;
// Generic attributes
HashMap polyAttribBuffers = new HashMap<>();
@@ -9107,7 +9138,7 @@ static protected class TessGeometry {
int polyIndexCount;
int firstPolyIndex;
int lastPolyIndex;
- ShortBuffer polyIndicesBuffer;
+ ShortBuffer[] polyIndicesBuffer;
IndexCache polyIndexCache = new IndexCache();
// Tessellated line data
@@ -9167,8 +9198,10 @@ static protected class TessGeometry {
renderMode = mode;
bufObjStreaming = stream;
allocate();
+ disableMultipleBuffers();
}
+
// -----------------------------------------------------------------
//
// Allocate/dispose
@@ -9194,17 +9227,53 @@ void allocate() {
pointOffsets = new float[2 * PGL.DEFAULT_TESS_VERTICES];
pointIndices = new short[PGL.DEFAULT_TESS_VERTICES];
+
+ polyVerticesBuffer = new FloatBuffer[MAX_BUFFERS];
+
+ polyColorsBuffer = new IntBuffer[MAX_BUFFERS];
+ polyNormalsBuffer = new FloatBuffer[MAX_BUFFERS];
+ polyTexCoordsBuffer = new FloatBuffer[MAX_BUFFERS];
+ polyAmbientBuffer = new IntBuffer[MAX_BUFFERS];
+ polySpecularBuffer = new IntBuffer[MAX_BUFFERS];
+ polyEmissiveBuffer = new IntBuffer[MAX_BUFFERS];
+ polyShininessBuffer = new FloatBuffer[MAX_BUFFERS];
+ polyIndicesBuffer = new ShortBuffer[MAX_BUFFERS];
+
+// lineVerticesBuffer = new FloatBuffer[MAX_BUFFERS];
+// lineColorsBuffer = new IntBuffer[MAX_BUFFERS];
+// lineDirectionsBuffer = new FloatBuffer[MAX_BUFFERS];
+// lineIndicesBuffer = new ShortBuffer[MAX_BUFFERS];
+//
+// pointVerticesBuffer = new FloatBuffer[MAX_BUFFERS];
+// pointColorsBuffer = new IntBuffer[MAX_BUFFERS];
+// pointOffsetsBuffer = new FloatBuffer[MAX_BUFFERS];
+// pointIndicesBuffer = new ShortBuffer[MAX_BUFFERS];
+
if (!bufObjStreaming) {
- polyVerticesBuffer = PGL.allocateFloatBuffer(polyVertices);
- polyColorsBuffer = PGL.allocateIntBuffer(polyColors);
- polyNormalsBuffer = PGL.allocateFloatBuffer(polyNormals);
- polyTexCoordsBuffer = PGL.allocateFloatBuffer(polyTexCoords);
- polyAmbientBuffer = PGL.allocateIntBuffer(polyAmbient);
- polySpecularBuffer = PGL.allocateIntBuffer(polySpecular);
- polyEmissiveBuffer = PGL.allocateIntBuffer(polyEmissive);
- polyShininessBuffer = PGL.allocateFloatBuffer(polyShininess);
- polyIndicesBuffer = PGL.allocateShortBuffer(polyIndices);
+
+ for (int i = 0; i < MAX_BUFFERS; i++) {
+ polyVerticesBuffer[i] = PGL.allocateFloatBuffer(polyVertices);
+
+ polyColorsBuffer[i] = PGL.allocateIntBuffer(polyColors);
+ polyNormalsBuffer[i] = PGL.allocateFloatBuffer(polyNormals);
+ polyTexCoordsBuffer[i] = PGL.allocateFloatBuffer(polyTexCoords);
+ polyAmbientBuffer[i] = PGL.allocateIntBuffer(polyAmbient);
+ polySpecularBuffer[i] = PGL.allocateIntBuffer(polySpecular);
+ polyEmissiveBuffer[i] = PGL.allocateIntBuffer(polyEmissive);
+ polyShininessBuffer[i] = PGL.allocateFloatBuffer(polyShininess);
+ polyIndicesBuffer[i] = PGL.allocateShortBuffer(polyIndices);
+
+// lineVerticesBuffer[i] = PGL.allocateFloatBuffer(lineVertices);
+// lineColorsBuffer[i] = PGL.allocateIntBuffer(lineColors);
+// lineDirectionsBuffer[i] = PGL.allocateFloatBuffer(lineDirections);
+// lineIndicesBuffer[i] = PGL.allocateShortBuffer(lineIndices);
+//
+// pointVerticesBuffer[i] = PGL.allocateFloatBuffer(pointVertices);
+// pointColorsBuffer[i] = PGL.allocateIntBuffer(pointColors);
+// pointOffsetsBuffer[i] = PGL.allocateFloatBuffer(pointOffsets);
+// pointIndicesBuffer[i] = PGL.allocateShortBuffer(pointIndices);
+ }
lineVerticesBuffer = PGL.allocateFloatBuffer(lineVertices);
lineColorsBuffer = PGL.allocateIntBuffer(lineColors);
@@ -9215,11 +9284,41 @@ void allocate() {
pointColorsBuffer = PGL.allocateIntBuffer(pointColors);
pointOffsetsBuffer = PGL.allocateFloatBuffer(pointOffsets);
pointIndicesBuffer = PGL.allocateShortBuffer(pointIndices);
+
}
clear();
}
+ public void resetIndex() {
+ verticesIndex = 0;
+ colorsIndex = 0;
+ normalsIndex = 0;
+ texCoordsIndex = 0;
+ ambientIndex = 0;
+ specularIndex = 0;
+ emissiveIndex = 0;
+ shininessIndex = 0;
+ polyIndicesIndex = 0;
+ lineVerticesIndex = 0;
+ lineColorsIndex = 0;
+ lineDirectionsIndex = 0;
+ lineIndiciesIndex = 0;
+ pointVerticesIndex = 0;
+ pointColorsIndex = 0;
+ pointDirectionsIndex = 0;
+ pointIndiciesIndex = 0;
+ }
+
+ public void enableMultipleBuffers() {
+ MAX_BUFFERS = 256;
+ }
+
+ public void disableMultipleBuffers() {
+ MAX_BUFFERS = 1;
+ }
+
+
void initAttrib(VertexAttribute attrib) {
if (attrib.type == PGL.FLOAT && !fpolyAttribs.containsKey(attrib.name)) {
float[] temp = new float[attrib.tessSize * PGL.DEFAULT_TESS_VERTICES];
@@ -9485,7 +9584,7 @@ int getPointVertexSum(PVector v, int first, int last) {
// Buffer mapping methods
protected void mapPolyVerticesBuffer() {
- polyVerticesBuffer = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asFloatBuffer();
+ polyVerticesBuffer[verticesIndex%MAX_BUFFERS] = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asFloatBuffer();
}
protected void initPolyVerticesBuffer(boolean onlymap, boolean unmap, int usage) {
@@ -9503,7 +9602,7 @@ protected void initPolyVerticesBuffer(boolean onlymap, boolean unmap, int usage)
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
}
} else {
- pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef, polyVerticesBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef, polyVerticesBuffer[verticesIndex%MAX_BUFFERS], usage);
}
}
@@ -9521,8 +9620,9 @@ protected void copyPolyVertices(int usage) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolyVerticesBuffer();
- pgl.bufferData(PGL.ARRAY_BUFFER, 4 * polyVertexCount * PGL.SIZEOF_FLOAT, polyVerticesBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, 4 * polyVertexCount * PGL.SIZEOF_FLOAT, polyVerticesBuffer[(verticesIndex++)%MAX_BUFFERS], usage);
}
+// System.out.println("copyPolyVertices "+((verticesIndex)%MAX_BUFFERS));
}
protected void copyPolyVertices(int offset, int size) {
@@ -9533,14 +9633,15 @@ protected void copyPolyVertices(int offset, int size) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolyVerticesBuffer(offset, size);
- polyVerticesBuffer.position(4 * offset);
- pgl.bufferSubData(PGL.ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT, 4 * size * PGL.SIZEOF_FLOAT, polyVerticesBuffer);
- polyVerticesBuffer.rewind();
+ polyVerticesBuffer[verticesIndex%MAX_BUFFERS].position(4 * offset);
+ int before = verticesIndex%MAX_BUFFERS;
+ pgl.bufferSubData(PGL.ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT, 4 * size * PGL.SIZEOF_FLOAT, polyVerticesBuffer[(verticesIndex++)%MAX_BUFFERS]);
+ polyVerticesBuffer[before].rewind();
}
}
protected void mapPolyColorsBuffer() {
- polyColorsBuffer = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
+ polyColorsBuffer[colorsIndex] = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
}
protected void initPolyColorsBuffer(boolean onlymap, boolean unmap, int usage) {
@@ -9548,17 +9649,17 @@ protected void initPolyColorsBuffer(boolean onlymap, boolean unmap, int usage) {
int sizei = polyVertexCount * PGL.SIZEOF_INT;
if (bufObjStreaming) {
if (onlymap) {
- polyColorsBuffer = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
+ polyColorsBuffer[colorsIndex%MAX_BUFFERS] = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
} else {
pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, usage);
- polyColorsBuffer = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
+ polyColorsBuffer[colorsIndex%MAX_BUFFERS] = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
updatePolyColorsBuffer();
}
if (unmap) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
}
} else {
- pgl.bufferData(PGL.ARRAY_BUFFER, sizei, polyColorsBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, sizei, polyColorsBuffer[colorsIndex%MAX_BUFFERS], usage);
}
}
@@ -9576,7 +9677,7 @@ protected void copyPolyColors(int usage) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolyColorsBuffer();
- pgl.bufferData(PGL.ARRAY_BUFFER, polyVertexCount * PGL.SIZEOF_INT, polyColorsBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, polyVertexCount * PGL.SIZEOF_INT, polyColorsBuffer[(colorsIndex++)%MAX_BUFFERS], usage);
}
}
@@ -9588,14 +9689,15 @@ protected void copyPolyColors(int offset, int size) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolyColorsBuffer(offset, size);
- polyColorsBuffer.position(offset);
- pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, polyColorsBuffer);
- polyColorsBuffer.rewind();
+ polyColorsBuffer[colorsIndex].position(offset);
+ int beforeColorsIndex = colorsIndex%MAX_BUFFERS;
+ pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, polyColorsBuffer[(colorsIndex++)%MAX_BUFFERS]);
+ polyColorsBuffer[beforeColorsIndex].rewind();
}
}
protected void mapPolyNormalsBuffer() {
- polyNormalsBuffer = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asFloatBuffer();
+ polyNormalsBuffer[(colorsIndex)%MAX_BUFFERS] = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asFloatBuffer();
}
protected void initPolyNormalsBuffer(boolean onlymap, boolean unmap, int usage) {
@@ -9613,7 +9715,7 @@ protected void initPolyNormalsBuffer(boolean onlymap, boolean unmap, int usage)
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
}
} else {
- pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef, polyNormalsBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef, polyNormalsBuffer[(normalsIndex)%MAX_BUFFERS], usage);
}
}
@@ -9631,7 +9733,7 @@ protected void copyPolyNormals(int usage) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolyNormalsBuffer();
- pgl.bufferData(PGL.ARRAY_BUFFER, 3 * polyVertexCount * PGL.SIZEOF_FLOAT, polyNormalsBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, 3 * polyVertexCount * PGL.SIZEOF_FLOAT, polyNormalsBuffer[(normalsIndex++)%MAX_BUFFERS], usage);
}
}
@@ -9643,14 +9745,15 @@ protected void copyPolyNormals(int offset, int size) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolyNormalsBuffer(offset, size);
- polyNormalsBuffer.position(3 * offset);
- pgl.bufferSubData(PGL.ARRAY_BUFFER, 3 * offset * PGL.SIZEOF_FLOAT, 3 * size * PGL.SIZEOF_FLOAT, polyNormalsBuffer);
- polyNormalsBuffer.rewind();
+ polyNormalsBuffer[(normalsIndex)%MAX_BUFFERS].position(3 * offset);
+ int before = (normalsIndex)%MAX_BUFFERS;
+ pgl.bufferSubData(PGL.ARRAY_BUFFER, 3 * offset * PGL.SIZEOF_FLOAT, 3 * size * PGL.SIZEOF_FLOAT, polyNormalsBuffer[(normalsIndex++)%MAX_BUFFERS]);
+ polyNormalsBuffer[before].rewind();
}
}
protected void mapPolyTexCoordsBuffer() {
- polyTexCoordsBuffer = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asFloatBuffer();
+ polyTexCoordsBuffer[(normalsIndex)%MAX_BUFFERS] = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asFloatBuffer();
}
protected void initPolyTexCoordsBuffer(boolean onlymap, boolean unmap, int usage) {
@@ -9668,7 +9771,7 @@ protected void initPolyTexCoordsBuffer(boolean onlymap, boolean unmap, int usage
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
}
} else {
- pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef, polyTexCoordsBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef, polyTexCoordsBuffer[(texCoordsIndex)%MAX_BUFFERS], usage);
}
}
@@ -9686,7 +9789,7 @@ protected void copyPolyTexCoords(int usage) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolyTexCoordsBuffer();
- pgl.bufferData(PGL.ARRAY_BUFFER, 2 * polyVertexCount * PGL.SIZEOF_FLOAT, polyTexCoordsBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, 2 * polyVertexCount * PGL.SIZEOF_FLOAT, polyTexCoordsBuffer[(texCoordsIndex++)%MAX_BUFFERS], usage);
}
}
@@ -9698,14 +9801,15 @@ protected void copyPolyTexCoords(int offset, int size) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolyTexCoordsBuffer(offset, size);
- polyTexCoordsBuffer.position(2 * offset);
- pgl.bufferSubData(PGL.ARRAY_BUFFER, 2 * offset * PGL.SIZEOF_FLOAT, 2 * size * PGL.SIZEOF_FLOAT, polyTexCoordsBuffer);
- polyTexCoordsBuffer.rewind();
+ polyTexCoordsBuffer[(texCoordsIndex)%MAX_BUFFERS].position(2 * offset);
+ int before = (texCoordsIndex)%MAX_BUFFERS;
+ pgl.bufferSubData(PGL.ARRAY_BUFFER, 2 * offset * PGL.SIZEOF_FLOAT, 2 * size * PGL.SIZEOF_FLOAT, polyTexCoordsBuffer[(texCoordsIndex++)%MAX_BUFFERS]);
+ polyTexCoordsBuffer[before].rewind();
}
}
protected void mapPolyAmbientBuffer() {
- polyAmbientBuffer = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
+ polyAmbientBuffer[(ambientIndex)%MAX_BUFFERS] = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
}
protected void initPolyAmbientBuffer(boolean onlymap, boolean unmap, int usage) {
@@ -9713,17 +9817,17 @@ protected void initPolyAmbientBuffer(boolean onlymap, boolean unmap, int usage)
int sizei = polyVertexCount * PGL.SIZEOF_INT;
if (bufObjStreaming) {
if (onlymap) {
- polyAmbientBuffer = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
+ polyAmbientBuffer[(ambientIndex)%MAX_BUFFERS] = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
} else {
pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, usage);
- polyAmbientBuffer = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
+ polyAmbientBuffer[(ambientIndex)%MAX_BUFFERS] = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
updatePolyAmbientBuffer();
}
if (unmap) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
}
} else {
- pgl.bufferData(PGL.ARRAY_BUFFER, sizei, polyAmbientBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, sizei, polyAmbientBuffer[(ambientIndex)%MAX_BUFFERS], usage);
}
}
@@ -9741,7 +9845,7 @@ protected void copyPolyAmbient(int usage) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolyAmbientBuffer();
- pgl.bufferData(PGL.ARRAY_BUFFER, polyVertexCount * PGL.SIZEOF_INT, polyAmbientBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, polyVertexCount * PGL.SIZEOF_INT, polyAmbientBuffer[(ambientIndex++)%MAX_BUFFERS], usage);
}
}
@@ -9753,14 +9857,15 @@ protected void copyPolyAmbient(int offset, int size) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolyAmbientBuffer(offset, size);
- polyAmbientBuffer.position(offset);
- pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, polyAmbientBuffer);
- polyAmbientBuffer.rewind();
+ polyAmbientBuffer[(ambientIndex)%MAX_BUFFERS].position(offset);
+ int before = (ambientIndex)%MAX_BUFFERS;
+ pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, polyAmbientBuffer[(ambientIndex++)%MAX_BUFFERS]);
+ polyAmbientBuffer[before].rewind();
}
}
protected void mapPolySpecularBuffer() {
- polySpecularBuffer = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
+ polySpecularBuffer[(specularIndex)%MAX_BUFFERS] = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
}
protected void initPolySpecularBuffer(boolean onlymap, boolean unmap, int usage) {
@@ -9768,17 +9873,17 @@ protected void initPolySpecularBuffer(boolean onlymap, boolean unmap, int usage)
int sizei = polyVertexCount * PGL.SIZEOF_INT;
if (bufObjStreaming) {
if (onlymap) {
- polySpecularBuffer = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
+ polySpecularBuffer[(specularIndex)%MAX_BUFFERS] = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
} else {
pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, usage);
- polySpecularBuffer = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
+ polySpecularBuffer[(specularIndex)%MAX_BUFFERS] = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
updatePolySpecularBuffer();
}
if (unmap) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
}
} else {
- pgl.bufferData(PGL.ARRAY_BUFFER, sizei, polySpecularBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, sizei, polySpecularBuffer[(specularIndex)%MAX_BUFFERS], usage);
}
}
@@ -9796,7 +9901,7 @@ protected void copyPolySpecular(int usage) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolySpecularBuffer();
- pgl.bufferData(PGL.ARRAY_BUFFER, polyVertexCount * PGL.SIZEOF_INT, polySpecularBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, polyVertexCount * PGL.SIZEOF_INT, polySpecularBuffer[(specularIndex++)%MAX_BUFFERS], usage);
}
}
@@ -9808,14 +9913,15 @@ protected void copyPolySpecular(int offset, int size) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolySpecularBuffer(offset, size);
- polySpecularBuffer.position(offset);
- pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, polySpecularBuffer);
- polySpecularBuffer.rewind();
+ polySpecularBuffer[(specularIndex)%MAX_BUFFERS].position(offset);
+ int before = (specularIndex)%MAX_BUFFERS;
+ pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, polySpecularBuffer[(specularIndex++)%MAX_BUFFERS]);
+ polySpecularBuffer[before].rewind();
}
}
protected void mapPolyEmissiveBuffer() {
- polyEmissiveBuffer = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
+ polyEmissiveBuffer[(emissiveIndex)%MAX_BUFFERS] = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
}
protected void initPolyEmissiveBuffer(boolean onlymap, boolean unmap, int usage) {
@@ -9823,17 +9929,17 @@ protected void initPolyEmissiveBuffer(boolean onlymap, boolean unmap, int usage)
int sizei = polyVertexCount * PGL.SIZEOF_INT;
if (bufObjStreaming) {
if (onlymap) {
- polyEmissiveBuffer = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
+ polyEmissiveBuffer[(emissiveIndex)%MAX_BUFFERS] = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
} else {
pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, usage);
- polyEmissiveBuffer = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
+ polyEmissiveBuffer[(emissiveIndex)%MAX_BUFFERS] = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asIntBuffer();
updatePolyEmissiveBuffer();
}
if (unmap) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
}
} else {
- pgl.bufferData(PGL.ARRAY_BUFFER, sizei, polyEmissiveBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, sizei, polyEmissiveBuffer[(emissiveIndex)%MAX_BUFFERS], usage);
}
}
@@ -9851,7 +9957,7 @@ protected void copyPolyEmissive(int usage) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolyEmissiveBuffer();
- pgl.bufferData(PGL.ARRAY_BUFFER, polyVertexCount * PGL.SIZEOF_INT, polyEmissiveBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, polyVertexCount * PGL.SIZEOF_INT, polyEmissiveBuffer[(emissiveIndex++)%MAX_BUFFERS], usage);
}
}
@@ -9863,14 +9969,15 @@ protected void copyPolyEmissive(int offset, int size) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolyEmissiveBuffer(offset, size);
- polyEmissiveBuffer.position(offset);
- pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, polyEmissiveBuffer);
- polyEmissiveBuffer.rewind();
+ polyEmissiveBuffer[(emissiveIndex)%MAX_BUFFERS].position(offset);
+ int before = (emissiveIndex)%MAX_BUFFERS;
+ pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, polyEmissiveBuffer[(emissiveIndex++)%MAX_BUFFERS]);
+ polyEmissiveBuffer[before].rewind();
}
}
protected void mapPolyShininessBuffer() {
- polyShininessBuffer = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asFloatBuffer();
+ polyShininessBuffer[(shininessIndex)%MAX_BUFFERS] = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asFloatBuffer();
}
protected void initPolyShininessBuffer(boolean onlymap, boolean unmap, int usage) {
@@ -9878,17 +9985,17 @@ protected void initPolyShininessBuffer(boolean onlymap, boolean unmap, int usage
int sizei = polyVertexCount * PGL.SIZEOF_FLOAT;
if (bufObjStreaming) {
if (onlymap) {
- polyShininessBuffer = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asFloatBuffer();
+ polyShininessBuffer[(shininessIndex)%MAX_BUFFERS] = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asFloatBuffer();
} else {
pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, usage);
- polyShininessBuffer = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asFloatBuffer();
+ polyShininessBuffer[(shininessIndex)%MAX_BUFFERS] = pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asFloatBuffer();
updatePolyShininessBuffer();
}
if (unmap) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
}
} else {
- pgl.bufferData(PGL.ARRAY_BUFFER, sizei, polyShininessBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, sizei, polyShininessBuffer[(shininessIndex)%MAX_BUFFERS], usage);
}
}
@@ -9906,7 +10013,7 @@ protected void copyPolyShininess(int usage) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolyShininessBuffer();
- pgl.bufferData(PGL.ARRAY_BUFFER, polyVertexCount * PGL.SIZEOF_FLOAT, polyShininessBuffer, usage);
+ pgl.bufferData(PGL.ARRAY_BUFFER, polyVertexCount * PGL.SIZEOF_FLOAT, polyShininessBuffer[(shininessIndex++)%MAX_BUFFERS], usage);
}
}
@@ -9918,9 +10025,10 @@ protected void copyPolyShininess(int offset, int size) {
pgl.unmapBuffer(PGL.ARRAY_BUFFER);
} else {
updatePolyShininessBuffer(offset, size);
- polyShininessBuffer.position(offset);
- pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_FLOAT, size * PGL.SIZEOF_FLOAT, polyShininessBuffer);
- polyShininessBuffer.rewind();
+ polyShininessBuffer[(shininessIndex)%MAX_BUFFERS].position(offset);
+ int before = (shininessIndex)%MAX_BUFFERS;
+ pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_FLOAT, size * PGL.SIZEOF_FLOAT, polyShininessBuffer[(shininessIndex++)%MAX_BUFFERS]);
+ polyShininessBuffer[before].rewind();
}
}
@@ -9988,7 +10096,7 @@ protected void copyPolyAttribs(VertexAttribute attrib, int offset, int size) {
}
protected void mapPolyIndicesBuffer() {
- polyIndicesBuffer = pg.pgl.mapBuffer(PGL.ELEMENT_ARRAY_BUFFER, PGL.bufferMapAccess).asShortBuffer();
+ polyIndicesBuffer[(polyIndicesIndex)%MAX_BUFFERS] = pg.pgl.mapBuffer(PGL.ELEMENT_ARRAY_BUFFER, PGL.bufferMapAccess).asShortBuffer();
}
protected void initPolyIndicesBuffer(boolean onlymap, boolean unmap, int usage) {
@@ -10006,7 +10114,7 @@ protected void initPolyIndicesBuffer(boolean onlymap, boolean unmap, int usage)
pgl.unmapBuffer(PGL.ELEMENT_ARRAY_BUFFER);
}
} else {
- pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, sizei, polyIndicesBuffer, usage);
+ pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, sizei, polyIndicesBuffer[(polyIndicesIndex)%MAX_BUFFERS], usage);
}
}
@@ -10019,11 +10127,12 @@ protected void copyPolyIndices(int usage) {
pgl.unmapBuffer(PGL.ELEMENT_ARRAY_BUFFER);
} else {
updatePolyIndicesBuffer();
- pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, polyIndexCount * PGL.SIZEOF_INDEX, polyIndicesBuffer, usage);
+ pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, polyIndexCount * PGL.SIZEOF_INDEX, polyIndicesBuffer[(polyIndicesIndex++)%MAX_BUFFERS], usage);
}
}
protected void mapLineVerticesBuffer() {
+// lineVerticesBuffer[(lineVerticesIndex)%MAX_BUFFERS] = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asFloatBuffer();
lineVerticesBuffer = pg.pgl.mapBuffer(PGL.ARRAY_BUFFER, PGL.bufferMapAccess).asFloatBuffer();
}
@@ -10434,7 +10543,30 @@ protected void updatePolyVerticesBuffer() {
}
protected void updatePolyVerticesBuffer(int offset, int size) {
- PGL.updateFloatBuffer(polyVerticesBuffer, polyVertices, 4 * offset, 4 * size);
+ PGL.updateFloatBuffer(polyVerticesBuffer[verticesIndex%MAX_BUFFERS], polyVertices, 4 * offset, 4 * size);
+// System.out.println("-----");
+// System.out.println("offset: "+offset+" size: "+size);
+// System.out.println("normal array:");
+// try {
+// for (int i = 0; i < 4; i++) {
+// System.out.print(polyVertices[i]+" ");
+// }
+// }
+// catch (RuntimeException e) {
+// System.out.println("(woops)");
+// }
+//
+//
+// System.out.println("\nBuffer: ");
+// int max = polyVerticesBuffer[verticesIndex%MAX_BUFFERS].capacity();
+// if (16 < max) max = 16;
+//
+// for (int i = 0; i < max; i+=4) {
+// float f = polyVerticesBuffer[verticesIndex%MAX_BUFFERS].get();
+// System.out.print(f+" ");
+// }
+// polyVerticesBuffer[verticesIndex%MAX_BUFFERS].rewind();
+// System.out.println();
}
protected void updatePolyColorsBuffer() {
@@ -10442,7 +10574,7 @@ protected void updatePolyColorsBuffer() {
}
protected void updatePolyColorsBuffer(int offset, int size) {
- PGL.updateIntBuffer(polyColorsBuffer, polyColors, offset, size);
+ PGL.updateIntBuffer(polyColorsBuffer[colorsIndex%MAX_BUFFERS], polyColors, offset, size);
}
protected void updatePolyNormalsBuffer() {
@@ -10450,7 +10582,7 @@ protected void updatePolyNormalsBuffer() {
}
protected void updatePolyNormalsBuffer(int offset, int size) {
- PGL.updateFloatBuffer(polyNormalsBuffer, polyNormals, 3 * offset, 3 * size);
+ PGL.updateFloatBuffer(polyNormalsBuffer[normalsIndex%MAX_BUFFERS], polyNormals, 3 * offset, 3 * size);
}
protected void updatePolyTexCoordsBuffer() {
@@ -10458,7 +10590,7 @@ protected void updatePolyTexCoordsBuffer() {
}
protected void updatePolyTexCoordsBuffer(int offset, int size) {
- PGL.updateFloatBuffer(polyTexCoordsBuffer, polyTexCoords, 2 * offset, 2 * size);
+ PGL.updateFloatBuffer(polyTexCoordsBuffer[texCoordsIndex%MAX_BUFFERS], polyTexCoords, 2 * offset, 2 * size);
}
protected void updatePolyAmbientBuffer() {
@@ -10466,7 +10598,7 @@ protected void updatePolyAmbientBuffer() {
}
protected void updatePolyAmbientBuffer(int offset, int size) {
- PGL.updateIntBuffer(polyAmbientBuffer, polyAmbient, offset, size);
+ PGL.updateIntBuffer(polyAmbientBuffer[ambientIndex%MAX_BUFFERS], polyAmbient, offset, size);
}
protected void updatePolySpecularBuffer() {
@@ -10474,7 +10606,7 @@ protected void updatePolySpecularBuffer() {
}
protected void updatePolySpecularBuffer(int offset, int size) {
- PGL.updateIntBuffer(polySpecularBuffer, polySpecular, offset, size);
+ PGL.updateIntBuffer(polySpecularBuffer[specularIndex%MAX_BUFFERS], polySpecular, offset, size);
}
protected void updatePolyEmissiveBuffer() {
@@ -10482,7 +10614,7 @@ protected void updatePolyEmissiveBuffer() {
}
protected void updatePolyEmissiveBuffer(int offset, int size) {
- PGL.updateIntBuffer(polyEmissiveBuffer, polyEmissive, offset, size);
+ PGL.updateIntBuffer(polyEmissiveBuffer[emissiveIndex%MAX_BUFFERS], polyEmissive, offset, size);
}
protected void updatePolyShininessBuffer() {
@@ -10490,7 +10622,7 @@ protected void updatePolyShininessBuffer() {
}
protected void updatePolyShininessBuffer(int offset, int size) {
- PGL.updateFloatBuffer(polyShininessBuffer, polyShininess, offset, size);
+ PGL.updateFloatBuffer(polyShininessBuffer[shininessIndex%MAX_BUFFERS], polyShininess, offset, size);
}
protected void updateAttribBuffer(String name) {
@@ -10522,7 +10654,7 @@ protected void updatePolyIndicesBuffer() {
}
protected void updatePolyIndicesBuffer(int offset, int size) {
- PGL.updateShortBuffer(polyIndicesBuffer, polyIndices, offset, size);
+ PGL.updateShortBuffer(polyIndicesBuffer[polyIndicesIndex%MAX_BUFFERS], polyIndices, offset, size);
}
protected void updateLineVerticesBuffer() {
@@ -10597,56 +10729,88 @@ void expandPolyVertices(int n) {
float[] temp = new float[4 * n];
PApplet.arrayCopy(polyVertices, 0, temp, 0, 4 * polyVertexCount);
polyVertices = temp;
- if (!bufObjStreaming) polyVerticesBuffer = PGL.allocateFloatBuffer(polyVertices);
+ if (!bufObjStreaming) {
+ for (int i = 0; i < MAX_BUFFERS; i++) {
+ polyVerticesBuffer[i] = PGL.allocateFloatBuffer(polyVertices);
+ }
+ }
}
void expandPolyColors(int n) {
int[] temp = new int[n];
PApplet.arrayCopy(polyColors, 0, temp, 0, polyVertexCount);
polyColors = temp;
- if (!bufObjStreaming) polyColorsBuffer = PGL.allocateIntBuffer(polyColors);
+ if (!bufObjStreaming) {
+ for (int i = 0; i < MAX_BUFFERS; i++) {
+ polyColorsBuffer[i] = PGL.allocateIntBuffer(polyColors);
+ }
+ }
}
void expandPolyNormals(int n) {
float[] temp = new float[3 * n];
PApplet.arrayCopy(polyNormals, 0, temp, 0, 3 * polyVertexCount);
polyNormals = temp;
- if (!bufObjStreaming) polyNormalsBuffer = PGL.allocateFloatBuffer(polyNormals);
+ if (!bufObjStreaming) {
+ for (int i = 0; i < MAX_BUFFERS; i++) {
+ polyNormalsBuffer[i] = PGL.allocateFloatBuffer(polyNormals);
+ }
+ }
}
void expandPolyTexCoords(int n) {
float[] temp = new float[2 * n];
PApplet.arrayCopy(polyTexCoords, 0, temp, 0, 2 * polyVertexCount);
polyTexCoords = temp;
- if (!bufObjStreaming) polyTexCoordsBuffer = PGL.allocateFloatBuffer(polyTexCoords);
+ if (!bufObjStreaming) {
+ for (int i = 0; i < MAX_BUFFERS; i++) {
+ polyTexCoordsBuffer[i] = PGL.allocateFloatBuffer(polyTexCoords);
+ }
+ }
}
void expandPolyAmbient(int n) {
int[] temp = new int[n];
PApplet.arrayCopy(polyAmbient, 0, temp, 0, polyVertexCount);
polyAmbient = temp;
- if (!bufObjStreaming) polyAmbientBuffer = PGL.allocateIntBuffer(polyAmbient);
+ if (!bufObjStreaming) {
+ for (int i = 0; i < MAX_BUFFERS; i++) {
+ polyAmbientBuffer[i] = PGL.allocateIntBuffer(polyAmbient);
+ }
+ }
}
void expandPolySpecular(int n) {
int[] temp = new int[n];
PApplet.arrayCopy(polySpecular, 0, temp, 0, polyVertexCount);
polySpecular = temp;
- if (!bufObjStreaming) polySpecularBuffer = PGL.allocateIntBuffer(polySpecular);
+ if (!bufObjStreaming) {
+ for (int i = 0; i < MAX_BUFFERS; i++) {
+ polySpecularBuffer[i] = PGL.allocateIntBuffer(polySpecular);
+ }
+ }
}
void expandPolyEmissive(int n) {
int[] temp = new int[n];
PApplet.arrayCopy(polyEmissive, 0, temp, 0, polyVertexCount);
polyEmissive = temp;
- if (!bufObjStreaming) polyEmissiveBuffer = PGL.allocateIntBuffer(polyEmissive);
+ if (!bufObjStreaming) {
+ for (int i = 0; i < MAX_BUFFERS; i++) {
+ polyEmissiveBuffer[i] = PGL.allocateIntBuffer(polyEmissive);
+ }
+ }
}
void expandPolyShininess(int n) {
float[] temp = new float[n];
PApplet.arrayCopy(polyShininess, 0, temp, 0, polyVertexCount);
polyShininess = temp;
- if (!bufObjStreaming) polyShininessBuffer = PGL.allocateFloatBuffer(polyShininess);
+ if (!bufObjStreaming) {
+ for (int i = 0; i < MAX_BUFFERS; i++) {
+ polyShininessBuffer[i] = PGL.allocateFloatBuffer(polyShininess);
+ }
+ }
}
void expandAttributes(int n) {
@@ -10690,7 +10854,11 @@ void expandPolyIndices(int n) {
short[] temp = new short[n];
PApplet.arrayCopy(polyIndices, 0, temp, 0, polyIndexCount);
polyIndices = temp;
- if (!bufObjStreaming) polyIndicesBuffer = PGL.allocateShortBuffer(polyIndices);
+ if (!bufObjStreaming) {
+ for (int i = 0; i < MAX_BUFFERS; i++) {
+ polyIndicesBuffer[i] = PGL.allocateShortBuffer(polyIndices);
+ }
+ }
}
void expandLineVertices(int n) {
@@ -10791,60 +10959,62 @@ void trim() {
}
}
+
+ // TODO: For loop instead of the current index.
void trimPolyVertices() {
float[] temp = new float[4 * polyVertexCount];
PApplet.arrayCopy(polyVertices, 0, temp, 0, 4 * polyVertexCount);
polyVertices = temp;
- if (!bufObjStreaming) polyVerticesBuffer = PGL.allocateFloatBuffer(polyVertices);
+ if (!bufObjStreaming) polyVerticesBuffer[verticesIndex%MAX_BUFFERS] = PGL.allocateFloatBuffer(polyVertices);
}
void trimPolyColors() {
int[] temp = new int[polyVertexCount];
PApplet.arrayCopy(polyColors, 0, temp, 0, polyVertexCount);
polyColors = temp;
- if (!bufObjStreaming) polyColorsBuffer = PGL.allocateIntBuffer(polyColors);
+ if (!bufObjStreaming) polyColorsBuffer[colorsIndex%MAX_BUFFERS] = PGL.allocateIntBuffer(polyColors);
}
void trimPolyNormals() {
float[] temp = new float[3 * polyVertexCount];
PApplet.arrayCopy(polyNormals, 0, temp, 0, 3 * polyVertexCount);
polyNormals = temp;
- if (!bufObjStreaming) polyNormalsBuffer = PGL.allocateFloatBuffer(polyNormals);
+ if (!bufObjStreaming) polyNormalsBuffer[normalsIndex%MAX_BUFFERS] = PGL.allocateFloatBuffer(polyNormals);
}
void trimPolyTexCoords() {
float[] temp = new float[2 * polyVertexCount];
PApplet.arrayCopy(polyTexCoords, 0, temp, 0, 2 * polyVertexCount);
polyTexCoords = temp;
- if (!bufObjStreaming) polyTexCoordsBuffer = PGL.allocateFloatBuffer(polyTexCoords);
+ if (!bufObjStreaming) polyTexCoordsBuffer[texCoordsIndex%MAX_BUFFERS] = PGL.allocateFloatBuffer(polyTexCoords);
}
void trimPolyAmbient() {
int[] temp = new int[polyVertexCount];
PApplet.arrayCopy(polyAmbient, 0, temp, 0, polyVertexCount);
polyAmbient = temp;
- if (!bufObjStreaming) polyAmbientBuffer = PGL.allocateIntBuffer(polyAmbient);
+ if (!bufObjStreaming) polyAmbientBuffer[ambientIndex%MAX_BUFFERS] = PGL.allocateIntBuffer(polyAmbient);
}
void trimPolySpecular() {
int[] temp = new int[polyVertexCount];
PApplet.arrayCopy(polySpecular, 0, temp, 0, polyVertexCount);
polySpecular = temp;
- if (!bufObjStreaming) polySpecularBuffer = PGL.allocateIntBuffer(polySpecular);
+ if (!bufObjStreaming) polySpecularBuffer[specularIndex%MAX_BUFFERS] = PGL.allocateIntBuffer(polySpecular);
}
void trimPolyEmissive() {
int[] temp = new int[polyVertexCount];
PApplet.arrayCopy(polyEmissive, 0, temp, 0, polyVertexCount);
polyEmissive = temp;
- if (!bufObjStreaming) polyEmissiveBuffer = PGL.allocateIntBuffer(polyEmissive);
+ if (!bufObjStreaming) polyEmissiveBuffer[emissiveIndex%MAX_BUFFERS] = PGL.allocateIntBuffer(polyEmissive);
}
void trimPolyShininess() {
float[] temp = new float[polyVertexCount];
PApplet.arrayCopy(polyShininess, 0, temp, 0, polyVertexCount);
polyShininess = temp;
- if (!bufObjStreaming) polyShininessBuffer = PGL.allocateFloatBuffer(polyShininess);
+ if (!bufObjStreaming) polyShininessBuffer[shininessIndex%MAX_BUFFERS] = PGL.allocateFloatBuffer(polyShininess);
}
void trimPolyAttributes() {
@@ -10888,7 +11058,7 @@ void trimPolyIndices() {
short[] temp = new short[polyIndexCount];
PApplet.arrayCopy(polyIndices, 0, temp, 0, polyIndexCount);
polyIndices = temp;
- if (!bufObjStreaming) polyIndicesBuffer = PGL.allocateShortBuffer(polyIndices);
+ if (!bufObjStreaming) polyIndicesBuffer[polyIndicesIndex%MAX_BUFFERS] = PGL.allocateShortBuffer(polyIndices);
}
void trimLineVertices() {
@@ -14580,4 +14750,4 @@ static void rotateRight(int[] array, int i1, int i2) {
}
-}
+}
\ No newline at end of file
diff --git a/core/src/processing/vulkan/PGraphicsVulkan.java b/core/src/processing/vulkan/PGraphicsVulkan.java
new file mode 100644
index 0000000000..3622327c05
--- /dev/null
+++ b/core/src/processing/vulkan/PGraphicsVulkan.java
@@ -0,0 +1,51 @@
+package processing.vulkan;
+
+import processing.GL2VK.GL2VK;
+import processing.core.PSurface;
+import processing.opengl.PGL;
+import processing.opengl.PGraphicsOpenGL;
+import processing.opengl.PJOGL;
+
+public class PGraphicsVulkan extends PGraphicsOpenGL {
+
+ public PGraphicsVulkan() {
+ super();
+ }
+
+ @Override
+ protected PGL createPGL(PGraphicsOpenGL pg) {
+ return new PVK(pg);
+ }
+
+ @Override
+ public PSurface createSurface() {
+ return surface = new PSurfaceVK(this);
+ }
+
+ public void selectNode(int node) {
+ ((PVK)pgl).selectNode(node);
+ }
+
+ public void enableAutoMode() {
+ ((PVK)pgl).enableAutoMode();
+ }
+
+ public int getNodesCount() {
+ return ((PVK)pgl).getNodesCount();
+ }
+
+ public void setMaxNodes(int v) {
+ ((PVK)pgl).setMaxNodes(v);
+ }
+
+
+ public void bufferMultithreaded(boolean onoff) {
+ ((PVK)pgl).bufferMultithreaded(onoff);
+ }
+
+ @Override
+ public void beginDraw() {
+ super.beginDraw();
+ enableMultipleBuffers();
+ }
+}
diff --git a/core/src/processing/vulkan/PJOGLInterface.java b/core/src/processing/vulkan/PJOGLInterface.java
new file mode 100644
index 0000000000..7af0c19b3b
--- /dev/null
+++ b/core/src/processing/vulkan/PJOGLInterface.java
@@ -0,0 +1,196 @@
+package processing.vulkan;
+
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Shape;
+import java.awt.Toolkit;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.geom.PathIterator;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.jogamp.common.util.VersionNumber;
+import com.jogamp.opengl.GL;
+import com.jogamp.opengl.GL2;
+import com.jogamp.opengl.GL2ES2;
+import com.jogamp.opengl.GL2ES3;
+import com.jogamp.opengl.GL2GL3;
+import com.jogamp.opengl.GL3ES3;
+import com.jogamp.opengl.GLAutoDrawable;
+import com.jogamp.opengl.GLCapabilities;
+import com.jogamp.opengl.GLCapabilitiesImmutable;
+import com.jogamp.opengl.GLContext;
+import com.jogamp.opengl.GLDrawable;
+import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
+import com.jogamp.opengl.GLRendererQuirks;
+import com.jogamp.opengl.glu.GLU;
+import com.jogamp.opengl.glu.GLUtessellator;
+import com.jogamp.opengl.glu.GLUtessellatorCallbackAdapter;
+
+
+public interface PJOGLInterface {
+public Object getNative();
+public void setCaps(GLCapabilities caps);
+public GLCapabilitiesImmutable getCaps();
+public boolean needSharedObjectSync();
+public void setFps(float fps);
+public void getGL(GLAutoDrawable glDrawable);
+public void init(GLAutoDrawable glDrawable);
+public void showme(String method, int value);
+public void flush();
+public void finish();
+public void hint(int target, int hint);
+public void enable(int value);
+public void disable(int value);
+public void getBooleanv(int value, IntBuffer data);
+public void getIntegerv(int value, IntBuffer data);
+public void getFloatv(int value, FloatBuffer data);
+public boolean isEnabled(int value);
+public String getString(int name);
+public int getError();
+public String errorString(int err);
+public void genBuffers(int n, IntBuffer buffers);
+public void deleteBuffers(int n, IntBuffer buffers);
+public void bindBuffer(int target, int buffer);
+public void bufferData(int target, int size, Buffer data, int usage);
+public void bufferSubData(int target, int offset, int size, Buffer data);
+public void isBuffer(int buffer);
+public void getBufferParameteriv(int target, int value, IntBuffer data);
+public ByteBuffer mapBuffer(int target, int access);
+public ByteBuffer mapBufferRange(int target, int offset, int length, int access);
+public void unmapBuffer(int target);
+public long fenceSync(int condition, int flags);
+public void deleteSync(long sync);
+public int clientWaitSync(long sync, int flags, long timeout);
+public void depthRangef(float n, float f);
+public void viewport(int x, int y, int w, int h);
+public void vertexAttrib1f(int index, float value);
+public void vertexAttrib2f(int index, float value0, float value1);
+public void vertexAttrib3f(int index, float value0, float value1, float value2);
+public void vertexAttrib4f(int index, float value0, float value1, float value2, float value3);
+public void vertexAttrib1fv(int index, FloatBuffer values);
+public void vertexAttrib2fv(int index, FloatBuffer values);
+public void vertexAttrib3fv(int index, FloatBuffer values);
+public void vertexAttrib4fv(int index, FloatBuffer values);
+public void vertexAttribPointer(int index, int size, int type, boolean normalized, int stride, int offset);
+public void enableVertexAttribArray(int index);
+public void disableVertexAttribArray(int index);
+public void drawArraysImpl(int mode, int first, int count);
+public void drawElementsImpl(int mode, int count, int type, int offset);
+public void lineWidth(float width);
+public void frontFace(int dir);
+public void cullFace(int mode);
+public void polygonOffset(float factor, float units);
+public void pixelStorei(int pname, int param);
+public void texImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, Buffer data);
+public void copyTexImage2D(int target, int level, int internalFormat, int x, int y, int width, int height, int border);
+public void texSubImage2D(int target, int level, int xOffset, int yOffset, int width, int height, int format, int type, Buffer data);
+public void copyTexSubImage2D(int target, int level, int xOffset, int yOffset, int x, int y, int width, int height);
+public void compressedTexImage2D(int target, int level, int internalFormat, int width, int height, int border, int imageSize, Buffer data);
+public void compressedTexSubImage2D(int target, int level, int xOffset, int yOffset, int width, int height, int format, int imageSize, Buffer data);
+public void texParameteri(int target, int pname, int param);
+public void texParameterf(int target, int pname, float param);
+public void texParameteriv(int target, int pname, IntBuffer params);
+public void texParameterfv(int target, int pname, FloatBuffer params);
+public void generateMipmap(int target);
+public void genTextures(int n, IntBuffer textures);
+public void deleteTextures(int n, IntBuffer textures);
+public void getTexParameteriv(int target, int pname, IntBuffer params);
+public void getTexParameterfv(int target, int pname, FloatBuffer params);
+public boolean isTexture(int texture);
+public int createShader(int type);
+public void shaderSource(int shader, String source);
+public void compileShader(int shader);
+public void releaseShaderCompiler();
+public void deleteShader(int shader);
+public void shaderBinary(int count, IntBuffer shaders, int binaryFormat, Buffer binary, int length);
+public int createProgram();
+public void attachShader(int program, int shader);
+public void detachShader(int program, int shader);
+public void linkProgram(int program);
+public void useProgram(int program);
+public void deleteProgram(int program);
+public String getActiveAttrib(int program, int index, IntBuffer size, IntBuffer type);
+public int getAttribLocation(int program, String name);
+public void bindAttribLocation(int program, int index, String name);
+public int getUniformLocation(int program, String name);
+public String getActiveUniform(int program, int index, IntBuffer size, IntBuffer type);
+public void uniform1i(int location, int value);
+public void uniform2i(int location, int value0, int value1);
+public void uniform3i(int location, int value0, int value1, int value2);
+public void uniform4i(int location, int value0, int value1, int value2, int value3);
+public void uniform1f(int location, float value);
+public void uniform2f(int location, float value0, float value1);
+public void uniform3f(int location, float value0, float value1, float value2);
+public void uniform4f(int location, float value0, float value1, float value2, float value3);
+public void uniform1iv(int location, int count, IntBuffer v);
+public void uniform2iv(int location, int count, IntBuffer v);
+public void uniform3iv(int location, int count, IntBuffer v);
+public void uniform4iv(int location, int count, IntBuffer v);
+public void uniform1fv(int location, int count, FloatBuffer v);
+public void uniform2fv(int location, int count, FloatBuffer v);
+public void uniform3fv(int location, int count, FloatBuffer v);
+public void uniform4fv(int location, int count, FloatBuffer v);
+public void uniformMatrix2fv(int location, int count, boolean transpose, FloatBuffer mat);
+public void uniformMatrix3fv(int location, int count, boolean transpose, FloatBuffer mat);
+public void uniformMatrix4fv(int location, int count, boolean transpose, FloatBuffer mat);
+public void validateProgram(int program);
+public boolean isShader(int shader);
+public void getShaderiv(int shader, int pname, IntBuffer params);
+public void getAttachedShaders(int program, int maxCount, IntBuffer count, IntBuffer shaders);
+public String getShaderInfoLog(int shader);
+public String getShaderSource(int shader);
+public void getShaderPrecisionFormat(int shaderType, int precisionType, IntBuffer range, IntBuffer precision);
+public void getVertexAttribfv(int index, int pname, FloatBuffer params);
+public void getVertexAttribiv(int index, int pname, IntBuffer params);
+public void getVertexAttribPointerv(int index, int pname, ByteBuffer data);
+public void getUniformfv(int program, int location, FloatBuffer params);
+public void getUniformiv(int program, int location, IntBuffer params);
+public boolean isProgram(int program);
+public void getProgramiv(int program, int pname, IntBuffer params);
+public String getProgramInfoLog(int program);
+public void scissor(int x, int y, int w, int h);
+public void sampleCoverage(float value, boolean invert);
+public void stencilFunc(int func, int ref, int mask);
+public void stencilFuncSeparate(int face, int func, int ref, int mask);
+public void stencilOp(int sfail, int dpfail, int dppass);
+public void stencilOpSeparate(int face, int sfail, int dpfail, int dppass);
+public void depthFunc(int func);
+public void blendEquation(int mode);
+public void blendEquationSeparate(int modeRGB, int modeAlpha);
+public void blendFunc(int src, int dst);
+public void blendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha);
+public void blendColor(float red, float green, float blue, float alpha);
+public void colorMask(boolean r, boolean g, boolean b, boolean a);
+public void depthMask(boolean mask);
+public void stencilMask(int mask);
+public void stencilMaskSeparate(int face, int mask);
+public void clearColor(float r, float g, float b, float a);
+public void clearDepth(float d);
+public void clearStencil(int s);
+public void clear(int buf);
+public void deleteFramebuffers(int n, IntBuffer framebuffers);
+public void genFramebuffers(int n, IntBuffer framebuffers);
+public void bindRenderbuffer(int target, int renderbuffer);
+public void deleteRenderbuffers(int n, IntBuffer renderbuffers);
+public void genRenderbuffers(int n, IntBuffer renderbuffers);
+public void renderbufferStorage(int target, int internalFormat, int width, int height);
+public void framebufferRenderbuffer(int target, int attachment, int rbt, int renderbuffer);
+public void framebufferTexture2D(int target, int attachment, int texTarget, int texture, int level);
+public int checkFramebufferStatus(int target);
+public boolean isFramebuffer(int framebuffer);
+public void getFramebufferAttachmentParameteriv(int target, int attachment, int name, IntBuffer params);
+public boolean isRenderbuffer(int renderbuffer);
+public void getRenderbufferParameteriv(int target, int name, IntBuffer params);
+public void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter);
+public void renderbufferStorageMultisample(int target, int samples, int format, int width, int height);
+public void readBuffer(int buf);
+public void drawBuffer(int buf);
+}
diff --git a/core/src/processing/vulkan/PSurfaceVK.java b/core/src/processing/vulkan/PSurfaceVK.java
new file mode 100644
index 0000000000..dc27fefd2e
--- /dev/null
+++ b/core/src/processing/vulkan/PSurfaceVK.java
@@ -0,0 +1,682 @@
+package processing.vulkan;
+
+import java.awt.EventQueue;
+import java.awt.FileDialog;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+
+import static org.lwjgl.glfw.GLFW.GLFW_CLIENT_API;
+import static org.lwjgl.glfw.GLFW.GLFW_CURSOR;
+import static org.lwjgl.glfw.GLFW.GLFW_CURSOR_NORMAL;
+import static org.lwjgl.glfw.GLFW.GLFW_FALSE;
+import static org.lwjgl.glfw.GLFW.GLFW_NO_API;
+import static org.lwjgl.glfw.GLFW.GLFW_RESIZABLE;
+import static org.lwjgl.glfw.GLFW.*;
+import static org.lwjgl.glfw.GLFWVulkan.glfwCreateWindowSurface;
+import static org.lwjgl.system.MemoryStack.stackPush;
+import static org.lwjgl.system.MemoryUtil.NULL;
+import static org.lwjgl.vulkan.VK10.VK_NULL_HANDLE;
+import static org.lwjgl.vulkan.VK10.VK_SUCCESS;
+
+import java.awt.DisplayMode;
+import java.io.File;
+import java.nio.BufferOverflowException;
+import java.nio.LongBuffer;
+import java.util.ArrayList;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.lwjgl.system.MemoryStack;
+import org.lwjgl.vulkan.VkInstance;
+
+import processing.GL2VK.GL2VK;
+import processing.GL2VK.Util;
+import processing.awt.ShimAWT;
+import processing.core.PApplet;
+import processing.core.PConstants;
+import processing.core.PGraphics;
+import processing.core.PImage;
+import processing.core.PSurface;
+import processing.event.KeyEvent;
+import processing.event.MouseEvent;
+import processing.opengl.PGraphicsOpenGL;
+
+// NEXT TODO:
+// Create a function which creates a surface with a specified width and height, puts it into
+// animation thread.
+
+public class PSurfaceVK implements PSurface {
+
+ protected PGraphics graphics;
+
+ protected PApplet sketch;
+ protected int sketchWidth = 0;
+ protected int sketchHeight = 0;
+ private boolean windowCreated = false;
+
+ private Thread drawExceptionHandler;
+ private Object drawExceptionMutex = new Object();
+ protected Throwable drawException;
+
+ private AnimatorTask animationThread;
+ private boolean isStopped = true;
+
+ private PVK pvk;
+
+ public static GL2VK gl2vk = null;
+
+ /////////////////////////////////
+ // GLFW window variables
+ public long glfwwindow;
+ public int glfwwidth = 1200;
+ public int glfwheight = 800;
+ public long glfwsurface;
+ public boolean glfwframebufferResize = false;
+
+ private int glfwMouseX = 0, glfwMouseY = 0;
+ private int glfwButton = 0, glfwAction = 0;
+
+ private static int GLFW_SHIFT = 340;
+ private static int GLFW_ENTER = 257;
+ private static int GLFW_BACKSPACE = 259;
+ private static int GLFW_CTRL = 341;
+ private static int GLFW_ALT = 342;
+
+ // TODO: Make framerate dynamic.
+ class AnimatorTask extends TimerTask {
+ Timer timer;
+ float fps = 60.0f;
+
+ public AnimatorTask(float fps) {
+ super();
+ this.fps = fps;
+ }
+
+ public void start() {
+ final long period = 0 < fps ? (long) (1000.0f / fps) : 1; // 0 -> 1: IllegalArgumentException: Non-positive period
+ timer = new Timer();
+ timer.scheduleAtFixedRate(this, 0, period);
+ }
+
+ long then = 0;
+
+ @Override
+ public void run() {
+// System.out.println("INTERVAL "+(System.nanoTime()-then));
+// Util.beginTmr();
+
+ // We create the window here because glfw window needs to be created in the same
+ // thread as it is run in.
+ if (!windowCreated) {
+ initWindow();
+ }
+
+ if (pvk.shouldClose()) {
+ sketch.exit();
+ }
+//
+ if (!sketch.finished) {
+ pvk.getGL(pvk);
+
+// Util.beginTmr();
+ pvk.beginRecord();
+ pvk.selectNode(0);
+ pvk.enableAutoMode();
+ sketch.handleDraw();
+ pvk.endRecord();
+
+// Util.beginTmr();
+
+// Util.beginTmr();
+ PGraphicsOpenGL.completeFinishedPixelTransfers();
+// Util.endTmr("completeFinishedPixelTransfers");
+ }
+ if (sketch.exitCalled()) {
+ sketch.dispose();
+ sketch.exitActual();
+ pvk.cleanup();
+ }
+// Util.endTmr("end entire cycle");
+// then = System.nanoTime();
+ }
+ }
+
+ public PSurfaceVK(PGraphics graphics) {
+ this.graphics = graphics;
+ this.pvk = (PVK)((PGraphicsVulkan) graphics).pgl;
+ }
+
+ public void initOffscreen(PApplet sketch) {
+ this.sketch = sketch;
+
+ sketchWidth = sketch.sketchWidth();
+ sketchHeight = sketch.sketchHeight();
+ }
+
+ public void initFrame(PApplet sketch) {
+ this.sketch = sketch;
+ sketchWidth = sketch.sketchWidth();
+ sketchHeight = sketch.sketchHeight();
+
+ initIcons();
+ initAnimator();
+ }
+
+ private void initIcons() {
+// IOUtil.ClassResources res;
+// if (PJOGL.icons == null || PJOGL.icons.length == 0) {
+// // Default Processing icons
+// final int[] sizes = { 16, 32, 48, 64, 128, 256, 512 };
+// String[] iconImages = new String[sizes.length];
+// for (int i = 0; i < sizes.length; i++) {
+// iconImages[i] = "/icon/icon-" + sizes[i] + ".png";
+// }
+// res = new ClassResources(iconImages,
+// PApplet.class.getClassLoader(),
+// PApplet.class);
+// } else {
+// // Loading custom icons from user-provided files.
+// String[] iconImages = new String[PJOGL.icons.length];
+// for (int i = 0; i < PJOGL.icons.length; i++) {
+// iconImages[i] = resourceFilename(PJOGL.icons[i]);
+// }
+//
+// res = new ClassResources(iconImages,
+// sketch.getClass().getClassLoader(),
+// sketch.getClass());
+// }
+// NewtFactory.setWindowIcons(res);
+ // TODO: make work for vulkan
+ }
+
+ public void createGLFWSurface(VkInstance instance) {
+
+ try(MemoryStack stack = stackPush()) {
+
+ LongBuffer pSurface = stack.longs(VK_NULL_HANDLE);
+
+ if(glfwCreateWindowSurface(instance, glfwwindow, null, pSurface) != VK_SUCCESS) {
+ throw new RuntimeException("Failed to create window surface");
+ }
+
+ glfwsurface = pSurface.get(0);
+ }
+ }
+
+
+ private static boolean isPCodedKey(int code) {
+ return
+// code == com.jogamp.newt.event.KeyEvent.VK_UP ||
+// code == com.jogamp.newt.event.KeyEvent.VK_DOWN ||
+// code == com.jogamp.newt.event.KeyEvent.VK_LEFT ||
+// code == com.jogamp.newt.event.KeyEvent.VK_RIGHT ||
+ code == GLFW_ALT ||
+ code == GLFW_CTRL ||
+ code == GLFW_SHIFT;
+// code == GLFW_WINDOWS ||
+// (!isHackyKey(code));
+ }
+
+
+ // Why do we need this mapping?
+ // Relevant discussion and links here:
+ // http://forum.jogamp.org/Newt-wrong-keycode-for-key-td4033690.html#a4033697
+ // (I don't think this is a complete solution).
+ private static int mapToPConst(int code) {
+ return switch (code) {
+ case com.jogamp.newt.event.KeyEvent.VK_UP -> PConstants.UP;
+ case com.jogamp.newt.event.KeyEvent.VK_DOWN -> PConstants.DOWN;
+ case com.jogamp.newt.event.KeyEvent.VK_LEFT -> PConstants.LEFT;
+ case com.jogamp.newt.event.KeyEvent.VK_RIGHT -> PConstants.RIGHT;
+ case com.jogamp.newt.event.KeyEvent.VK_ALT -> PConstants.ALT;
+ case com.jogamp.newt.event.KeyEvent.VK_CONTROL -> PConstants.CONTROL;
+ case com.jogamp.newt.event.KeyEvent.VK_SHIFT -> PConstants.SHIFT;
+ case com.jogamp.newt.event.KeyEvent.VK_WINDOWS -> java.awt.event.KeyEvent.VK_META;
+ default -> code;
+ };
+ }
+
+
+ private static boolean isHackyKey(int code) {
+ return (code == GLFW_BACKSPACE ||
+// code == com.jogamp.newt.event.KeyEvent.VK_TAB ||
+ code == GLFW_ENTER
+// code == com.jogamp.newt.event.KeyEvent.VK_ESCAPE ||
+// code == com.jogamp.newt.event.KeyEvent.VK_DELETE
+ );
+ }
+
+
+ private static char hackToChar(int code, char def) {
+ return switch (code) {
+ case com.jogamp.newt.event.KeyEvent.VK_BACK_SPACE -> PConstants.BACKSPACE;
+ case com.jogamp.newt.event.KeyEvent.VK_TAB -> PConstants.TAB;
+ case com.jogamp.newt.event.KeyEvent.VK_ENTER -> PConstants.ENTER;
+ case com.jogamp.newt.event.KeyEvent.VK_ESCAPE -> PConstants.ESC;
+ case com.jogamp.newt.event.KeyEvent.VK_DELETE -> PConstants.DELETE;
+ default -> def;
+ };
+ }
+
+
+ protected void nativeKeyEvent(long millis, int action, int modifiers,
+ int key, int keyCode, boolean isAutoRepeat) {
+ // SHIFT, CTRL, META, and ALT are identical to processing.event.Event
+// int modifiers = nativeEvent.getModifiers();
+// int peModifiers = nativeEvent.getModifiers() &
+// (InputEvent.SHIFT_MASK |
+// InputEvent.CTRL_MASK |
+// InputEvent.META_MASK |
+// InputEvent.ALT_MASK);
+
+
+
+
+ // From http://jogamp.org/deployment/v2.1.0/javadoc/jogl/javadoc/com/jogamp/newt/event/KeyEvent.html
+ // public final short getKeySymbol()
+ // Returns the virtual key symbol reflecting the current keyboard layout.
+ // public final short getKeyCode()
+ // Returns the virtual key code using a fixed mapping to the US keyboard layout.
+ // In contrast to key symbol, key code uses a fixed US keyboard layout and therefore is keyboard layout independent.
+ // E.g. virtual key code VK_Y denotes the same physical key regardless whether keyboard layout QWERTY or QWERTZ is active. The key symbol of the former is VK_Y, where the latter produces VK_Y.
+
+
+ if (!isPCodedKey(key)) {
+ key = Character.toLowerCase(key);
+
+ if (modifiers == GLFW_MOD_SHIFT) {
+ key = Character.toUpperCase(key);
+ }
+
+ KeyEvent ke = new KeyEvent(new Object(), millis,
+ action, modifiers,
+ (char)key,
+ keyCode,
+ isAutoRepeat);
+ sketch.postEvent(ke);
+ }
+
+// if (!isPCodedKey(code, nativeEvent.isPrintableKey()) && !isHackyKey(code)) {
+// if (peAction == KeyEvent.PRESS) {
+// // Create key typed event
+// // TODO: combine dead keys with the following key
+// KeyEvent tke = new KeyEvent(nativeEvent, nativeEvent.getWhen(),
+// KeyEvent.TYPE, modifiers,
+// keyChar,
+// 0,
+// nativeEvent.isAutoRepeat());
+//
+// sketch.postEvent(tke);
+// }
+// }
+ }
+
+
+ private void nativeMouseEvent(long millis, int action, int modifiers,
+ int x, int y, int button, int count) {
+
+
+
+ int peButton = switch (button) {
+ case GLFW_MOUSE_BUTTON_LEFT -> PConstants.LEFT;
+ case GLFW_MOUSE_BUTTON_MIDDLE -> PConstants.CENTER;
+ case GLFW_MOUSE_BUTTON_RIGHT -> PConstants.RIGHT;
+ default -> 0;
+ };
+
+ int peaction = switch (action) {
+ case GLFW_PRESS -> MouseEvent.PRESS;
+ case GLFW_RELEASE -> MouseEvent.RELEASE;
+ case 99 -> MouseEvent.MOVE;
+ default -> 0;
+ };
+
+ int scale = 1;
+// if (PApplet.platform == PConstants.MACOS) {
+// scale = (int) getCurrentPixelScale();
+// } else {
+// scale = (int) getPixelScale();
+// }
+ int sx = x / scale;
+ int sy = y / scale;
+ int mx = sx;
+ int my = sy;
+
+// if (pvk.presentMode()) {
+// mx -= (int)pvk.presentX;
+// my -= (int)pvk.presentY;
+// //noinspection IntegerDivisionInFloatingPointContext
+// if (peAction == KeyEvent.RELEASE &&
+// pvk.insideStopButton(sx, sy - screenRect.height / windowScaleFactor)) {
+// sketch.exit();
+// }
+// if (mx < 0 || sketchWidth < mx || my < 0 || sketchHeight < my) {
+// return;
+// }
+// }
+
+ MouseEvent me = new MouseEvent(new Object(), millis,
+ peaction, modifiers,
+ mx, my,
+ peButton,
+ count);
+
+ sketch.postEvent(me);
+ }
+
+
+
+
+
+ protected void initListeners() {
+ }
+
+ private void initWindow() {
+ if(!glfwInit()) {
+ throw new RuntimeException("Cannot initialize GLFW");
+ }
+
+ glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
+ glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
+
+ String title = "Vulkan";
+
+ glfwwidth = graphics.width;
+ glfwheight = graphics.height;
+
+ glfwwindow = glfwCreateWindow(glfwwidth, glfwheight, title, NULL, NULL);
+
+ if(glfwwindow == NULL) {
+ throw new RuntimeException("Cannot create window");
+ }
+
+ glfwSetFramebufferSizeCallback(glfwwindow, this::framebufferResizeCallback);
+ glfwSetCursorPosCallback(glfwwindow, this::cursorMoveCallback);
+ glfwSetMouseButtonCallback(glfwwindow, this::mouseButtonCallback);
+ glfwSetKeyCallback(glfwwindow, this::keyActionCallback);
+ glfwSetInputMode(glfwwindow, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
+
+
+ if (gl2vk == null) {
+ int nodes = sketch.maxNodes;
+ if (nodes == -1) {
+ int availableProcessors = Runtime.getRuntime().availableProcessors();
+ nodes = availableProcessors;
+ }
+ gl2vk = new GL2VK(this, nodes);
+ pvk.setGL2VK(gl2vk);
+ }
+ windowCreated = true;
+ }
+
+ private void framebufferResizeCallback(long window, int width, int height) {
+ glfwframebufferResize = true;
+ }
+
+ private void cursorMoveCallback(long window, double xpos, double ypos) {
+ glfwMouseX = (int)xpos;
+ glfwMouseY = (int)ypos;
+ glfwAction = 99;
+ nativeMouseEvent(0, glfwAction, 0,
+ glfwMouseX, glfwMouseY, glfwButton, 0);
+ }
+
+ private void mouseButtonCallback(long window, int button, int action, int mod) {
+ glfwButton = button;
+ glfwAction = action;
+ nativeMouseEvent(0, glfwAction, mod,
+ glfwMouseX, glfwMouseY, glfwButton, 0);
+ }
+
+ private void keyActionCallback(long window, int key, int scancode, int action, int mods) {
+// System.out.println((char)scancode)
+// System.out.println(key);
+ nativeKeyEvent(0L, action, mods,
+ (char)key, 0, false);
+ }
+
+
+ private void initAnimator() {
+ if (PApplet.platform == PConstants.WINDOWS) {
+ // Force Windows to keep timer resolution high by creating a dummy
+ // thread that sleeps for a time that is not a multiple of 10 ms.
+ // See section titled "Clocks and Timers on Windows" in this post:
+ // https://web.archive.org/web/20160308031939/https://blogs.oracle.com/dholmes/entry/inside_the_hotspot_vm_clocks
+ Thread highResTimerThread = new Thread(() -> {
+ try {
+ Thread.sleep(Long.MAX_VALUE);
+ } catch (InterruptedException ignore) { }
+ }, "HighResTimerThread");
+ highResTimerThread.setDaemon(true);
+ highResTimerThread.start();
+ }
+
+ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ GraphicsDevice gd = ge.getDefaultScreenDevice();
+ DisplayMode dm = gd.getDisplayMode();
+
+ // Get the refresh rate
+ int refreshRate = dm.getRefreshRate();
+
+ if (refreshRate == DisplayMode.REFRESH_RATE_UNKNOWN) {
+ refreshRate = 60;
+ }
+
+ animationThread = new AnimatorTask(refreshRate);
+
+
+ drawExceptionHandler = new Thread(() -> {
+ synchronized (drawExceptionMutex) {
+ try {
+ while (drawException == null) {
+ drawExceptionMutex.wait();
+ }
+ Throwable cause = drawException.getCause();
+ if (cause instanceof RuntimeException) {
+ throw (RuntimeException) cause;
+ } else if (cause instanceof UnsatisfiedLinkError) {
+ throw new UnsatisfiedLinkError(cause.getMessage());
+ } else if (cause == null) {
+ throw new RuntimeException(drawException.getMessage());
+ } else {
+ throw new RuntimeException(cause);
+ }
+ } catch (InterruptedException ignored) { }
+ }
+ });
+ drawExceptionHandler.start();
+
+ }
+
+ @Override
+ public Object getNative() {
+ // TODO Auto-generated method stub
+ System.out.println("WARNING getNative() not implemented.");
+ return null;
+ }
+
+ @Override
+ public void setTitle(String title) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setResizable(boolean resizable) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setAlwaysOnTop(boolean always) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setIcon(PImage icon) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void placeWindow(int[] location, int[] editorLocation) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void placePresent(int stopColor) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setLocation(int x, int y) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setSize(int width, int height) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setFrameRate(float fps) {
+// System.out.println("SET FRAMERATE "+fps);
+// animationThread.cancel();
+// animationThread = new AnimatorTask(fps);
+// animationThread.start();
+ }
+
+ @Override
+ public void setCursor(int kind) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setCursor(PImage image, int hotspotX, int hotspotY) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void showCursor() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void hideCursor() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public PImage loadImage(String path, Object... args) {
+ // TODO Auto-generated method stub
+ return ShimAWT.loadImage(sketch, path, args);
+ }
+
+ @Override
+ public boolean openLink(String url) {
+ // TODO Auto-generated method stub
+ return ShimAWT.openLink(url);
+ }
+
+ @Override
+ public void selectInput(String prompt, String callbackMethod,
+ File file, Object callbackObject) {
+ EventQueue.invokeLater(() -> {
+ // https://github.com/processing/processing/issues/3831
+ boolean hide = (sketch != null) &&
+ (PApplet.platform == PConstants.WINDOWS);
+ if (hide) setVisible(false);
+
+ ShimAWT.selectImpl(prompt, callbackMethod, file,
+ callbackObject, null, FileDialog.LOAD);
+
+ if (hide) setVisible(true);
+ });
+ }
+
+ @Override
+ public void selectOutput(String prompt, String callbackMethod,
+ File file, Object callbackObject) {
+ EventQueue.invokeLater(() -> {
+ // https://github.com/processing/processing/issues/3831
+ boolean hide = (sketch != null) &&
+ (PApplet.platform == PConstants.WINDOWS);
+ if (hide) setVisible(false);
+
+ ShimAWT.selectImpl(prompt, callbackMethod, file,
+ callbackObject, null, FileDialog.SAVE);
+
+ if (hide) setVisible(true);
+ });
+ }
+
+ @Override
+ public void selectFolder(String prompt, String callbackMethod,
+ File file, Object callbackObject) {
+ EventQueue.invokeLater(() -> {
+ // https://github.com/processing/processing/issues/3831
+ boolean hide = (sketch != null) &&
+ (PApplet.platform == PConstants.WINDOWS);
+ if (hide) setVisible(false);
+
+ ShimAWT.selectFolderImpl(prompt, callbackMethod, file,
+ callbackObject, null);
+
+ if (hide) setVisible(true);
+ });
+ }
+
+ private AtomicBoolean paused = new AtomicBoolean(false);
+
+
+ @Override
+ public void startThread() {
+
+ // OpenGL compatibility:
+ // Window gets resized upon initialisation
+// pvk.resetFBOLayer();
+
+ // Our animation thread here.
+ animationThread.start();
+ isStopped = false;
+ }
+
+ @Override
+ public void pauseThread() {
+ paused.set(true);
+ }
+
+ @Override
+ public void resumeThread() {
+ paused.set(false);
+ }
+
+ @Override
+ public boolean stopThread() {
+ if (animationThread != null) animationThread.cancel();
+ isStopped = true;
+ return true;
+ }
+
+ @Override
+ public boolean isStopped() {
+ return isStopped;
+ }
+
+}
\ No newline at end of file
diff --git a/core/src/processing/vulkan/PVK.java b/core/src/processing/vulkan/PVK.java
new file mode 100644
index 0000000000..80d9c5e851
--- /dev/null
+++ b/core/src/processing/vulkan/PVK.java
@@ -0,0 +1,1940 @@
+package processing.vulkan;
+
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Toolkit;
+import java.nio.Buffer;
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.CharBuffer;
+import java.nio.DoubleBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.nio.LongBuffer;
+import java.nio.ShortBuffer;
+import java.util.HashMap;
+
+import com.jogamp.opengl.GL;
+import com.jogamp.opengl.GL2ES2;
+import com.jogamp.opengl.GL2ES3;
+import com.jogamp.opengl.GL2GL3;
+import com.jogamp.opengl.GL3ES3;
+import com.jogamp.opengl.GLAutoDrawable;
+import com.jogamp.opengl.GLCapabilities;
+import com.jogamp.opengl.GLCapabilitiesImmutable;
+import com.jogamp.opengl.glu.GLU;
+import com.jogamp.opengl.glu.GLUtessellator;
+import com.jogamp.opengl.glu.GLUtessellatorCallbackAdapter;
+
+import processing.GL2VK.GL2VK;
+import processing.GL2VK.TextureBuffer;
+import processing.GL2VK.Util;
+import processing.opengl.PGL;
+import processing.opengl.PGraphicsOpenGL;
+import processing.opengl.PJOGL;
+import processing.opengl.PGL.TessellatorCallback;
+public class PVK extends PGL implements PJOGLInterface {
+ static {
+ FALSE = GL.GL_FALSE;
+ TRUE = GL.GL_TRUE;
+
+ INT = GL2ES2.GL_INT;
+ BYTE = GL.GL_BYTE;
+ SHORT = GL.GL_SHORT;
+ FLOAT = GL.GL_FLOAT;
+ BOOL = GL2ES2.GL_BOOL;
+ UNSIGNED_INT = GL.GL_UNSIGNED_INT;
+ UNSIGNED_BYTE = GL.GL_UNSIGNED_BYTE;
+ UNSIGNED_SHORT = GL.GL_UNSIGNED_SHORT;
+
+ RGB = GL.GL_RGB;
+ RGBA = GL.GL_RGBA;
+ ALPHA = GL.GL_ALPHA;
+ LUMINANCE = GL.GL_LUMINANCE;
+ LUMINANCE_ALPHA = GL.GL_LUMINANCE_ALPHA;
+
+ UNSIGNED_SHORT_5_6_5 = GL.GL_UNSIGNED_SHORT_5_6_5;
+ UNSIGNED_SHORT_4_4_4_4 = GL.GL_UNSIGNED_SHORT_4_4_4_4;
+ UNSIGNED_SHORT_5_5_5_1 = GL.GL_UNSIGNED_SHORT_5_5_5_1;
+
+ RGBA4 = GL.GL_RGBA4;
+ RGB5_A1 = GL.GL_RGB5_A1;
+ RGB565 = GL.GL_RGB565;
+ RGB8 = GL.GL_RGB8;
+ RGBA8 = GL.GL_RGBA8;
+ ALPHA8 = GL.GL_ALPHA8;
+
+ READ_ONLY = GL2ES3.GL_READ_ONLY;
+ WRITE_ONLY = GL.GL_WRITE_ONLY;
+ READ_WRITE = GL2ES3.GL_READ_WRITE;
+
+ TESS_WINDING_NONZERO = GLU.GLU_TESS_WINDING_NONZERO;
+ TESS_WINDING_ODD = GLU.GLU_TESS_WINDING_ODD;
+ TESS_EDGE_FLAG = GLU.GLU_TESS_EDGE_FLAG;
+
+ GENERATE_MIPMAP_HINT = GL.GL_GENERATE_MIPMAP_HINT;
+ FASTEST = GL.GL_FASTEST;
+ NICEST = GL.GL_NICEST;
+ DONT_CARE = GL.GL_DONT_CARE;
+
+ VENDOR = GL.GL_VENDOR;
+ RENDERER = GL.GL_RENDERER;
+ VERSION = GL.GL_VERSION;
+ EXTENSIONS = GL.GL_EXTENSIONS;
+ SHADING_LANGUAGE_VERSION = GL2ES2.GL_SHADING_LANGUAGE_VERSION;
+
+ MAX_SAMPLES = GL.GL_MAX_SAMPLES;
+ SAMPLES = GL.GL_SAMPLES;
+
+ ALIASED_LINE_WIDTH_RANGE = GL.GL_ALIASED_LINE_WIDTH_RANGE;
+ ALIASED_POINT_SIZE_RANGE = GL.GL_ALIASED_POINT_SIZE_RANGE;
+
+ DEPTH_BITS = GL.GL_DEPTH_BITS;
+ STENCIL_BITS = GL.GL_STENCIL_BITS;
+
+ CCW = GL.GL_CCW;
+ CW = GL.GL_CW;
+
+ VIEWPORT = GL.GL_VIEWPORT;
+
+ ARRAY_BUFFER = GL.GL_ARRAY_BUFFER;
+ ELEMENT_ARRAY_BUFFER = GL.GL_ELEMENT_ARRAY_BUFFER;
+ PIXEL_PACK_BUFFER = GL2ES3.GL_PIXEL_PACK_BUFFER;
+
+ MAX_VERTEX_ATTRIBS = GL2ES2.GL_MAX_VERTEX_ATTRIBS;
+
+ STATIC_DRAW = GL.GL_STATIC_DRAW;
+ DYNAMIC_DRAW = GL.GL_DYNAMIC_DRAW;
+ STREAM_DRAW = GL2ES2.GL_STREAM_DRAW;
+ STREAM_READ = GL2ES3.GL_STREAM_READ;
+
+ BUFFER_SIZE = GL.GL_BUFFER_SIZE;
+ BUFFER_USAGE = GL.GL_BUFFER_USAGE;
+
+ POINTS = GL.GL_POINTS;
+ LINE_STRIP = GL.GL_LINE_STRIP;
+ LINE_LOOP = GL.GL_LINE_LOOP;
+ LINES = GL.GL_LINES;
+ TRIANGLE_FAN = GL.GL_TRIANGLE_FAN;
+ TRIANGLE_STRIP = GL.GL_TRIANGLE_STRIP;
+ TRIANGLES = GL.GL_TRIANGLES;
+
+ CULL_FACE = GL.GL_CULL_FACE;
+ FRONT = GL.GL_FRONT;
+ BACK = GL.GL_BACK;
+ FRONT_AND_BACK = GL.GL_FRONT_AND_BACK;
+
+ POLYGON_OFFSET_FILL = GL.GL_POLYGON_OFFSET_FILL;
+
+ UNPACK_ALIGNMENT = GL.GL_UNPACK_ALIGNMENT;
+ PACK_ALIGNMENT = GL.GL_PACK_ALIGNMENT;
+
+ TEXTURE_2D = GL.GL_TEXTURE_2D;
+ TEXTURE_RECTANGLE = GL2GL3.GL_TEXTURE_RECTANGLE;
+
+ TEXTURE_BINDING_2D = GL.GL_TEXTURE_BINDING_2D;
+ TEXTURE_BINDING_RECTANGLE = GL2GL3.GL_TEXTURE_BINDING_RECTANGLE;
+
+ MAX_TEXTURE_SIZE = GL.GL_MAX_TEXTURE_SIZE;
+ TEXTURE_MAX_ANISOTROPY = GL.GL_TEXTURE_MAX_ANISOTROPY_EXT;
+ MAX_TEXTURE_MAX_ANISOTROPY = GL.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT;
+
+ MAX_VERTEX_TEXTURE_IMAGE_UNITS = GL2ES2.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS;
+ MAX_TEXTURE_IMAGE_UNITS = GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS;
+ MAX_COMBINED_TEXTURE_IMAGE_UNITS = GL2ES2.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS;
+
+ NUM_COMPRESSED_TEXTURE_FORMATS = GL.GL_NUM_COMPRESSED_TEXTURE_FORMATS;
+ COMPRESSED_TEXTURE_FORMATS = GL.GL_COMPRESSED_TEXTURE_FORMATS;
+
+ NEAREST = GL.GL_NEAREST;
+ LINEAR = GL.GL_LINEAR;
+ LINEAR_MIPMAP_NEAREST = GL.GL_LINEAR_MIPMAP_NEAREST;
+ LINEAR_MIPMAP_LINEAR = GL.GL_LINEAR_MIPMAP_LINEAR;
+
+ CLAMP_TO_EDGE = GL.GL_CLAMP_TO_EDGE;
+ REPEAT = GL.GL_REPEAT;
+
+ TEXTURE0 = GL.GL_TEXTURE0;
+ TEXTURE1 = GL.GL_TEXTURE1;
+ TEXTURE2 = GL.GL_TEXTURE2;
+ TEXTURE3 = GL.GL_TEXTURE3;
+ TEXTURE_MIN_FILTER = GL.GL_TEXTURE_MIN_FILTER;
+ TEXTURE_MAG_FILTER = GL.GL_TEXTURE_MAG_FILTER;
+ TEXTURE_WRAP_S = GL.GL_TEXTURE_WRAP_S;
+ TEXTURE_WRAP_T = GL.GL_TEXTURE_WRAP_T;
+ TEXTURE_WRAP_R = GL2ES2.GL_TEXTURE_WRAP_R;
+
+ TEXTURE_CUBE_MAP = GL.GL_TEXTURE_CUBE_MAP;
+ TEXTURE_CUBE_MAP_POSITIVE_X = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ TEXTURE_CUBE_MAP_POSITIVE_Y = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y;
+ TEXTURE_CUBE_MAP_POSITIVE_Z = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Z;
+ TEXTURE_CUBE_MAP_NEGATIVE_X = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X;
+ TEXTURE_CUBE_MAP_NEGATIVE_Y = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y;
+ TEXTURE_CUBE_MAP_NEGATIVE_Z = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
+
+ VERTEX_SHADER = GL2ES2.GL_VERTEX_SHADER;
+ FRAGMENT_SHADER = GL2ES2.GL_FRAGMENT_SHADER;
+ INFO_LOG_LENGTH = GL2ES2.GL_INFO_LOG_LENGTH;
+ SHADER_SOURCE_LENGTH = GL2ES2.GL_SHADER_SOURCE_LENGTH;
+ COMPILE_STATUS = GL2ES2.GL_COMPILE_STATUS;
+ LINK_STATUS = GL2ES2.GL_LINK_STATUS;
+ VALIDATE_STATUS = GL2ES2.GL_VALIDATE_STATUS;
+ SHADER_TYPE = GL2ES2.GL_SHADER_TYPE;
+ DELETE_STATUS = GL2ES2.GL_DELETE_STATUS;
+
+ FLOAT_VEC2 = GL2ES2.GL_FLOAT_VEC2;
+ FLOAT_VEC3 = GL2ES2.GL_FLOAT_VEC3;
+ FLOAT_VEC4 = GL2ES2.GL_FLOAT_VEC4;
+ FLOAT_MAT2 = GL2ES2.GL_FLOAT_MAT2;
+ FLOAT_MAT3 = GL2ES2.GL_FLOAT_MAT3;
+ FLOAT_MAT4 = GL2ES2.GL_FLOAT_MAT4;
+ INT_VEC2 = GL2ES2.GL_INT_VEC2;
+ INT_VEC3 = GL2ES2.GL_INT_VEC3;
+ INT_VEC4 = GL2ES2.GL_INT_VEC4;
+ BOOL_VEC2 = GL2ES2.GL_BOOL_VEC2;
+ BOOL_VEC3 = GL2ES2.GL_BOOL_VEC3;
+ BOOL_VEC4 = GL2ES2.GL_BOOL_VEC4;
+ SAMPLER_2D = GL2ES2.GL_SAMPLER_2D;
+ SAMPLER_CUBE = GL2ES2.GL_SAMPLER_CUBE;
+
+ LOW_FLOAT = GL2ES2.GL_LOW_FLOAT;
+ MEDIUM_FLOAT = GL2ES2.GL_MEDIUM_FLOAT;
+ HIGH_FLOAT = GL2ES2.GL_HIGH_FLOAT;
+ LOW_INT = GL2ES2.GL_LOW_INT;
+ MEDIUM_INT = GL2ES2.GL_MEDIUM_INT;
+ HIGH_INT = GL2ES2.GL_HIGH_INT;
+
+ CURRENT_VERTEX_ATTRIB = GL2ES2.GL_CURRENT_VERTEX_ATTRIB;
+
+ VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING;
+ VERTEX_ATTRIB_ARRAY_ENABLED = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_ENABLED;
+ VERTEX_ATTRIB_ARRAY_SIZE = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_SIZE;
+ VERTEX_ATTRIB_ARRAY_STRIDE = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_STRIDE;
+ VERTEX_ATTRIB_ARRAY_TYPE = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_TYPE;
+ VERTEX_ATTRIB_ARRAY_NORMALIZED = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_NORMALIZED;
+ VERTEX_ATTRIB_ARRAY_POINTER = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_POINTER;
+
+ BLEND = GL.GL_BLEND;
+ ONE = GL.GL_ONE;
+ ZERO = GL.GL_ZERO;
+ SRC_ALPHA = GL.GL_SRC_ALPHA;
+ DST_ALPHA = GL.GL_DST_ALPHA;
+ ONE_MINUS_SRC_ALPHA = GL.GL_ONE_MINUS_SRC_ALPHA;
+ ONE_MINUS_DST_COLOR = GL.GL_ONE_MINUS_DST_COLOR;
+ ONE_MINUS_SRC_COLOR = GL.GL_ONE_MINUS_SRC_COLOR;
+ DST_COLOR = GL.GL_DST_COLOR;
+ SRC_COLOR = GL.GL_SRC_COLOR;
+
+ SAMPLE_ALPHA_TO_COVERAGE = GL.GL_SAMPLE_ALPHA_TO_COVERAGE;
+ SAMPLE_COVERAGE = GL.GL_SAMPLE_COVERAGE;
+
+ KEEP = GL.GL_KEEP;
+ REPLACE = GL.GL_REPLACE;
+ INCR = GL.GL_INCR;
+ DECR = GL.GL_DECR;
+ INVERT = GL.GL_INVERT;
+ INCR_WRAP = GL.GL_INCR_WRAP;
+ DECR_WRAP = GL.GL_DECR_WRAP;
+ NEVER = GL.GL_NEVER;
+ ALWAYS = GL.GL_ALWAYS;
+
+ EQUAL = GL.GL_EQUAL;
+ LESS = GL.GL_LESS;
+ LEQUAL = GL.GL_LEQUAL;
+ GREATER = GL.GL_GREATER;
+ GEQUAL = GL.GL_GEQUAL;
+ NOTEQUAL = GL.GL_NOTEQUAL;
+
+ FUNC_ADD = GL.GL_FUNC_ADD;
+ FUNC_MIN = GL2ES3.GL_MIN;
+ FUNC_MAX = GL2ES3.GL_MAX;
+ FUNC_REVERSE_SUBTRACT = GL.GL_FUNC_REVERSE_SUBTRACT;
+ FUNC_SUBTRACT = GL.GL_FUNC_SUBTRACT;
+
+ DITHER = GL.GL_DITHER;
+
+ CONSTANT_COLOR = GL2ES2.GL_CONSTANT_COLOR;
+ CONSTANT_ALPHA = GL2ES2.GL_CONSTANT_ALPHA;
+ ONE_MINUS_CONSTANT_COLOR = GL2ES2.GL_ONE_MINUS_CONSTANT_COLOR;
+ ONE_MINUS_CONSTANT_ALPHA = GL2ES2.GL_ONE_MINUS_CONSTANT_ALPHA;
+ SRC_ALPHA_SATURATE = GL.GL_SRC_ALPHA_SATURATE;
+
+ SCISSOR_TEST = GL.GL_SCISSOR_TEST;
+ STENCIL_TEST = GL.GL_STENCIL_TEST;
+ DEPTH_TEST = GL.GL_DEPTH_TEST;
+ DEPTH_WRITEMASK = GL.GL_DEPTH_WRITEMASK;
+
+ COLOR_BUFFER_BIT = GL.GL_COLOR_BUFFER_BIT;
+ DEPTH_BUFFER_BIT = GL.GL_DEPTH_BUFFER_BIT;
+ STENCIL_BUFFER_BIT = GL.GL_STENCIL_BUFFER_BIT;
+
+ FRAMEBUFFER = GL.GL_FRAMEBUFFER;
+ COLOR_ATTACHMENT0 = GL.GL_COLOR_ATTACHMENT0;
+ COLOR_ATTACHMENT1 = GL2ES2.GL_COLOR_ATTACHMENT1;
+ COLOR_ATTACHMENT2 = GL2ES2.GL_COLOR_ATTACHMENT2;
+ COLOR_ATTACHMENT3 = GL2ES2.GL_COLOR_ATTACHMENT3;
+ RENDERBUFFER = GL.GL_RENDERBUFFER;
+ DEPTH_ATTACHMENT = GL.GL_DEPTH_ATTACHMENT;
+ STENCIL_ATTACHMENT = GL.GL_STENCIL_ATTACHMENT;
+ READ_FRAMEBUFFER = GL.GL_READ_FRAMEBUFFER;
+ DRAW_FRAMEBUFFER = GL.GL_DRAW_FRAMEBUFFER;
+
+ DEPTH24_STENCIL8 = GL.GL_DEPTH24_STENCIL8;
+
+ DEPTH_COMPONENT = GL2ES2.GL_DEPTH_COMPONENT;
+ DEPTH_COMPONENT16 = GL.GL_DEPTH_COMPONENT16;
+ DEPTH_COMPONENT24 = GL.GL_DEPTH_COMPONENT24;
+ DEPTH_COMPONENT32 = GL.GL_DEPTH_COMPONENT32;
+
+ STENCIL_INDEX = GL2ES2.GL_STENCIL_INDEX;
+ STENCIL_INDEX1 = GL.GL_STENCIL_INDEX1;
+ STENCIL_INDEX4 = GL.GL_STENCIL_INDEX4;
+ STENCIL_INDEX8 = GL.GL_STENCIL_INDEX8;
+
+ DEPTH_STENCIL = GL.GL_DEPTH_STENCIL;
+
+ FRAMEBUFFER_COMPLETE = GL.GL_FRAMEBUFFER_COMPLETE;
+ FRAMEBUFFER_UNDEFINED = GL2ES3.GL_FRAMEBUFFER_UNDEFINED;
+ FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
+ FRAMEBUFFER_INCOMPLETE_DIMENSIONS = GL.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
+ FRAMEBUFFER_INCOMPLETE_FORMATS = GL.GL_FRAMEBUFFER_INCOMPLETE_FORMATS;
+ FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER;
+ FRAMEBUFFER_INCOMPLETE_READ_BUFFER = GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER;
+ FRAMEBUFFER_UNSUPPORTED = GL.GL_FRAMEBUFFER_UNSUPPORTED;
+ FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = GL.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE;
+ FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS = GL3ES3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS;
+
+ FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = GL.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE;
+ FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = GL.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME;
+ FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = GL.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL;
+ FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = GL.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE;
+
+ RENDERBUFFER_WIDTH = GL.GL_RENDERBUFFER_WIDTH;
+ RENDERBUFFER_HEIGHT = GL.GL_RENDERBUFFER_HEIGHT;
+ RENDERBUFFER_RED_SIZE = GL.GL_RENDERBUFFER_RED_SIZE;
+ RENDERBUFFER_GREEN_SIZE = GL.GL_RENDERBUFFER_GREEN_SIZE;
+ RENDERBUFFER_BLUE_SIZE = GL.GL_RENDERBUFFER_BLUE_SIZE;
+ RENDERBUFFER_ALPHA_SIZE = GL.GL_RENDERBUFFER_ALPHA_SIZE;
+ RENDERBUFFER_DEPTH_SIZE = GL.GL_RENDERBUFFER_DEPTH_SIZE;
+ RENDERBUFFER_STENCIL_SIZE = GL.GL_RENDERBUFFER_STENCIL_SIZE;
+ RENDERBUFFER_INTERNAL_FORMAT = GL.GL_RENDERBUFFER_INTERNAL_FORMAT;
+
+ MULTISAMPLE = GL.GL_MULTISAMPLE;
+ LINE_SMOOTH = GL.GL_LINE_SMOOTH;
+ POLYGON_SMOOTH = GL2GL3.GL_POLYGON_SMOOTH;
+
+ SYNC_GPU_COMMANDS_COMPLETE = GL3ES3.GL_SYNC_GPU_COMMANDS_COMPLETE;
+ ALREADY_SIGNALED = GL3ES3.GL_ALREADY_SIGNALED;
+ CONDITION_SATISFIED = GL3ES3.GL_CONDITION_SATISFIED;
+ }
+
+ private HashMap glEnumToStrings = new HashMap<>();
+
+ private GL2VK gl2vk;
+
+
+ /** GLU interface **/
+ // For backward compatibility idk
+ // I hope this doesn't require openGL
+ public GLU glu;
+
+ public PVK(PGraphicsOpenGL pg, GL2VK gl2vk) {
+ this.gl2vk = gl2vk;
+ this.graphics = pg;
+ glu = new GLU();
+ }
+
+ public PVK(PGraphicsOpenGL pg) {
+ this.graphics = pg;
+ glu = new GLU();
+ }
+
+ {
+ prepareStrings();
+ if (glColorTex == null) {
+ glColorFbo = allocateIntBuffer(1);
+ glColorTex = allocateIntBuffer(2);
+ glDepthStencil = allocateIntBuffer(1);
+ glDepth = allocateIntBuffer(1);
+ glStencil = allocateIntBuffer(1);
+
+ glMultiFbo = allocateIntBuffer(1);
+ glMultiColor = allocateIntBuffer(1);
+ glMultiDepthStencil = allocateIntBuffer(1);
+ glMultiDepth = allocateIntBuffer(1);
+ glMultiStencil = allocateIntBuffer(1);
+ }
+
+ byteBuffer = allocateByteBuffer(1);
+ intBuffer = allocateIntBuffer(1);
+ viewBuffer = allocateIntBuffer(4);
+ }
+
+ public void setGL2VK(GL2VK gl2vk) {
+ this.gl2vk = gl2vk;
+ }
+
+ public void cleanup() {
+ gl2vk.close();
+ }
+
+ public boolean shouldClose() {
+ return gl2vk.shouldClose();
+ }
+
+ public void beginRecord() {
+ report("beginRecord");
+ gl2vk.beginRecord();
+ }
+
+ public void endRecord() {
+ report("endRecord");
+ gl2vk.endRecord();
+ }
+
+ public void selectNode(int node) {
+ gl2vk.disableAutoMode();
+ gl2vk.selectNode(node);
+ }
+
+ public void enableAutoMode() {
+ gl2vk.enableAutoMode();
+ }
+
+ public int getNodesCount() {
+ return gl2vk.getNodesCount();
+ }
+
+ public void setMaxNodes(int v) {
+ gl2vk.setMaxNodes(v);
+ }
+
+
+ public void bufferMultithreaded(boolean onoff) {
+ gl2vk.bufferMultithreaded(onoff);
+ }
+
+ private void report(String func) {
+// System.out.println(func);
+ }
+
+
+ private void prepareStrings() {
+ // OpenGL strings only really have this
+ // information being loaded into the
+ // hashmap below.
+
+ // TODO: Query vulkan
+ glEnumToStrings.put(VENDOR, "Intel");
+ glEnumToStrings.put(RENDERER, "Intel(R) UHD Graphics 620");
+
+ // For obvious reasons, this needs to be spoofed as some version of OpenGL.
+ // Let's just use the version on my Surface Book 2.
+ glEnumToStrings.put(VERSION, "4.6.0 - Build 30.0.101.1339");
+
+ // TODO:
+ // Convert Vulkan extensions to comparibly equivalent OpenGL
+ // extensions and hope for the best this doesn't break anything.
+ glEnumToStrings.put(EXTENSIONS, "GL_3DFX_texture_compression_FXT1 GL_AMD_depth_clamp_separate GL_AMD_vertex_shader_layer GL_AMD_vertex_shader_viewport_index GL_ARB_ES2_compatibility GL_ARB_ES3_1_compatibility GL_ARB_ES3_compatibility GL_ARB_arrays_of_arrays GL_ARB_base_instance GL_ARB_bindless_texture GL_ARB_blend_func_extended GL_ARB_buffer_storage GL_ARB_cl_event GL_ARB_clear_buffer_object GL_ARB_clear_texture GL_ARB_clip_control GL_ARB_color_buffer_float GL_ARB_compressed_texture_pixel_storage GL_ARB_compute_shader GL_ARB_conditional_render_inverted GL_ARB_conservative_depth GL_ARB_copy_buffer GL_ARB_copy_image GL_ARB_cull_distance GL_ARB_debug_output GL_ARB_depth_buffer_float GL_ARB_depth_clamp GL_ARB_depth_texture GL_ARB_derivative_control GL_ARB_direct_state_access GL_ARB_draw_buffers GL_ARB_draw_buffers_blend GL_ARB_draw_elements_base_vertex GL_ARB_draw_indirect GL_ARB_draw_instanced GL_ARB_enhanced_layouts GL_ARB_explicit_attrib_location GL_ARB_explicit_uniform_location GL_ARB_fragment_coord_conventions GL_ARB_fragment_layer_viewport GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_fragment_shader_interlock GL_ARB_framebuffer_no_attachments GL_ARB_framebuffer_object GL_ARB_framebuffer_sRGB GL_ARB_geometry_shader4 GL_ARB_get_program_binary GL_ARB_get_texture_sub_image GL_ARB_gl_spirv GL_ARB_gpu_shader5 GL_ARB_gpu_shader_fp64 GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_indirect_parameters GL_ARB_instanced_arrays GL_ARB_internalformat_query GL_ARB_internalformat_query2 GL_ARB_invalidate_subdata GL_ARB_map_buffer_alignment GL_ARB_map_buffer_range GL_ARB_multi_bind GL_ARB_multi_draw_indirect GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_occlusion_query2 GL_ARB_pipeline_statistics_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_polygon_offset_clamp GL_ARB_post_depth_coverage GL_ARB_program_interface_query GL_ARB_provoking_vertex GL_ARB_query_buffer_object GL_ARB_robust_buffer_access_behavior GL_ARB_robustness GL_ARB_robustness_isolation GL_ARB_sample_shading GL_ARB_sampler_objects GL_ARB_seamless_cube_map GL_ARB_seamless_cubemap_per_texture GL_ARB_separate_shader_objects GL_ARB_shader_atomic_counter_ops GL_ARB_shader_atomic_counters GL_ARB_shader_bit_encoding GL_ARB_shader_draw_parameters GL_ARB_shader_group_vote GL_ARB_shader_image_load_store GL_ARB_shader_image_size GL_ARB_shader_objects GL_ARB_shader_precision GL_ARB_shader_stencil_export GL_ARB_shader_storage_buffer_object GL_ARB_shader_subroutine GL_ARB_shader_texture_image_samples GL_ARB_shading_language_100 GL_ARB_shading_language_420pack GL_ARB_shading_language_packing GL_ARB_shadow GL_ARB_spirv_extensions GL_ARB_stencil_texturing GL_ARB_sync GL_ARB_tessellation_shader GL_ARB_texture_barrier GL_ARB_texture_border_clamp GL_ARB_texture_buffer_object GL_ARB_texture_buffer_object_rgb32 GL_ARB_texture_buffer_range GL_ARB_texture_compression GL_ARB_texture_compression_bptc GL_ARB_texture_compression_rgtc GL_ARB_texture_cube_map GL_ARB_texture_cube_map_array GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_filter_anisotropic GL_ARB_texture_float GL_ARB_texture_gather GL_ARB_texture_mirror_clamp_to_edge GL_ARB_texture_mirrored_repeat GL_ARB_texture_multisample GL_ARB_texture_non_power_of_two GL_ARB_texture_query_levels GL_ARB_texture_query_lod GL_ARB_texture_rectangle GL_ARB_texture_rg GL_ARB_texture_rgb10_a2ui GL_ARB_texture_stencil8 GL_ARB_texture_storage GL_ARB_texture_storage_multisample GL_ARB_texture_swizzle GL_ARB_texture_view GL_ARB_timer_query GL_ARB_transform_feedback2 GL_ARB_transform_feedback3 GL_ARB_transform_feedback_instanced GL_ARB_transform_feedback_overflow_query GL_ARB_transpose_matrix GL_ARB_uniform_buffer_object GL_ARB_vertex_array_bgra GL_ARB_vertex_array_object GL_ARB_vertex_attrib_64bit GL_ARB_vertex_attrib_binding GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_vertex_type_10f_11f_11f_rev GL_ARB_vertex_type_2_10_10_10_rev GL_ARB_viewport_array GL_ARB_window_pos GL_ATI_separate_stencil GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_clip_volume_hint GL_EXT_compiled_vertex_array GL_EXT_direct_state_access GL_EXT_draw_buffers2 GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_framebuffer_object GL_EXT_geometry_shader4 GL_EXT_gpu_program_parameters GL_EXT_gpu_shader4 GL_EXT_memory_object GL_EXT_memory_object_win32 GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_float GL_EXT_packed_pixels GL_EXT_polygon_offset_clamp GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_semaphore GL_EXT_semaphore_win32 GL_EXT_separate_specular_color GL_EXT_shader_framebuffer_fetch GL_EXT_shader_integer_mix GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture3D GL_EXT_texture_array GL_EXT_texture_compression_s3tc GL_EXT_texture_edge_clamp GL_EXT_texture_env_add GL_EXT_texture_env_combine GL_EXT_texture_filter_anisotropic GL_EXT_texture_integer GL_EXT_texture_lod_bias GL_EXT_texture_rectangle GL_EXT_texture_sRGB GL_EXT_texture_sRGB_decode GL_EXT_texture_shared_exponent GL_EXT_texture_snorm GL_EXT_texture_storage GL_EXT_texture_swizzle GL_EXT_timer_query GL_EXT_transform_feedback GL_IBM_texture_mirrored_repeat GL_INTEL_conservative_rasterization GL_INTEL_fragment_shader_ordering GL_INTEL_framebuffer_CMAA GL_INTEL_map_texture GL_INTEL_multi_rate_fragment_shader GL_INTEL_performance_query GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_KHR_context_flush_control GL_KHR_debug GL_KHR_no_error GL_KHR_shader_subgroup GL_KHR_shader_subgroup_arithmetic GL_KHR_shader_subgroup_ballot GL_KHR_shader_subgroup_basic GL_KHR_shader_subgroup_clustered GL_KHR_shader_subgroup_quad GL_KHR_shader_subgroup_shuffle GL_KHR_shader_subgroup_shuffle_relative GL_KHR_shader_subgroup_vote GL_KHR_texture_compression_astc_hdr GL_KHR_texture_compression_astc_ldr GL_NV_blend_square GL_NV_conditional_render GL_NV_primitive_restart GL_NV_texgen_reflection GL_SGIS_generate_mipmap GL_SGIS_texture_edge_clamp GL_SGIS_texture_lod GL_SUN_multi_draw_arrays GL_WIN_swap_hint WGL_EXT_swap_control");
+
+ // This needs to be spoofed too.
+ glEnumToStrings.put(SHADING_LANGUAGE_VERSION, "4.60 - Build 30.0.101.1339");
+ }
+
+ @Override
+ public Object getNative() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setCaps(GLCapabilities caps) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public GLCapabilitiesImmutable getCaps() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean needSharedObjectSync() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setFps(float fps) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void getGL(GLAutoDrawable glDrawable) {
+// setThread(Thread.currentThread());
+ }
+
+ @Override
+ public boolean threadIsCurrent() {
+ // idc
+ return true;
+ }
+
+ @Override
+ protected int[] getGLVersion() {
+ int[] res = {4, 6, 0};
+ return res;
+ }
+
+ public void init(GLAutoDrawable glDrawable) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void showme(String method, int value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void flush() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void finish() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void hint(int target, int hint) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void enable(int value) {
+ int gl2vkValue = -1;
+ if (value == DEPTH_TEST) {
+ gl2vkValue = GL2VK.DEPTH_TEST;
+ }
+ else if (value == BLEND) {
+ gl2vkValue = GL2VK.BLEND;
+ }
+ else if (value == MULTISAMPLE) {
+ gl2vkValue = GL2VK.MULTISAMPLE;
+ }
+ else if (value == POLYGON_SMOOTH) {
+ gl2vkValue = GL2VK.POLYGON_SMOOTH;
+ }
+ else if (value == CULL_FACE) {
+ gl2vkValue = GL2VK.CULL_FACE;
+ }
+
+ gl2vk.glEnable(gl2vkValue);
+ }
+
+ @Override
+ public void disable(int value) {
+ if (value == DEPTH_TEST) {
+
+ }
+ else if (value == BLEND) {
+
+ }
+ else if (value == MULTISAMPLE) {
+
+ }
+ else if (value == POLYGON_SMOOTH) {
+
+ }
+ else if (value == CULL_FACE) {
+
+ }
+// gl2vk.glDisable(value);
+ }
+
+ @Override
+ public void getBooleanv(int value, IntBuffer data) {
+ // TODO Auto-generated method stub
+ System.out.println("getBooleanv UNKNOWN "+value);
+ }
+
+ @Override
+ // TODO: actual values instead of placeholder values.
+ // Have fun with that.
+ public void getIntegerv(int value, IntBuffer data) {
+// MAX_TEXTURE_SIZE 16384
+// MAX_SAMPLES 16
+// MAX_TEXTURE_MAX_ANISOTROPY 16.0
+
+ if (value == MAX_TEXTURE_SIZE) {
+ data.put(0, 16384);
+ }
+ else if (value == MAX_SAMPLES) {
+ data.put(0, 16);
+ }
+ else if (value == MAX_TEXTURE_IMAGE_UNITS) {
+ data.put(0, 24);
+ }
+ else {
+ System.out.println("getIntegerv UNKNOWN "+value);
+ }
+ }
+
+ @Override
+ public void getFloatv(int value, FloatBuffer data) {
+// MAX_TEXTURE_SIZE 16384
+// MAX_SAMPLES 16
+// MAX_TEXTURE_MAX_ANISOTROPY 16.0
+
+ if (value == MAX_TEXTURE_MAX_ANISOTROPY) {
+ data.put(0, 16f);
+ }
+ else {
+ System.out.println("getFloatv UNKNOWN "+value);
+ }
+ }
+
+ @Override
+ public boolean isEnabled(int value) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @SuppressWarnings("deprecation")
+ private FontMetrics getFontMetrics(Font font) { // ignore
+ report("getFontMetrics");
+ return Toolkit.getDefaultToolkit().getFontMetrics(font);
+ }
+
+
+ @Override
+ protected int getTextWidth(Object font, char[] buffer, int start, int stop) {
+ report("getTextWidth");
+ // maybe should use one of the newer/fancier functions for this?
+ int length = stop - start;
+ FontMetrics metrics = getFontMetrics((Font) font);
+ return metrics.charsWidth(buffer, start, length);
+ }
+
+
+
+ @Override
+ public int getError() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String errorString(int err) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void genBuffers(int n, IntBuffer buffers) {
+ report("genBuffers");
+ gl2vk.glGenBuffers(n, buffers);
+ }
+
+ @Override
+ public void deleteBuffers(int n, IntBuffer buffers) {
+ // TODO: Deletebuffers
+ }
+
+ @Override
+ public void bindBuffer(int target, int buffer) {
+ report("bindBuffer");
+ gl2vk.glBindBuffer(target, buffer);
+ }
+
+
+ public static ByteBuffer convertToByteBuffer(Buffer outputBuffer) {
+ if (outputBuffer == null) return null;
+
+ ByteBuffer byteBuffer = null;
+ if (outputBuffer instanceof ByteBuffer) {
+ System.out.println("ByteBuffer");
+ byteBuffer = (ByteBuffer) outputBuffer;
+ } else if (outputBuffer instanceof CharBuffer) {
+ System.out.println("CharBuffer");
+ byteBuffer = ByteBuffer.allocate(outputBuffer.capacity());
+ byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
+ byteBuffer.asCharBuffer().put((CharBuffer) outputBuffer);
+ } else if (outputBuffer instanceof ShortBuffer) {
+ System.out.println("ShortBuffer");
+ byteBuffer = ByteBuffer.allocate(outputBuffer.capacity() * 2);
+ byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
+ byteBuffer.asShortBuffer().put((ShortBuffer) outputBuffer);
+ } else if (outputBuffer instanceof IntBuffer) {
+ System.out.println("IntBuffer");
+ byteBuffer = ByteBuffer.allocate(outputBuffer.capacity() * 4);
+ byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
+ byteBuffer.asIntBuffer().put((IntBuffer) outputBuffer);
+ } else if (outputBuffer instanceof LongBuffer) {
+ System.out.println("LongBuffer");
+ byteBuffer = ByteBuffer.allocate(outputBuffer.capacity() * 8);
+ byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
+ byteBuffer.asLongBuffer().put((LongBuffer) outputBuffer);
+ } else if (outputBuffer instanceof FloatBuffer) {
+ System.out.println("FloatBuffer");
+ byteBuffer = ByteBuffer.allocate(outputBuffer.capacity() * 4);
+ byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
+ byteBuffer.asFloatBuffer().put((FloatBuffer) outputBuffer);
+ } else if (outputBuffer instanceof DoubleBuffer) {
+ System.out.println("DoubleBuffer");
+ byteBuffer = ByteBuffer.allocate(outputBuffer.capacity() * 8);
+ byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
+ byteBuffer.asDoubleBuffer().put((DoubleBuffer) outputBuffer);
+ }
+ else {
+ System.err.println("Unknown buffer "+outputBuffer.getClass().toString());
+ }
+ return byteBuffer;
+ }
+
+
+
+
+ @Override
+ public void bufferData(int target, int size, Buffer data, int usage) {
+ int gl2vktarget = -1;
+ if (target == ARRAY_BUFFER) {
+ gl2vktarget = GL2VK.GL_VERTEX_BUFFER;
+ }
+ else if (target == ELEMENT_ARRAY_BUFFER) {
+ gl2vktarget = GL2VK.GL_INDEX_BUFFER;
+ }
+ else {
+ System.err.println("bufferData: Dunno what to do with target "+target);
+ }
+
+ int gl2vkusage = -1;
+ if (usage == STREAM_DRAW) {
+ gl2vkusage = GL2VK.STREAM_DRAW;
+ } else if (usage == STREAM_READ) {
+ gl2vkusage = GL2VK.STREAM_READ;
+ } else if (usage == STATIC_DRAW) {
+ gl2vkusage = GL2VK.STATIC_DRAW;
+ } else if (usage == DYNAMIC_DRAW) {
+ gl2vkusage = GL2VK.DYNAMIC_DRAW;
+ }
+ else {
+ System.err.println("bufferData: Unknown usage "+usage);
+ }
+
+
+ report("bufferData");
+
+// ByteBuffer databyte = convertToByteBuffer(data);
+
+
+// System.out.println();
+// if (databyte != null) {
+//// newData = ByteBuffer.allocateDirect(data.capacity());
+//// newData.order(ByteOrder.LITTLE_ENDIAN);
+// databyte.rewind();
+//
+// int max = databyte.capacity();
+// if (32 < max) max = 64;
+//
+// for (int i = 0; i < max; i+=4) {
+// float f = databyte.getFloat();
+//// if (f > 1.0f) f /= 512f;
+// System.out.print(f+" ");
+//// newData.putFloat(f);
+// }
+// databyte.rewind();
+// System.out.println();
+//
+// for (int i = 0; i < max; i+=4) {
+// short x = databyte.getShort();
+//// if (f > 1.0f) f /= 512f;
+// System.out.print(x+" ");
+//// newData.putFloat(f);
+// }
+// databyte.rewind();
+//// newData.rewind();
+// System.out.println();
+
+ if (data instanceof ByteBuffer) {
+ gl2vk.glBufferData(gl2vktarget, size, (ByteBuffer)data, gl2vkusage);
+ } else if (data instanceof CharBuffer) {
+ gl2vk.glBufferData(gl2vktarget, size, (ByteBuffer)data, gl2vkusage);
+ } else if (data instanceof ShortBuffer) {
+ gl2vk.glBufferData(gl2vktarget, size, (ShortBuffer)data, gl2vkusage);
+ } else if (data instanceof IntBuffer) {
+ gl2vk.glBufferData(gl2vktarget, size, (IntBuffer)data, gl2vkusage);
+ } else if (data instanceof LongBuffer) {
+ System.err.println("bufferData: LongBuffer not support");
+ } else if (data instanceof FloatBuffer) {
+ gl2vk.glBufferData(gl2vktarget, size, (FloatBuffer)data, gl2vkusage);
+ } else if (data instanceof DoubleBuffer) {
+ System.err.println("bufferData: DoubleBuffer not support");
+ } else if (data == null) {
+ // Just create the buffer
+ gl2vk.glBufferData(gl2vktarget, size, gl2vkusage);
+ }
+ else {
+ System.err.println("bufferData: Unknown buffer type "+data.getClass().getName());
+ }
+ }
+
+ @Override
+ public void bufferSubData(int target, int offset, int size, Buffer data) {
+// TODO
+ }
+
+ @Override
+ public void isBuffer(int buffer) {
+ // TODO
+
+ }
+
+ // Because we don't have our GL anymore, we need to return an emulated list of
+ // OpenGL's int->names. The emulated list is right here in this class.
+ @Override
+ public String getString(int name) {
+ return glEnumToStrings.get(name);
+ }
+
+ @Override
+ protected boolean isES() {
+ return false;
+ }
+
+ @Override
+ public void getBufferParameteriv(int target, int value, IntBuffer data) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public ByteBuffer mapBuffer(int target, int access) {
+ return gl2vk.glMapBuffer(target, access);
+ }
+
+ @Override
+ public ByteBuffer mapBufferRange(int target, int offset, int length,
+ int access) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void unmapBuffer(int target) {
+ gl2vk.glUnmapBuffer(target);
+
+ }
+
+ @Override
+ public long fenceSync(int condition, int flags) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public void deleteSync(long sync) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int clientWaitSync(long sync, int flags, long timeout) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public void depthRangef(float n, float f) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void viewport(int x, int y, int w, int h) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void vertexAttrib1f(int index, float value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void vertexAttrib2f(int index, float value0, float value1) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void vertexAttrib3f(int index, float value0, float value1,
+ float value2) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void vertexAttrib4f(int index, float value0, float value1,
+ float value2, float value3) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void vertexAttrib1fv(int index, FloatBuffer values) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void vertexAttrib2fv(int index, FloatBuffer values) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void vertexAttrib3fv(int index, FloatBuffer values) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void vertexAttrib4fv(int index, FloatBuffer values) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void vertexAttribPointer(int index, int size, int type,
+ boolean normalized, int stride, int offset) {
+ report("vertexAttribPointer");
+
+ int gl2vktype = 0;
+ if (type == UNSIGNED_BYTE)
+ gl2vktype = GL2VK.GL_UNSIGNED_BYTE;
+ else if (type == FLOAT)
+ gl2vktype = GL2VK.GL_FLOAT;
+ else if (type == UNSIGNED_SHORT)
+ gl2vktype = GL2VK.GL_UNSIGNED_SHORT;
+ else if (type == UNSIGNED_INT)
+ gl2vktype = GL2VK.GL_UNSIGNED_INT;
+ else if (type == INT)
+ gl2vktype = GL2VK.GL_INT;
+ else if (type == BYTE)
+ gl2vktype = GL2VK.GL_BYTE;
+ else if (type == SHORT)
+ gl2vktype = GL2VK.GL_SHORT;
+ else if (type == BOOL)
+ gl2vktype = GL2VK.GL_BOOL;
+ else System.out.println("WARNING Unknown type "+type);
+
+ gl2vk.glVertexAttribPointer(index, size, gl2vktype, normalized, stride, offset);
+
+ }
+
+ @Override
+ public void enableVertexAttribArray(int index) {
+ // Unneeded and unused in gl2vk
+
+ gl2vk.glEnableVertexAttribArray(index);
+ }
+
+ @Override
+ public void disableVertexAttribArray(int index) {
+ // Unneeded and unused in gl2vk
+ gl2vk.glDisableVertexAttribArray(index);
+ }
+
+ @Override
+ public void drawArraysImpl(int mode, int first, int count) {
+ report("drawArrays");
+ gl2vk.glDrawArrays(mode, first, count);
+ }
+
+ @Override
+ public void drawElementsImpl(int mode, int count, int type, int offset) {
+ int gl2vktype = 0;
+ if (type == UNSIGNED_BYTE) {
+ gl2vktype = GL2VK.GL_UNSIGNED_BYTE;
+ }
+ else if (type == UNSIGNED_INT) {
+ gl2vktype = GL2VK.GL_UNSIGNED_INT;
+ }
+ else if (type == UNSIGNED_SHORT) {
+ gl2vktype = GL2VK.GL_UNSIGNED_SHORT;
+ }
+ report("drawElements");
+ gl2vk.glDrawElements(mode, count, gl2vktype, offset);
+ }
+
+ @Override
+ public void lineWidth(float width) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void frontFace(int dir) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void cullFace(int mode) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void polygonOffset(float factor, float units) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void pixelStorei(int pname, int param) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void texImage2D(int target, int level, int internalFormat, int width,
+ int height, int border, int format, int type,
+ Buffer data) {
+ gl2vk.glTexImage2D(target, level, internalFormat, width, height, border, format, type, data);
+ }
+
+ @Override
+ public void copyTexImage2D(int target, int level, int internalFormat, int x,
+ int y, int width, int height, int border) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void texSubImage2D(int target, int level, int xOffset, int yOffset,
+ int width, int height, int format, int type,
+ Buffer data) {
+ report("texSubImage2D");
+
+ // Don't buffer the white 16x16 memory-saver slow-af clear texture.
+ // TODO: automatically detect incoming wave of clear textures, and then
+ // submit vkCmdClearImage command.
+ if (!(width == 16 && height == 16)) {
+ gl2vk.glTexSubImage2D(target, level, xOffset, yOffset, width, height, format, type, data);
+ }
+ }
+
+ @Override
+ public void copyTexSubImage2D(int target, int level, int xOffset, int yOffset,
+ int x, int y, int width, int height) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void compressedTexImage2D(int target, int level, int internalFormat,
+ int width, int height, int border,
+ int imageSize, Buffer data) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void compressedTexSubImage2D(int target, int level, int xOffset,
+ int yOffset, int width, int height,
+ int format, int imageSize, Buffer data) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void texParameteri(int target, int pname, int param) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void texParameterf(int target, int pname, float param) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void texParameteriv(int target, int pname, IntBuffer params) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void texParameterfv(int target, int pname, FloatBuffer params) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void generateMipmap(int target) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void genTextures(int n, IntBuffer textures) {
+ report("genTextures");
+ gl2vk.glGenTextures(n, textures);
+ }
+
+ @Override
+ public void deleteTextures(int n, IntBuffer textures) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void getTexParameteriv(int target, int pname, IntBuffer params) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void getTexParameterfv(int target, int pname, FloatBuffer params) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean isTexture(int texture) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public int createShader(int type) {
+ report("createShader");
+ int gl2vktype = 0;
+ if (type == VERTEX_SHADER) {
+ gl2vktype = GL2VK.GL_VERTEX_SHADER;
+ }
+ else {
+ gl2vktype = GL2VK.GL_FRAGMENT_SHADER;
+ }
+ return gl2vk.glCreateShader(gl2vktype);
+ }
+
+ @Override
+ public void shaderSource(int shader, String source) {
+ report("shaderSource");
+ gl2vk.glShaderSource(shader, source);
+ }
+
+ @Override
+ public void compileShader(int shader) {
+ report("compileShader");
+ gl2vk.glCompileShader(shader);
+ }
+
+ @Override
+ public void releaseShaderCompiler() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteShader(int shader) {
+ report("deleteShader");
+ gl2vk.glDeleteShader(shader);
+
+ }
+
+ @Override
+ public void shaderBinary(int count, IntBuffer shaders, int binaryFormat,
+ Buffer binary, int length) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int createProgram() {
+ report("createProgram");
+ return gl2vk.glCreateProgram();
+ }
+
+ @Override
+ public void attachShader(int program, int shader) {
+ report("attachShader");
+ gl2vk.glAttachShader(program, shader);
+ }
+
+ @Override
+ public void detachShader(int program, int shader) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void linkProgram(int program) {
+ report("linkProgram");
+ gl2vk.glLinkProgram(program);
+ }
+
+ @Override
+ public void useProgram(int program) {
+ report("useProgram");
+ gl2vk.glUseProgram(program);
+ }
+
+ @Override
+ public void deleteProgram(int program) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public String getActiveAttrib(int program, int index, IntBuffer size,
+ IntBuffer type) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getAttribLocation(int program, String name) {
+ report("getAttribLocation");
+ return gl2vk.glGetAttribLocation(program, name);
+ }
+
+ @Override
+ public void bindAttribLocation(int program, int index, String name) {
+
+ }
+
+ @Override
+ public int getUniformLocation(int program, String name) {
+ report("getUniformLocation");
+ return gl2vk.glGetUniformLocation(program, name);
+ }
+
+ @Override
+ public String getActiveUniform(int program, int index, IntBuffer size,
+ IntBuffer type) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void uniform1i(int location, int value) {
+ report("uniform1i");
+ gl2vk.glUniform1i(location, value);
+ }
+
+ @Override
+ public void uniform2i(int location, int value0, int value1) {
+ report("uniform2i");
+ gl2vk.glUniform2i(location, value0, value1);
+ }
+
+ @Override
+ public void uniform3i(int location, int value0, int value1, int value2) {
+ report("uniform3i");
+ gl2vk.glUniform3i(location, value0, value1, value2);
+ }
+
+ @Override
+ public void uniform4i(int location, int value0, int value1, int value2,
+ int value3) {
+ report("uniform4i");
+ gl2vk.glUniform4i(location, value0, value1, value2, value3);
+ }
+
+ @Override
+ public void uniform1f(int location, float value) {
+ report("uniform1f");
+ gl2vk.glUniform1f(location, value);
+
+ }
+
+ @Override
+ public void uniform2f(int location, float value0, float value1) {
+ report("uniform2f");
+ gl2vk.glUniform2f(location, value0, value1);
+
+ }
+
+ @Override
+ public void uniform3f(int location, float value0, float value1,
+ float value2) {
+ report("uniform3f");
+ gl2vk.glUniform3f(location, value0, value1, value2);
+
+ }
+
+ @Override
+ public void uniform4f(int location, float value0, float value1, float value2,
+ float value3) {
+ report("uniform4f");
+ gl2vk.glUniform4f(location, value0, value1, value2, value3);
+
+ }
+
+ @Override
+ public void uniform1iv(int location, int count, IntBuffer v) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void uniform2iv(int location, int count, IntBuffer v) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void uniform3iv(int location, int count, IntBuffer v) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void uniform4iv(int location, int count, IntBuffer v) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void uniform1fv(int location, int count, FloatBuffer v) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void uniform2fv(int location, int count, FloatBuffer v) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void uniform3fv(int location, int count, FloatBuffer v) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void uniform4fv(int location, int count, FloatBuffer v) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void uniformMatrix2fv(int location, int count, boolean transpose,
+ FloatBuffer mat) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void uniformMatrix3fv(int location, int count, boolean transpose,
+ FloatBuffer mat) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void uniformMatrix4fv(int location, int count, boolean transpose,
+ FloatBuffer mat) {
+
+ report("uniformMatrix4fv");
+ gl2vk.glUniformMatrix4fv(location, count, transpose, mat);
+
+// mat.rewind();
+// for (int y = 0; y < 4; y++) {
+// for (int x = 0; x < 4; x++) {
+// System.out.print(" "+mat.get());
+// }
+// System.out.println();
+// }
+//
+// System.out.println();
+//
+// mat.rewind();
+ }
+
+ @Override
+ public void validateProgram(int program) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean isShader(int shader) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ @Override
+ public void getShaderiv(int shader, int pname, IntBuffer params) {
+ report("getShaderiv");
+ int gl2vkpname = 0;
+ if (pname == COMPILE_STATUS) {
+ gl2vkpname = GL2VK.GL_COMPILE_STATUS;
+ }
+ else if (pname == INFO_LOG_LENGTH) {
+ gl2vkpname = GL2VK.GL_INFO_LOG_LENGTH;
+ }
+ gl2vk.glGetShaderiv(shader, gl2vkpname, params);
+ }
+
+ @Override
+ public void getAttachedShaders(int program, int maxCount, IntBuffer count,
+ IntBuffer shaders) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getShaderInfoLog(int shader) {
+ report("getShaderInfoLog");
+ return gl2vk.glGetShaderInfoLog(shader);
+ }
+
+ @Override
+ public String getShaderSource(int shader) {
+ report("getShaderSource");
+ return gl2vk.glGetShaderSource(shader);
+ }
+
+ @Override
+ public void getShaderPrecisionFormat(int shaderType, int precisionType,
+ IntBuffer range, IntBuffer precision) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void getVertexAttribfv(int index, int pname, FloatBuffer params) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void getVertexAttribiv(int index, int pname, IntBuffer params) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void getVertexAttribPointerv(int index, int pname, ByteBuffer data) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void getUniformfv(int program, int location, FloatBuffer params) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void getUniformiv(int program, int location, IntBuffer params) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean isProgram(int program) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void getProgramiv(int program, int pname, IntBuffer params) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getProgramInfoLog(int program) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void scissor(int x, int y, int w, int h) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void sampleCoverage(float value, boolean invert) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void stencilFunc(int func, int ref, int mask) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void stencilFuncSeparate(int face, int func, int ref, int mask) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void stencilOp(int sfail, int dpfail, int dppass) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void stencilOpSeparate(int face, int sfail, int dpfail, int dppass) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void depthFunc(int func) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void blendEquation(int mode) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void blendEquationSeparate(int modeRGB, int modeAlpha) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void blendFunc(int src, int dst) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void blendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha,
+ int dstAlpha) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void blendColor(float red, float green, float blue, float alpha) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void colorMask(boolean r, boolean g, boolean b, boolean a) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void depthMask(boolean mask) {
+ gl2vk.glDepthMask(mask);
+ }
+
+ @Override
+ public void stencilMask(int mask) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void stencilMaskSeparate(int face, int mask) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void clearColor(float r, float g, float b, float a) {
+ // TODO Auto-generated method stub
+ gl2vk.glClearColor(r, g, b, a);
+ }
+
+ @Override
+ public void clearDepth(float d) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void clearStencil(int s) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void clear(int buf) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteFramebuffers(int n, IntBuffer framebuffers) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void genFramebuffers(int n, IntBuffer framebuffers) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void bindRenderbuffer(int target, int renderbuffer) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteRenderbuffers(int n, IntBuffer renderbuffers) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void genRenderbuffers(int n, IntBuffer renderbuffers) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void renderbufferStorage(int target, int internalFormat, int width,
+ int height) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void framebufferRenderbuffer(int target, int attachment, int rbt,
+ int renderbuffer) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void framebufferTexture2D(int target, int attachment, int texTarget,
+ int texture, int level) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int checkFramebufferStatus(int target) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean isFramebuffer(int framebuffer) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void getFramebufferAttachmentParameteriv(int target, int attachment,
+ int name, IntBuffer params) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean isRenderbuffer(int renderbuffer) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void getRenderbufferParameteriv(int target, int name,
+ IntBuffer params) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1,
+ int dstX0, int dstY0, int dstX1, int dstY1,
+ int mask, int filter) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void renderbufferStorageMultisample(int target, int samples,
+ int format, int width,
+ int height) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void readBuffer(int buf) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void drawBuffer(int buf) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void setFrameRate(float fps) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void initSurface(int antialias) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void reinitSurface() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void registerListeners() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected int getDepthBits() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ protected int getStencilBits() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ protected float getPixelScale() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ protected void getGL(PGL pgl) {
+ }
+
+ @Override
+ protected boolean canDraw() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ protected void requestFocus() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void requestDraw() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void swapBuffers() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void initFBOLayer() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected int getGLSLVersion() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ protected String getGLSLVersionSuffix() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ @Override
+ protected Object getDerivedFont(Object font, float size) {
+ report("getDerivedFont");
+ return ((Font) font).deriveFont(size);
+ }
+
+//Tessellator
+
+
+ @Override
+ protected Tessellator createTessellator(TessellatorCallback callback) {
+ return new Tessellator(callback);
+ }
+
+
+ protected static class Tessellator implements PGL.Tessellator {
+ protected GLUtessellator tess;
+ protected TessellatorCallback callback;
+ protected GLUCallback gluCallback;
+
+ public Tessellator(TessellatorCallback callback) {
+ this.callback = callback;
+ tess = GLU.gluNewTess();
+ gluCallback = new GLUCallback();
+
+ GLU.gluTessCallback(tess, GLU.GLU_TESS_BEGIN, gluCallback);
+ GLU.gluTessCallback(tess, GLU.GLU_TESS_END, gluCallback);
+ GLU.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, gluCallback);
+ GLU.gluTessCallback(tess, GLU.GLU_TESS_COMBINE, gluCallback);
+ GLU.gluTessCallback(tess, GLU.GLU_TESS_ERROR, gluCallback);
+ }
+
+ @Override
+ public void setCallback(int flag) {
+ GLU.gluTessCallback(tess, flag, gluCallback);
+ }
+
+ @Override
+ public void setWindingRule(int rule) {
+ setProperty(GLU.GLU_TESS_WINDING_RULE, rule);
+ }
+
+ public void setProperty(int property, int value) {
+ GLU.gluTessProperty(tess, property, value);
+ }
+
+ @Override
+ public void beginPolygon() {
+ beginPolygon(null);
+ }
+
+ @Override
+ public void beginPolygon(Object data) {
+ GLU.gluTessBeginPolygon(tess, data);
+ }
+
+ @Override
+ public void endPolygon() {
+ GLU.gluTessEndPolygon(tess);
+ }
+
+ @Override
+ public void beginContour() {
+ GLU.gluTessBeginContour(tess);
+ }
+
+ @Override
+ public void endContour() {
+ GLU.gluTessEndContour(tess);
+ }
+
+ @Override
+ public void addVertex(double[] v) {
+ addVertex(v, 0, v);
+ }
+
+ @Override
+ public void addVertex(double[] v, int n, Object data) {
+ GLU.gluTessVertex(tess, v, n, data);
+ }
+
+ protected class GLUCallback extends GLUtessellatorCallbackAdapter {
+ @Override
+ public void begin(int type) {
+ callback.begin(type);
+ }
+
+ @Override
+ public void end() {
+ callback.end();
+ }
+
+ @Override
+ public void vertex(Object data) {
+ callback.vertex(data);
+ }
+
+ @Override
+ public void combine(double[] coords, Object[] data,
+ float[] weight, Object[] outData) {
+ callback.combine(coords, data, weight, outData);
+ }
+
+ @Override
+ public void error(int errnum) {
+ callback.error(errnum);
+ }
+ }
+ }
+
+
+ @Override
+ protected String tessError(int err) {
+ return glu.gluErrorString(err);
+ }
+
+ @Override
+ protected FontOutline createFontOutline(char ch, Object font) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void viewportImpl(int x, int y, int w, int h) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void readPixelsImpl(int x, int y, int width, int height, int format,
+ int type, Buffer buffer) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void readPixelsImpl(int x, int y, int width, int height, int format,
+ int type, long offset) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void activeTextureImpl(int texture) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ protected void bindTextureImpl(int target, int texture) {
+ report("bindTextureImpl");
+ gl2vk.glBindTexture(texture);
+ }
+
+ @Override
+ protected void bindFramebufferImpl(int target, int framebuffer) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/core/src/processing/vulkan/PVKGraphics2D.java b/core/src/processing/vulkan/PVKGraphics2D.java
new file mode 100644
index 0000000000..728c6b4bd1
--- /dev/null
+++ b/core/src/processing/vulkan/PVKGraphics2D.java
@@ -0,0 +1,463 @@
+package processing.vulkan;
+
+import processing.core.PGraphics;
+import processing.core.PMatrix3D;
+import processing.core.PShape;
+import processing.core.PShapeSVG;
+import processing.opengl.PGraphicsOpenGL;
+import processing.opengl.PShapeOpenGL;
+
+public class PVKGraphics2D extends PGraphicsVulkan {
+ public PVKGraphics2D() {
+ super();
+ }
+
+ //////////////////////////////////////////////////////////////
+
+ // RENDERER SUPPORT QUERIES
+
+
+ @Override
+ public boolean is2D() {
+ return true;
+ }
+
+
+ @Override
+ public boolean is3D() {
+ return false;
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // HINTS
+
+
+ @Override
+ public void hint(int which) {
+ if (which == ENABLE_STROKE_PERSPECTIVE) {
+ showWarning("Strokes cannot be perspective-corrected in 2D.");
+ return;
+ }
+ super.hint(which);
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // PROJECTION
+
+
+ @Override
+ public void ortho() {
+ showMethodWarning("ortho");
+ }
+
+
+ @Override
+ public void ortho(float left, float right,
+ float bottom, float top) {
+ showMethodWarning("ortho");
+ }
+
+
+ @Override
+ public void ortho(float left, float right,
+ float bottom, float top,
+ float near, float far) {
+ showMethodWarning("ortho");
+ }
+
+
+ @Override
+ public void perspective() {
+ showMethodWarning("perspective");
+ }
+
+
+ @Override
+ public void perspective(float fov, float aspect, float zNear, float zFar) {
+ showMethodWarning("perspective");
+ }
+
+
+ @Override
+ public void frustum(float left, float right, float bottom, float top,
+ float znear, float zfar) {
+ showMethodWarning("frustum");
+ }
+
+
+ @Override
+ protected void defaultPerspective() {
+ super.ortho(0, width, -height, 0, -1, +1);
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // CAMERA
+
+
+ @Override
+ public void beginCamera() {
+ showMethodWarning("beginCamera");
+ }
+
+
+ @Override
+ public void endCamera() {
+ showMethodWarning("endCamera");
+ }
+
+
+ @Override
+ public void camera() {
+ showMethodWarning("camera");
+ }
+
+
+ @Override
+ public void camera(float eyeX, float eyeY, float eyeZ,
+ float centerX, float centerY, float centerZ,
+ float upX, float upY, float upZ) {
+ showMethodWarning("camera");
+ }
+
+
+ @Override
+ protected void defaultCamera() {
+ eyeDist = 1;
+ resetMatrix();
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // MATRIX MORE!
+
+
+ @Override
+ protected void begin2D() {
+ pushProjection();
+ defaultPerspective();
+ pushMatrix();
+ defaultCamera();
+ }
+
+
+ @Override
+ protected void end2D() {
+ popMatrix();
+ popProjection();
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // SHAPE
+
+
+ @Override
+ public void shape(PShape shape) {
+ if (shape.is2D()) {
+ super.shape(shape);
+ } else {
+ showWarning("The shape object is not 2D, cannot be displayed with " +
+ "this renderer");
+ }
+ }
+
+
+ @Override
+ public void shape(PShape shape, float x, float y) {
+ if (shape.is2D()) {
+ super.shape(shape, x, y);
+ } else {
+ showWarning("The shape object is not 2D, cannot be displayed with " +
+ "this renderer");
+ }
+ }
+
+
+ @Override
+ public void shape(PShape shape, float a, float b, float c, float d) {
+ if (shape.is2D()) {
+ super.shape(shape, a, b, c, d);
+ } else {
+ showWarning("The shape object is not 2D, cannot be displayed with " +
+ "this renderer");
+ }
+ }
+
+
+ @Override
+ public void shape(PShape shape, float x, float y, float z) {
+ showDepthWarningXYZ("shape");
+ }
+
+
+ @Override
+ public void shape(PShape shape, float x, float y, float z,
+ float c, float d, float e) {
+ showDepthWarningXYZ("shape");
+ }
+
+
+
+ //////////////////////////////////////////////////////////////
+
+ // SHAPE I/O
+
+
+ static protected boolean isSupportedExtension(String extension) {
+ return extension.equals("svg") || extension.equals("svgz");
+ }
+
+
+ static protected PShape loadShapeImpl(PGraphics pg,
+ String filename, String extension) {
+ if (extension.equals("svg") || extension.equals("svgz")) {
+ PShapeSVG svg = new PShapeSVG(pg.parent.loadXML(filename));
+ return PShapeOpenGL.createShape((PGraphicsOpenGL) pg, svg);
+ }
+ return null;
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // SCREEN TRANSFORMS
+
+
+ @Override
+ public float modelX(float x, float y, float z) {
+ showDepthWarning("modelX");
+ return 0;
+ }
+
+
+ @Override
+ public float modelY(float x, float y, float z) {
+ showDepthWarning("modelY");
+ return 0;
+ }
+
+
+ @Override
+ public float modelZ(float x, float y, float z) {
+ showDepthWarning("modelZ");
+ return 0;
+ }
+
+
+
+ //////////////////////////////////////////////////////////////
+
+ // BEZIER VERTICES
+
+
+ @Override
+ public void bezierVertex(float x2, float y2, float z2,
+ float x3, float y3, float z3,
+ float x4, float y4, float z4) {
+ showDepthWarningXYZ("bezierVertex");
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // QUADRATIC BEZIER VERTICES
+
+
+ @Override
+ public void quadraticVertex(float x2, float y2, float z2,
+ float x4, float y4, float z4) {
+ showDepthWarningXYZ("quadVertex");
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // CURVE VERTICES
+
+
+ @Override
+ public void curveVertex(float x, float y, float z) {
+ showDepthWarningXYZ("curveVertex");
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // BOX
+
+
+ @Override
+ public void box(float w, float h, float d) {
+ showMethodWarning("box");
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // SPHERE
+
+
+ @Override
+ public void sphere(float r) {
+ showMethodWarning("sphere");
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // VERTEX SHAPES
+
+
+ @Override
+ public void vertex(float x, float y, float z) {
+ showDepthWarningXYZ("vertex");
+ }
+
+ @Override
+ public void vertex(float x, float y, float z, float u, float v) {
+ showDepthWarningXYZ("vertex");
+ }
+
+ //////////////////////////////////////////////////////////////
+
+ // MATRIX TRANSFORMATIONS
+
+ @Override
+ public void translate(float tx, float ty, float tz) {
+ showDepthWarningXYZ("translate");
+ }
+
+ @Override
+ public void rotateX(float angle) {
+ showDepthWarning("rotateX");
+ }
+
+ @Override
+ public void rotateY(float angle) {
+ showDepthWarning("rotateY");
+ }
+
+ @Override
+ public void rotateZ(float angle) {
+ showDepthWarning("rotateZ");
+ }
+
+ @Override
+ public void rotate(float angle, float vx, float vy, float vz) {
+ showVariationWarning("rotate");
+ }
+
+ @Override
+ public void applyMatrix(PMatrix3D source) {
+ showVariationWarning("applyMatrix");
+ }
+
+ @Override
+ public void applyMatrix(float n00, float n01, float n02, float n03,
+ float n10, float n11, float n12, float n13,
+ float n20, float n21, float n22, float n23,
+ float n30, float n31, float n32, float n33) {
+ showVariationWarning("applyMatrix");
+ }
+
+ @Override
+ public void scale(float sx, float sy, float sz) {
+ showDepthWarningXYZ("scale");
+ }
+
+ //////////////////////////////////////////////////////////////
+
+ // SCREEN AND MODEL COORDS
+
+ @Override
+ public float screenX(float x, float y, float z) {
+ showDepthWarningXYZ("screenX");
+ return 0;
+ }
+
+ @Override
+ public float screenY(float x, float y, float z) {
+ showDepthWarningXYZ("screenY");
+ return 0;
+ }
+
+ @Override
+ public float screenZ(float x, float y, float z) {
+ showDepthWarningXYZ("screenZ");
+ return 0;
+ }
+
+ @Override
+ public PMatrix3D getMatrix(PMatrix3D target) {
+ showVariationWarning("getMatrix");
+ return target;
+ }
+
+ @Override
+ public void setMatrix(PMatrix3D source) {
+ showVariationWarning("setMatrix");
+ }
+
+ //////////////////////////////////////////////////////////////
+
+ // LIGHTS
+
+ @Override
+ public void lights() {
+ showMethodWarning("lights");
+ }
+
+ @Override
+ public void noLights() {
+ showMethodWarning("noLights");
+ }
+
+ @Override
+ public void ambientLight(float red, float green, float blue) {
+ showMethodWarning("ambientLight");
+ }
+
+ @Override
+ public void ambientLight(float red, float green, float blue,
+ float x, float y, float z) {
+ showMethodWarning("ambientLight");
+ }
+
+ @Override
+ public void directionalLight(float red, float green, float blue,
+ float nx, float ny, float nz) {
+ showMethodWarning("directionalLight");
+ }
+
+ @Override
+ public void pointLight(float red, float green, float blue,
+ float x, float y, float z) {
+ showMethodWarning("pointLight");
+ }
+
+ @Override
+ public void spotLight(float red, float green, float blue,
+ float x, float y, float z,
+ float nx, float ny, float nz,
+ float angle, float concentration) {
+ showMethodWarning("spotLight");
+ }
+
+ @Override
+ public void lightFalloff(float constant, float linear, float quadratic) {
+ showMethodWarning("lightFalloff");
+ }
+
+ @Override
+ public void lightSpecular(float v1, float v2, float v3) {
+ showMethodWarning("lightSpecular");
+ }
+}
diff --git a/core/src/processing/vulkan/PVKGraphics3D.java b/core/src/processing/vulkan/PVKGraphics3D.java
new file mode 100644
index 0000000000..6d4764ee50
--- /dev/null
+++ b/core/src/processing/vulkan/PVKGraphics3D.java
@@ -0,0 +1,123 @@
+package processing.vulkan;
+
+import processing.core.PGraphics;
+import processing.core.PShape;
+import processing.core.PShapeOBJ;
+import processing.opengl.PGraphicsOpenGL;
+import processing.opengl.PShapeOpenGL;
+
+public class PVKGraphics3D extends PGraphicsVulkan {
+ public PVKGraphics3D() {
+ super();
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // RENDERER SUPPORT QUERIES
+
+
+ @Override
+ public boolean is2D() {
+ return false;
+ }
+
+
+ @Override
+ public boolean is3D() {
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // PROJECTION
+
+
+ @Override
+ protected void defaultPerspective() {
+ perspective();
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // CAMERA
+
+
+ @Override
+ protected void defaultCamera() {
+ camera();
+ }
+
+
+ private void dumpStack() {
+// Thread.dumpStack();
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ // MATRIX MORE!
+
+
+ @Override
+ protected void begin2D() {
+ pushProjection();
+ ortho(-width/2f, width/2f, -height/2f, height/2f);
+ pushMatrix();
+
+ // Set camera for 2D rendering, it simply centers at (width/2, height/2)
+ float centerX = width/2f;
+ float centerY = height/2f;
+
+
+ modelview.reset();
+ modelview.translate(-centerX, -centerY);
+ dumpStack();
+
+ modelviewInv.set(modelview);
+ modelviewInv.invert();
+
+ camera.set(modelview);
+ cameraInv.set(modelviewInv);
+
+ updateProjmodelview();
+ }
+
+
+ @Override
+ protected void end2D() {
+ popMatrix();
+ popProjection();
+ }
+
+
+
+ //////////////////////////////////////////////////////////////
+
+ // SHAPE I/O
+
+
+ static protected boolean isSupportedExtension(String extension) {
+ return extension.equals("obj");
+ }
+
+
+ static protected PShape loadShapeImpl(PGraphics pg, String filename,
+ String extension) {
+ PShapeOBJ obj = null;
+
+ if (extension.equals("obj")) {
+ obj = new PShapeOBJ(pg.parent, filename);
+ int prevTextureMode = pg.textureMode;
+ pg.textureMode = NORMAL;
+ PShapeOpenGL p3d = PShapeOpenGL.createShape((PGraphicsOpenGL)pg, obj);
+ pg.textureMode = prevTextureMode;
+ return p3d;
+ }
+ return null;
+ }
+}
+
+
diff --git a/core/src/processing/vulkan/VKFrameBuffer.java b/core/src/processing/vulkan/VKFrameBuffer.java
new file mode 100644
index 0000000000..1f78b5bd5a
--- /dev/null
+++ b/core/src/processing/vulkan/VKFrameBuffer.java
@@ -0,0 +1,43 @@
+package processing.vulkan;
+
+import processing.opengl.FrameBuffer;
+import processing.opengl.PGraphicsOpenGL;
+
+public class VKFrameBuffer extends FrameBuffer {
+
+ private boolean depthTestEnabled = true;
+
+ // TODO: Dummy depth bit.
+
+ public VKFrameBuffer(PGraphicsOpenGL pg) {
+ super(pg);
+ }
+
+
+ public VKFrameBuffer(PGraphicsOpenGL pg, int w, int h, int samples, int colorBuffers,
+ boolean depthTest, boolean screen) {
+ super(pg, w, h, samples, colorBuffers, 0, 0, depthTest, screen);
+ this.depthTestEnabled = depthTest;
+ }
+
+
+ public VKFrameBuffer(PGraphicsOpenGL pg, int w, int h) {
+ super(pg, w, h, 1, 1, 0, 0, false, false);
+ }
+
+
+ public VKFrameBuffer(PGraphicsOpenGL pg, int w, int h, boolean screen) {
+ super(pg, w, h, 1, 1, 0, 0, false, screen);
+ }
+
+ @Override
+ public boolean hasDepthBuffer() {
+ return true;
+ }
+
+ @Override
+ public boolean hasStencilBuffer() {
+ return true;
+ }
+
+}