mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
starting the refactoring of PGL
This commit is contained in:
@@ -2969,6 +2969,7 @@ public class PGL {
|
||||
public static final int VERTEX_ATTRIB_ARRAY_STRIDE = GL2.GL_VERTEX_ATTRIB_ARRAY_STRIDE;
|
||||
public static final int VERTEX_ATTRIB_ARRAY_TYPE = GL2.GL_VERTEX_ATTRIB_ARRAY_TYPE;
|
||||
public static final int VERTEX_ATTRIB_ARRAY_NORMALIZED = GL2.GL_VERTEX_ATTRIB_ARRAY_NORMALIZED;
|
||||
public static final int VERTEX_ATTRIB_ARRAY_POINTER = GL2.GL_VERTEX_ATTRIB_ARRAY_POINTER;
|
||||
|
||||
public static final int BLEND = GL.GL_BLEND;
|
||||
public static final int ONE = GL.GL_ONE;
|
||||
@@ -3226,15 +3227,11 @@ public class PGL {
|
||||
// Reading Pixels
|
||||
|
||||
public void readPixels(int x, int y, int width, int height, int format, int type, Buffer buffer) {
|
||||
boolean needBeginOp = format != STENCIL_INDEX &&
|
||||
format != DEPTH_COMPONENT && format != DEPTH_STENCIL;
|
||||
if (needBeginOp) {
|
||||
PGraphicsOpenGL.pgCurrent.beginPixelsOp(PGraphicsOpenGL.OP_READ);
|
||||
}
|
||||
boolean needEndBegin = format != STENCIL_INDEX &&
|
||||
format != DEPTH_COMPONENT && format != DEPTH_STENCIL;
|
||||
if (needEndBegin) pg.beginReadPixels();
|
||||
readPixelsImpl(x, y, width, height, format, type, buffer);
|
||||
if (needBeginOp) {
|
||||
PGraphicsOpenGL.pgCurrent.endPixelsOp();
|
||||
}
|
||||
if (needEndBegin) pg.endReadPixels();
|
||||
}
|
||||
|
||||
protected void readPixelsImpl(int x, int y, int width, int height, int format, int type, Buffer buffer) {
|
||||
@@ -3477,13 +3474,14 @@ public class PGL {
|
||||
gl2.glDeleteProgram(program);
|
||||
}
|
||||
|
||||
public void getActiveAttrib(int program, int index, int[] size, int[] type, String[] name) {
|
||||
public String glGetActiveAttrib (int program, int index, IntBuffer size, IntBuffer type) {
|
||||
int[] tmp = {0, 0, 0};
|
||||
byte[] namebuf = new byte[1024];
|
||||
gl2.glGetActiveAttrib(program, index, 1024, tmp, 0, tmp, 1, tmp, 2, namebuf, 0);
|
||||
if (size != null && size.length != 0) size[0] = tmp[1];
|
||||
if (type != null && type.length != 0) type[0] = tmp[2];
|
||||
if (name != null && name.length != 0) name[0] = new String(namebuf, 0, tmp[0]);
|
||||
size.put(tmp[1]);
|
||||
type.put(tmp[2]);
|
||||
String name = new String(namebuf, 0, tmp[0]);
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getAttribLocation(int program, String name) {
|
||||
@@ -3498,13 +3496,14 @@ public class PGL {
|
||||
return gl2.glGetUniformLocation(program, name);
|
||||
}
|
||||
|
||||
public void getActiveUniform(int program, int index, int[] size,int[] type, String[] name) {
|
||||
public String getActiveUniform(int program, int index, IntBuffer size, IntBuffer type) {
|
||||
int[] tmp= {0, 0, 0};
|
||||
byte[] namebuf = new byte[1024];
|
||||
gl2.glGetActiveUniform(program, index, 1024, tmp, 0, tmp, 1, tmp, 2, namebuf, 0);
|
||||
if (size != null && size.length != 0) size[0] = tmp[1];
|
||||
if (type != null && type.length != 0) type[0] = tmp[2];
|
||||
if (name != null && name.length != 0) name[0] = new String(namebuf, 0, tmp[0]);
|
||||
size.put(tmp[1]);
|
||||
type.put(tmp[2]);
|
||||
String name = new String(namebuf, 0, tmp[0]);
|
||||
return name;
|
||||
}
|
||||
|
||||
public void uniform1i(int location, int value) {
|
||||
@@ -3628,7 +3627,7 @@ public class PGL {
|
||||
gl2.glGetVertexAttribiv(index, pname, params);
|
||||
}
|
||||
|
||||
public void getVertexAttribPointerv() {
|
||||
public void getVertexAttribPointerv(int index, int pname, ByteBuffer data) {
|
||||
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glGetVertexAttribPointerv()"));
|
||||
}
|
||||
|
||||
|
||||
@@ -532,7 +532,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
public PGraphicsOpenGL() {
|
||||
if (pgl == null) {
|
||||
pgl = new PGL(this);
|
||||
pgl = createPGL(this);
|
||||
}
|
||||
|
||||
if (tessellator == null) {
|
||||
@@ -1699,6 +1699,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
}
|
||||
|
||||
|
||||
// Factory method
|
||||
static public PGL createPGL(PGraphicsOpenGL pg) {
|
||||
return new PGL(pg);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PGL beginPGL() {
|
||||
flush();
|
||||
@@ -1768,6 +1774,13 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
pgl.drawBuffer(currentFramebuffer.getDefaultDrawBuffer());
|
||||
}
|
||||
|
||||
public void beginReadPixels() {
|
||||
pgCurrent.beginPixelsOp(OP_READ);
|
||||
}
|
||||
|
||||
public void endReadPixels() {
|
||||
pgCurrent.endPixelsOp();
|
||||
}
|
||||
|
||||
protected void beginPixelsOp(int op) {
|
||||
FrameBuffer pixfb = null;
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package processing.lwjgl;
|
||||
|
||||
public class PGraphics2D extends processing.opengl.PGraphics2D {
|
||||
|
||||
public PGraphics2D() {
|
||||
pgl = new PGL(this);
|
||||
|
||||
if (tessellator == null) {
|
||||
tessellator = new Tessellator();
|
||||
}
|
||||
|
||||
intBuffer = PGL.allocateIntBuffer(2);
|
||||
floatBuffer = PGL.allocateFloatBuffer(2);
|
||||
viewport = PGL.allocateIntBuffer(4);
|
||||
|
||||
inGeo = newInGeometry(IMMEDIATE);
|
||||
tessGeo = newTessGeometry(IMMEDIATE);
|
||||
texCache = newTexCache();
|
||||
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package processing.lwjgl;
|
||||
|
||||
public class PGraphics3D extends processing.opengl.PGraphics3D {
|
||||
|
||||
public PGraphics3D() {
|
||||
pgl = new PGL(this);
|
||||
|
||||
if (tessellator == null) {
|
||||
tessellator = new Tessellator();
|
||||
}
|
||||
|
||||
intBuffer = PGL.allocateIntBuffer(2);
|
||||
floatBuffer = PGL.allocateFloatBuffer(2);
|
||||
viewport = PGL.allocateIntBuffer(4);
|
||||
|
||||
inGeo = newInGeometry(IMMEDIATE);
|
||||
tessGeo = newTessGeometry(IMMEDIATE);
|
||||
texCache = newTexCache();
|
||||
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
package processing.lwjgl;
|
||||
|
||||
import processing.opengl.PGL;
|
||||
import processing.opengl.PGraphicsOpenGL;
|
||||
|
||||
/**
|
||||
@@ -29,27 +30,8 @@ import processing.opengl.PGraphicsOpenGL;
|
||||
*
|
||||
*/
|
||||
public class PGraphicsLWJGL extends PGraphicsOpenGL {
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// INIT/ALLOCATE/FINISH
|
||||
|
||||
|
||||
public PGraphicsLWJGL() {
|
||||
pgl = new PGL(this);
|
||||
|
||||
if (tessellator == null) {
|
||||
tessellator = new Tessellator();
|
||||
}
|
||||
|
||||
intBuffer = PGL.allocateIntBuffer(2);
|
||||
floatBuffer = PGL.allocateFloatBuffer(2);
|
||||
viewport = PGL.allocateIntBuffer(4);
|
||||
|
||||
inGeo = newInGeometry(IMMEDIATE);
|
||||
tessGeo = newTessGeometry(IMMEDIATE);
|
||||
texCache = newTexCache();
|
||||
|
||||
initialized = false;
|
||||
|
||||
static public PGL createPGL(PGraphicsOpenGL pg) {
|
||||
return new PLWJGL(pg);
|
||||
}
|
||||
}
|
||||
|
||||
+841
-593
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user