Removed PGL.Context subclass

This commit is contained in:
codeanticode
2013-01-16 16:02:18 +00:00
parent 7089582826
commit ac8a2a98a3
7 changed files with 161 additions and 195 deletions
+1 -1
View File
@@ -249,7 +249,7 @@ class FontTexture implements PConstants {
}
if (outdated) {
for (int i = 0; i < textures.length; i++) {
pg.removeTextureObject(textures[i].glName, textures[i].context.id());
pg.removeTextureObject(textures[i].glName, textures[i].context);
textures[i].glName = 0;
}
}
+21 -21
View File
@@ -43,7 +43,7 @@ public class FrameBuffer implements PConstants {
protected PApplet parent;
protected PGraphicsOpenGL pg;
protected PGL pgl;
protected PGL.Context context; // The context that created this framebuffer.
protected int context; // The context that created this framebuffer.
public int glFbo;
public int glDepth;
@@ -151,19 +151,19 @@ public class FrameBuffer implements PConstants {
try {
if (!screenFb) {
if (glFbo != 0) {
pg.finalizeFrameBufferObject(glFbo, context.id());
pg.finalizeFrameBufferObject(glFbo, context);
}
if (glDepth != 0) {
pg.finalizeRenderBufferObject(glDepth, context.id());
pg.finalizeRenderBufferObject(glDepth, context);
}
if (glStencil != 0) {
pg.finalizeRenderBufferObject(glStencil, context.id());
pg.finalizeRenderBufferObject(glStencil, context);
}
if (glMultisample != 0) {
pg.finalizeRenderBufferObject(glMultisample, context.id());
pg.finalizeRenderBufferObject(glMultisample, context);
}
if (glDepthStencil != 0) {
pg.finalizeRenderBufferObject(glDepthStencil, context.id());
pg.finalizeRenderBufferObject(glDepthStencil, context);
}
}
} finally {
@@ -345,7 +345,7 @@ public class FrameBuffer implements PConstants {
glFbo = 0;
} else {
//create the FBO object...
glFbo = pg.createFrameBufferObject(context.id());
glFbo = pg.createFrameBufferObject(context);
// ... and then create the rest of the stuff.
if (multisample) {
@@ -370,23 +370,23 @@ public class FrameBuffer implements PConstants {
if (screenFb) return;
if (glFbo != 0) {
pg.finalizeFrameBufferObject(glFbo, context.id());
pg.finalizeFrameBufferObject(glFbo, context);
glFbo = 0;
}
if (glDepth != 0) {
pg.finalizeRenderBufferObject(glDepth, context.id());
pg.finalizeRenderBufferObject(glDepth, context);
glDepth = 0;
}
if (glStencil != 0) {
pg.finalizeRenderBufferObject(glStencil, context.id());
pg.finalizeRenderBufferObject(glStencil, context);
glStencil = 0;
}
if (glMultisample != 0) {
pg.finalizeRenderBufferObject(glMultisample, context.id());
pg.finalizeRenderBufferObject(glMultisample, context);
glMultisample = 0;
}
if (glDepthStencil != 0) {
pg.finalizeRenderBufferObject(glDepthStencil, context.id());
pg.finalizeRenderBufferObject(glDepthStencil, context);
glDepthStencil = 0;
}
}
@@ -397,11 +397,11 @@ public class FrameBuffer implements PConstants {
boolean outdated = !pgl.contextIsCurrent(context);
if (outdated) {
pg.removeFrameBufferObject(glFbo, context.id());
pg.removeRenderBufferObject(glDepth, context.id());
pg.removeRenderBufferObject(glStencil, context.id());
pg.removeRenderBufferObject(glDepthStencil, context.id());
pg.removeRenderBufferObject(glMultisample, context.id());
pg.removeFrameBufferObject(glFbo, context);
pg.removeRenderBufferObject(glDepth, context);
pg.removeRenderBufferObject(glStencil, context);
pg.removeRenderBufferObject(glDepthStencil, context);
pg.removeRenderBufferObject(glMultisample, context);
glFbo = 0;
glDepth = 0;
@@ -423,7 +423,7 @@ public class FrameBuffer implements PConstants {
pg.pushFramebuffer();
pg.setFramebuffer(this);
glMultisample = pg.createRenderBufferObject(context.id());
glMultisample = pg.createRenderBufferObject(context);
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glMultisample);
pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples,
PGL.RGBA8, width, height);
@@ -444,7 +444,7 @@ public class FrameBuffer implements PConstants {
pg.pushFramebuffer();
pg.setFramebuffer(this);
glDepthStencil = pg.createRenderBufferObject(context.id());
glDepthStencil = pg.createRenderBufferObject(context);
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glDepthStencil);
if (multisample) {
@@ -474,7 +474,7 @@ public class FrameBuffer implements PConstants {
pg.pushFramebuffer();
pg.setFramebuffer(this);
glDepth = pg.createRenderBufferObject(context.id());
glDepth = pg.createRenderBufferObject(context);
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glDepth);
int glConst = PGL.DEPTH_COMPONENT16;
@@ -510,7 +510,7 @@ public class FrameBuffer implements PConstants {
pg.pushFramebuffer();
pg.setFramebuffer(this);
glStencil = pg.createRenderBufferObject(context.id());
glStencil = pg.createRenderBufferObject(context);
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glStencil);
int glConst = PGL.STENCIL_INDEX1;
+11 -41
View File
@@ -516,6 +516,10 @@ public class PGL {
// Initialization, finalization
public PGL() {
}
public PGL(PGraphicsOpenGL pg) {
this.pg = pg;
if (glu == null) {
@@ -1935,48 +1939,13 @@ public class PGL {
// Context interface
protected Context createEmptyContext() {
return new Context();
protected int createEmptyContext() {
return -1;
}
protected Context getCurrentContext() {
return new Context(context);
}
protected class Context {
protected int id;
Context() {
id = -1;
}
Context(GLContext context) {
if (context != null) {
id = context.hashCode();
} else {
id = -1;
}
}
boolean current() {
return equal(context);
}
boolean equal(GLContext context) {
if (id == -1 || context == null) {
// A null context means a still non-created resource,
// so it is considered equal to the argument.
return true;
} else {
return id == context.hashCode();
}
}
int id() {
return id;
}
protected int getCurrentContext() {
return context.hashCode();
}
@@ -2079,8 +2048,8 @@ public class PGL {
// Utility functions
protected boolean contextIsCurrent(Context other) {
return other == null || other.current();
protected boolean contextIsCurrent(int other) {
return other == -1 || other == context.hashCode();
}
@@ -3412,6 +3381,7 @@ public class PGL {
}
}
@Override
public final boolean isStarted() {
stateSync.lock();
try {
+37 -41
View File
@@ -138,21 +138,21 @@ public class PGraphicsOpenGL extends PGraphics {
public int glPolyShininess;
public int glPolyIndex;
protected boolean polyBuffersCreated = false;
protected PGL.Context polyBuffersContext;
protected int polyBuffersContext;
public int glLineVertex;
public int glLineColor;
public int glLineAttrib;
public int glLineIndex;
protected boolean lineBuffersCreated = false;
protected PGL.Context lineBuffersContext;
protected int lineBuffersContext;
public int glPointVertex;
public int glPointColor;
public int glPointAttrib;
public int glPointIndex;
protected boolean pointBuffersCreated = false;
protected PGL.Context pointBuffersContext;
protected int pointBuffersContext;
protected static final int INIT_VERTEX_BUFFER_SIZE = 256;
protected static final int INIT_INDEX_BUFFER_SIZE = 512;
@@ -1198,45 +1198,41 @@ public class PGraphicsOpenGL extends PGraphics {
int sizei = INIT_VERTEX_BUFFER_SIZE * PGL.SIZEOF_INT;
int sizex = INIT_INDEX_BUFFER_SIZE * PGL.SIZEOF_INDEX;
glPolyVertex = createVertexBufferObject(polyBuffersContext.id());
glPolyVertex = createVertexBufferObject(polyBuffersContext);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyVertex);
pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef, null, PGL.STATIC_DRAW);
glPolyColor = createVertexBufferObject(polyBuffersContext.id());
glPolyColor = createVertexBufferObject(polyBuffersContext);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyColor);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW);
glPolyNormal = createVertexBufferObject(polyBuffersContext.id());
glPolyNormal = createVertexBufferObject(polyBuffersContext);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyNormal);
pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef, null, PGL.STATIC_DRAW);
glPolyTexcoord = createVertexBufferObject(polyBuffersContext.id());
glPolyTexcoord = createVertexBufferObject(polyBuffersContext);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyTexcoord);
pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef, null, PGL.STATIC_DRAW);
glPolyAmbient = pgPrimary.createVertexBufferObject(
polyBuffersContext.id());
glPolyAmbient = pgPrimary.createVertexBufferObject(polyBuffersContext);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyAmbient);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW);
glPolySpecular = pgPrimary.createVertexBufferObject(
polyBuffersContext.id());
glPolySpecular = pgPrimary.createVertexBufferObject(polyBuffersContext);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolySpecular);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW);
glPolyEmissive = pgPrimary.createVertexBufferObject(
polyBuffersContext.id());
glPolyEmissive = pgPrimary.createVertexBufferObject(polyBuffersContext);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyEmissive);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW);
glPolyShininess = pgPrimary.createVertexBufferObject(
polyBuffersContext.id());
glPolyShininess = pgPrimary.createVertexBufferObject(polyBuffersContext);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyShininess);
pgl.bufferData(PGL.ARRAY_BUFFER, sizef, null, PGL.STATIC_DRAW);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
glPolyIndex = createVertexBufferObject(polyBuffersContext.id());
glPolyIndex = createVertexBufferObject(polyBuffersContext);
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPolyIndex);
pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, sizex, null, PGL.STATIC_DRAW);
@@ -1319,31 +1315,31 @@ public class PGraphicsOpenGL extends PGraphics {
protected void deletePolyBuffers() {
if (polyBuffersCreated) {
deleteVertexBufferObject(glPolyVertex, polyBuffersContext.id());
deleteVertexBufferObject(glPolyVertex, polyBuffersContext);
glPolyVertex = 0;
deleteVertexBufferObject(glPolyColor, polyBuffersContext.id());
deleteVertexBufferObject(glPolyColor, polyBuffersContext);
glPolyColor = 0;
deleteVertexBufferObject(glPolyNormal, polyBuffersContext.id());
deleteVertexBufferObject(glPolyNormal, polyBuffersContext);
glPolyNormal = 0;
deleteVertexBufferObject(glPolyTexcoord, polyBuffersContext.id());
deleteVertexBufferObject(glPolyTexcoord, polyBuffersContext);
glPolyTexcoord = 0;
deleteVertexBufferObject(glPolyAmbient, polyBuffersContext.id());
deleteVertexBufferObject(glPolyAmbient, polyBuffersContext);
glPolyAmbient = 0;
deleteVertexBufferObject(glPolySpecular, polyBuffersContext.id());
deleteVertexBufferObject(glPolySpecular, polyBuffersContext);
glPolySpecular = 0;
deleteVertexBufferObject(glPolyEmissive, polyBuffersContext.id());
deleteVertexBufferObject(glPolyEmissive, polyBuffersContext);
glPolyEmissive = 0;
deleteVertexBufferObject(glPolyShininess, polyBuffersContext.id());
deleteVertexBufferObject(glPolyShininess, polyBuffersContext);
glPolyShininess = 0;
deleteVertexBufferObject(glPolyIndex, polyBuffersContext.id());
deleteVertexBufferObject(glPolyIndex, polyBuffersContext);
glPolyIndex = 0;
polyBuffersCreated = false;
@@ -1359,22 +1355,22 @@ public class PGraphicsOpenGL extends PGraphics {
int sizei = INIT_VERTEX_BUFFER_SIZE * PGL.SIZEOF_INT;
int sizex = INIT_INDEX_BUFFER_SIZE * PGL.SIZEOF_INDEX;
glLineVertex = createVertexBufferObject(lineBuffersContext.id());
glLineVertex = createVertexBufferObject(lineBuffersContext);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineVertex);
pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef, null, PGL.STATIC_DRAW);
glLineColor = createVertexBufferObject(lineBuffersContext.id());
glLineColor = createVertexBufferObject(lineBuffersContext);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineColor);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW);
glLineAttrib = createVertexBufferObject(lineBuffersContext.id());
glLineAttrib = createVertexBufferObject(lineBuffersContext);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineAttrib);
pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef, null, PGL.STATIC_DRAW);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
glLineIndex = createVertexBufferObject(lineBuffersContext.id());
glLineIndex = createVertexBufferObject(lineBuffersContext);
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glLineIndex);
pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, sizex, null, PGL.STATIC_DRAW);
@@ -1428,16 +1424,16 @@ public class PGraphicsOpenGL extends PGraphics {
protected void deleteLineBuffers() {
if (lineBuffersCreated) {
deleteVertexBufferObject(glLineVertex, lineBuffersContext.id());
deleteVertexBufferObject(glLineVertex, lineBuffersContext);
glLineVertex = 0;
deleteVertexBufferObject(glLineColor, lineBuffersContext.id());
deleteVertexBufferObject(glLineColor, lineBuffersContext);
glLineColor = 0;
deleteVertexBufferObject(glLineAttrib, lineBuffersContext.id());
deleteVertexBufferObject(glLineAttrib, lineBuffersContext);
glLineAttrib = 0;
deleteVertexBufferObject(glLineIndex, lineBuffersContext.id());
deleteVertexBufferObject(glLineIndex, lineBuffersContext);
glLineIndex = 0;
lineBuffersCreated = false;
@@ -1453,21 +1449,21 @@ public class PGraphicsOpenGL extends PGraphics {
int sizei = INIT_VERTEX_BUFFER_SIZE * PGL.SIZEOF_INT;
int sizex = INIT_INDEX_BUFFER_SIZE * PGL.SIZEOF_INDEX;
glPointVertex = createVertexBufferObject(pointBuffersContext.id());
glPointVertex = createVertexBufferObject(pointBuffersContext);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointVertex);
pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef, null, PGL.STATIC_DRAW);
glPointColor = createVertexBufferObject(pointBuffersContext.id());
glPointColor = createVertexBufferObject(pointBuffersContext);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointColor);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW);
glPointAttrib = createVertexBufferObject(pointBuffersContext.id());
glPointAttrib = createVertexBufferObject(pointBuffersContext);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointAttrib);
pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef, null, PGL.STATIC_DRAW);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
glPointIndex = createVertexBufferObject(pointBuffersContext.id());
glPointIndex = createVertexBufferObject(pointBuffersContext);
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPointIndex);
pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, sizex, null, PGL.STATIC_DRAW);
@@ -1521,16 +1517,16 @@ public class PGraphicsOpenGL extends PGraphics {
protected void deletePointBuffers() {
if (pointBuffersCreated) {
deleteVertexBufferObject(glPointVertex, pointBuffersContext.id());
deleteVertexBufferObject(glPointVertex, pointBuffersContext);
glPointVertex = 0;
deleteVertexBufferObject(glPointColor, pointBuffersContext.id());
deleteVertexBufferObject(glPointColor, pointBuffersContext);
glPointColor = 0;
deleteVertexBufferObject(glPointAttrib, pointBuffersContext.id());
deleteVertexBufferObject(glPointAttrib, pointBuffersContext);
glPointAttrib = 0;
deleteVertexBufferObject(glPointIndex, pointBuffersContext.id());
deleteVertexBufferObject(glPointIndex, pointBuffersContext);
glPointIndex = 0;
pointBuffersCreated = false;
+14 -14
View File
@@ -58,7 +58,7 @@ public class PShader {
protected PGraphicsOpenGL pgCurrent;
protected PGL pgl;
protected PGL.Context context; // The context that created this shader.
protected int context; // The context that created this shader.
public int glProgram;
public int glVertex;
@@ -89,7 +89,7 @@ public class PShader {
parent = null;
pgMain = null;
pgl = null;
context = null;
context = pgl.createEmptyContext();
this.vertexURL = null;
this.fragmentURL = null;
@@ -172,13 +172,13 @@ public class PShader {
protected void finalize() throws Throwable {
try {
if (glVertex != 0) {
pgMain.finalizeGLSLVertShaderObject(glVertex, context.id());
pgMain.finalizeGLSLVertShaderObject(glVertex, context);
}
if (glFragment != 0) {
pgMain.finalizeGLSLFragShaderObject(glFragment, context.id());
pgMain.finalizeGLSLFragShaderObject(glFragment, context);
}
if (glProgram != 0) {
pgMain.finalizeGLSLProgramObject(glProgram, context.id());
pgMain.finalizeGLSLProgramObject(glProgram, context);
}
} finally {
super.finalize();
@@ -698,7 +698,7 @@ public class PShader {
protected void init() {
if (glProgram == 0 || contextIsOutdated()) {
context = pgl.getCurrentContext();
glProgram = pgMain.createGLSLProgramObject(context.id());
glProgram = pgMain.createGLSLProgramObject(context);
boolean hasVert = false;
if (vertexFilename != null) {
@@ -761,9 +761,9 @@ public class PShader {
protected boolean contextIsOutdated() {
boolean outdated = !pgl.contextIsCurrent(context);
if (outdated) {
pgMain.removeGLSLProgramObject(glProgram, context.id());
pgMain.removeGLSLVertShaderObject(glVertex, context.id());
pgMain.removeGLSLFragShaderObject(glFragment, context.id());
pgMain.removeGLSLProgramObject(glProgram, context);
pgMain.removeGLSLVertShaderObject(glVertex, context);
pgMain.removeGLSLFragShaderObject(glFragment, context);
glProgram = 0;
glVertex = 0;
@@ -833,7 +833,7 @@ public class PShader {
* @param shaderSource a string containing the shader's code
*/
protected boolean compileVertexShader() {
glVertex = pgMain.createGLSLVertShaderObject(context.id());
glVertex = pgMain.createGLSLVertShaderObject(context);
pgl.shaderSource(glVertex, vertexShaderSource);
pgl.compileShader(glVertex);
@@ -854,7 +854,7 @@ public class PShader {
* @param shaderSource a string containing the shader's code
*/
protected boolean compileFragmentShader() {
glFragment = pgMain.createGLSLFragShaderObject(context.id());
glFragment = pgMain.createGLSLFragShaderObject(context);
pgl.shaderSource(glFragment, fragmentShaderSource);
pgl.compileShader(glFragment);
@@ -883,15 +883,15 @@ public class PShader {
protected void release() {
if (glVertex != 0) {
pgMain.deleteGLSLVertShaderObject(glVertex, context.id());
pgMain.deleteGLSLVertShaderObject(glVertex, context);
glVertex = 0;
}
if (glFragment != 0) {
pgMain.deleteGLSLFragShaderObject(glFragment, context.id());
pgMain.deleteGLSLFragShaderObject(glFragment, context);
glFragment = 0;
}
if (glProgram != 0) {
pgMain.deleteGLSLProgramObject(glProgram, context.id());
pgMain.deleteGLSLProgramObject(glProgram, context);
glProgram = 0;
}
}
+69 -69
View File
@@ -67,7 +67,7 @@ public class PShapeOpenGL extends PShape {
protected PGraphicsOpenGL pg;
protected PGL pgl;
protected PGL.Context context; // The context that created this shape.
protected int context; // The context that created this shape.
protected PShapeOpenGL root;
@@ -418,77 +418,77 @@ public class PShapeOpenGL extends PShape {
protected void finalizePolyBuffers() {
if (glPolyVertex != 0) {
pg.finalizeVertexBufferObject(glPolyVertex, context.id());
pg.finalizeVertexBufferObject(glPolyVertex, context);
}
if (glPolyColor != 0) {
pg.finalizeVertexBufferObject(glPolyColor, context.id());
pg.finalizeVertexBufferObject(glPolyColor, context);
}
if (glPolyNormal != 0) {
pg.finalizeVertexBufferObject(glPolyNormal, context.id());
pg.finalizeVertexBufferObject(glPolyNormal, context);
}
if (glPolyTexcoord != 0) {
pg.finalizeVertexBufferObject(glPolyTexcoord, context.id());
pg.finalizeVertexBufferObject(glPolyTexcoord, context);
}
if (glPolyAmbient != 0) {
pg.finalizeVertexBufferObject(glPolyAmbient, context.id());
pg.finalizeVertexBufferObject(glPolyAmbient, context);
}
if (glPolySpecular != 0) {
pg.finalizeVertexBufferObject(glPolySpecular, context.id());
pg.finalizeVertexBufferObject(glPolySpecular, context);
}
if (glPolyEmissive != 0) {
pg.finalizeVertexBufferObject(glPolyEmissive, context.id());
pg.finalizeVertexBufferObject(glPolyEmissive, context);
}
if (glPolyShininess != 0) {
pg.finalizeVertexBufferObject(glPolyShininess, context.id());
pg.finalizeVertexBufferObject(glPolyShininess, context);
}
if (glPolyIndex != 0) {
pg.finalizeVertexBufferObject(glPolyIndex, context.id());
pg.finalizeVertexBufferObject(glPolyIndex, context);
}
}
protected void finalizeLineBuffers() {
if (glLineVertex != 0) {
pg.finalizeVertexBufferObject(glLineVertex, context.id());
pg.finalizeVertexBufferObject(glLineVertex, context);
}
if (glLineColor != 0) {
pg.finalizeVertexBufferObject(glLineColor, context.id());
pg.finalizeVertexBufferObject(glLineColor, context);
}
if (glLineAttrib != 0) {
pg.finalizeVertexBufferObject(glLineAttrib, context.id());
pg.finalizeVertexBufferObject(glLineAttrib, context);
}
if (glLineIndex != 0) {
pg.finalizeVertexBufferObject(glLineIndex, context.id());
pg.finalizeVertexBufferObject(glLineIndex, context);
}
}
protected void finalizePointBuffers() {
if (glPointVertex != 0) {
pg.finalizeVertexBufferObject(glPointVertex, context.id());
pg.finalizeVertexBufferObject(glPointVertex, context);
}
if (glPointColor != 0) {
pg.finalizeVertexBufferObject(glPointColor, context.id());
pg.finalizeVertexBufferObject(glPointColor, context);
}
if (glPointAttrib != 0) {
pg.finalizeVertexBufferObject(glPointAttrib, context.id());
pg.finalizeVertexBufferObject(glPointAttrib, context);
}
if (glPointIndex != 0) {
pg.finalizeVertexBufferObject(glPointIndex, context.id());
pg.finalizeVertexBufferObject(glPointIndex, context);
}
}
@@ -3998,50 +3998,50 @@ public class PShapeOpenGL extends PShape {
int sizei = size * PGL.SIZEOF_INT;
tessGeo.updatePolyVerticesBuffer();
glPolyVertex = pg.createVertexBufferObject(context.id());
glPolyVertex = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyVertex);
pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef,
tessGeo.polyVerticesBuffer,
PGL.STATIC_DRAW);
tessGeo.updatePolyColorsBuffer();
glPolyColor = pg.createVertexBufferObject(context.id());
glPolyColor = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyColor);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
tessGeo.polyColorsBuffer, PGL.STATIC_DRAW);
tessGeo.updatePolyNormalsBuffer();
glPolyNormal = pg.createVertexBufferObject(context.id());
glPolyNormal = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyNormal);
pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef,
tessGeo.polyNormalsBuffer, PGL.STATIC_DRAW);
tessGeo.updatePolyTexcoordsBuffer();
glPolyTexcoord = pg.createVertexBufferObject(context.id());
glPolyTexcoord = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyTexcoord);
pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef,
tessGeo.polyTexcoordsBuffer, PGL.STATIC_DRAW);
tessGeo.updatePolyAmbientBuffer();
glPolyAmbient = pg.createVertexBufferObject(context.id());
glPolyAmbient = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyAmbient);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
tessGeo.polyAmbientBuffer, PGL.STATIC_DRAW);
tessGeo.updatePolySpecularBuffer();
glPolySpecular = pg.createVertexBufferObject(context.id());
glPolySpecular = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolySpecular);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
tessGeo.polySpecularBuffer, PGL.STATIC_DRAW);
tessGeo.updatePolyEmissiveBuffer();
glPolyEmissive = pg.createVertexBufferObject(context.id());
glPolyEmissive = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyEmissive);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
tessGeo.polyEmissiveBuffer, PGL.STATIC_DRAW);
tessGeo.updatePolyShininessBuffer();
glPolyShininess = pg.createVertexBufferObject(context.id());
glPolyShininess = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyShininess);
pgl.bufferData(PGL.ARRAY_BUFFER, sizef,
tessGeo.polyShininessBuffer, PGL.STATIC_DRAW);
@@ -4049,7 +4049,7 @@ public class PShapeOpenGL extends PShape {
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
tessGeo.updatePolyIndicesBuffer();
glPolyIndex = pg.createVertexBufferObject(context.id());
glPolyIndex = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPolyIndex);
pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER,
tessGeo.polyIndexCount * PGL.SIZEOF_INDEX,
@@ -4065,19 +4065,19 @@ public class PShapeOpenGL extends PShape {
int sizei = size * PGL.SIZEOF_INT;
tessGeo.updateLineVerticesBuffer();
glLineVertex = pg.createVertexBufferObject(context.id());
glLineVertex = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineVertex);
pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef,
tessGeo.lineVerticesBuffer, PGL.STATIC_DRAW);
tessGeo.updateLineColorsBuffer();
glLineColor = pg.createVertexBufferObject(context.id());
glLineColor = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineColor);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
tessGeo.lineColorsBuffer, PGL.STATIC_DRAW);
tessGeo.updateLineAttribsBuffer();
glLineAttrib = pg.createVertexBufferObject(context.id());
glLineAttrib = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineAttrib);
pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef,
tessGeo.lineAttribsBuffer, PGL.STATIC_DRAW);
@@ -4085,7 +4085,7 @@ public class PShapeOpenGL extends PShape {
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
tessGeo.updateLineIndicesBuffer();
glLineIndex = pg.createVertexBufferObject(context.id());
glLineIndex = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glLineIndex);
pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER,
tessGeo.lineIndexCount * PGL.SIZEOF_INDEX,
@@ -4101,19 +4101,19 @@ public class PShapeOpenGL extends PShape {
int sizei = size * PGL.SIZEOF_INT;
tessGeo.updatePointVerticesBuffer();
glPointVertex = pg.createVertexBufferObject(context.id());
glPointVertex = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointVertex);
pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef,
tessGeo.pointVerticesBuffer, PGL.STATIC_DRAW);
tessGeo.updatePointColorsBuffer();
glPointColor = pg.createVertexBufferObject(context.id());
glPointColor = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointColor);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
tessGeo.pointColorsBuffer, PGL.STATIC_DRAW);
tessGeo.updatePointAttribsBuffer();
glPointAttrib = pg.createVertexBufferObject(context.id());
glPointAttrib = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointAttrib);
pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef,
tessGeo.pointAttribsBuffer, PGL.STATIC_DRAW);
@@ -4121,7 +4121,7 @@ public class PShapeOpenGL extends PShape {
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
tessGeo.updatePointIndicesBuffer();
glPointIndex = pg.createVertexBufferObject(context.id());
glPointIndex = pg.createVertexBufferObject(context);
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPointIndex);
pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER,
tessGeo.pointIndexCount * PGL.SIZEOF_INDEX,
@@ -4138,25 +4138,25 @@ public class PShapeOpenGL extends PShape {
// doesn't get deleted by OpenGL. The VBOs were already
// automatically disposed when the old context was
// destroyed.
pg.removeVertexBufferObject(glPolyVertex, context.id());
pg.removeVertexBufferObject(glPolyColor, context.id());
pg.removeVertexBufferObject(glPolyNormal, context.id());
pg.removeVertexBufferObject(glPolyTexcoord, context.id());
pg.removeVertexBufferObject(glPolyAmbient, context.id());
pg.removeVertexBufferObject(glPolySpecular, context.id());
pg.removeVertexBufferObject(glPolyEmissive, context.id());
pg.removeVertexBufferObject(glPolyShininess, context.id());
pg.removeVertexBufferObject(glPolyIndex, context.id());
pg.removeVertexBufferObject(glPolyVertex, context);
pg.removeVertexBufferObject(glPolyColor, context);
pg.removeVertexBufferObject(glPolyNormal, context);
pg.removeVertexBufferObject(glPolyTexcoord, context);
pg.removeVertexBufferObject(glPolyAmbient, context);
pg.removeVertexBufferObject(glPolySpecular, context);
pg.removeVertexBufferObject(glPolyEmissive, context);
pg.removeVertexBufferObject(glPolyShininess, context);
pg.removeVertexBufferObject(glPolyIndex, context);
pg.removeVertexBufferObject(glLineVertex, context.id());
pg.removeVertexBufferObject(glLineColor, context.id());
pg.removeVertexBufferObject(glLineAttrib, context.id());
pg.removeVertexBufferObject(glLineIndex, context.id());
pg.removeVertexBufferObject(glLineVertex, context);
pg.removeVertexBufferObject(glLineColor, context);
pg.removeVertexBufferObject(glLineAttrib, context);
pg.removeVertexBufferObject(glLineIndex, context);
pg.removeVertexBufferObject(glPointVertex, context.id());
pg.removeVertexBufferObject(glPointColor, context.id());
pg.removeVertexBufferObject(glPointAttrib, context.id());
pg.removeVertexBufferObject(glPointIndex, context.id());
pg.removeVertexBufferObject(glPointVertex, context);
pg.removeVertexBufferObject(glPointColor, context);
pg.removeVertexBufferObject(glPointAttrib, context);
pg.removeVertexBufferObject(glPointIndex, context);
// The OpenGL resources have been already deleted
// when the context changed. We only need to zero
@@ -4202,47 +4202,47 @@ public class PShapeOpenGL extends PShape {
protected void deletePolyBuffers() {
if (glPolyVertex != 0) {
pg.deleteVertexBufferObject(glPolyVertex, context.id());
pg.deleteVertexBufferObject(glPolyVertex, context);
glPolyVertex = 0;
}
if (glPolyColor != 0) {
pg.deleteVertexBufferObject(glPolyColor, context.id());
pg.deleteVertexBufferObject(glPolyColor, context);
glPolyColor = 0;
}
if (glPolyNormal != 0) {
pg.deleteVertexBufferObject(glPolyNormal, context.id());
pg.deleteVertexBufferObject(glPolyNormal, context);
glPolyNormal = 0;
}
if (glPolyTexcoord != 0) {
pg.deleteVertexBufferObject(glPolyTexcoord, context.id());
pg.deleteVertexBufferObject(glPolyTexcoord, context);
glPolyTexcoord = 0;
}
if (glPolyAmbient != 0) {
pg.deleteVertexBufferObject(glPolyAmbient, context.id());
pg.deleteVertexBufferObject(glPolyAmbient, context);
glPolyAmbient = 0;
}
if (glPolySpecular != 0) {
pg.deleteVertexBufferObject(glPolySpecular, context.id());
pg.deleteVertexBufferObject(glPolySpecular, context);
glPolySpecular = 0;
}
if (glPolyEmissive != 0) {
pg.deleteVertexBufferObject(glPolyEmissive, context.id());
pg.deleteVertexBufferObject(glPolyEmissive, context);
glPolyEmissive = 0;
}
if (glPolyShininess != 0) {
pg.deleteVertexBufferObject(glPolyShininess, context.id());
pg.deleteVertexBufferObject(glPolyShininess, context);
glPolyShininess = 0;
}
if (glPolyIndex != 0) {
pg.deleteVertexBufferObject(glPolyIndex, context.id());
pg.deleteVertexBufferObject(glPolyIndex, context);
glPolyIndex = 0;
}
}
@@ -4250,22 +4250,22 @@ public class PShapeOpenGL extends PShape {
protected void deleteLineBuffers() {
if (glLineVertex != 0) {
pg.deleteVertexBufferObject(glLineVertex, context.id());
pg.deleteVertexBufferObject(glLineVertex, context);
glLineVertex = 0;
}
if (glLineColor != 0) {
pg.deleteVertexBufferObject(glLineColor, context.id());
pg.deleteVertexBufferObject(glLineColor, context);
glLineColor = 0;
}
if (glLineAttrib != 0) {
pg.deleteVertexBufferObject(glLineAttrib, context.id());
pg.deleteVertexBufferObject(glLineAttrib, context);
glLineAttrib = 0;
}
if (glLineIndex != 0) {
pg.deleteVertexBufferObject(glLineIndex, context.id());
pg.deleteVertexBufferObject(glLineIndex, context);
glLineIndex = 0;
}
}
@@ -4273,22 +4273,22 @@ public class PShapeOpenGL extends PShape {
protected void deletePointBuffers() {
if (glPointVertex != 0) {
pg.deleteVertexBufferObject(glPointVertex, context.id());
pg.deleteVertexBufferObject(glPointVertex, context);
glPointVertex = 0;
}
if (glPointColor != 0) {
pg.deleteVertexBufferObject(glPointColor, context.id());
pg.deleteVertexBufferObject(glPointColor, context);
glPointColor = 0;
}
if (glPointAttrib != 0) {
pg.deleteVertexBufferObject(glPointAttrib, context.id());
pg.deleteVertexBufferObject(glPointAttrib, context);
glPointAttrib = 0;
}
if (glPointIndex != 0) {
pg.deleteVertexBufferObject(glPointIndex, context.id());
pg.deleteVertexBufferObject(glPointIndex, context);
glPointIndex = 0;
}
}
+8 -8
View File
@@ -78,10 +78,10 @@ public class Texture implements PConstants {
public int glWidth;
public int glHeight;
protected PApplet parent; // The Processing applet
protected PGraphicsOpenGL pg; // The main renderer
protected PGL pgl; // The interface between Processing and OpenGL.
protected PGL.Context context; // The context that created this texture.
protected PApplet parent; // The Processing applet
protected PGraphicsOpenGL pg; // The main renderer
protected PGL pgl; // The interface between Processing and OpenGL.
protected int context; // The context that created this texture.
protected PGraphicsOpenGL pgDraw; // The main renderer is the color buffer of.
protected boolean usingMipmaps;
@@ -162,7 +162,7 @@ public class Texture implements PConstants {
protected void finalize() throws Throwable {
try {
if (glName != 0) {
pg.finalizeTextureObject(glName, context.id());
pg.finalizeTextureObject(glName, context);
}
} finally {
super.finalize();
@@ -1193,7 +1193,7 @@ public class Texture implements PConstants {
}
context = pgl.getCurrentContext();
glName = pg.createTextureObject(context.id());
glName = pg.createTextureObject(context);
pgl.bindTexture(glTarget, glName);
pgl.texParameteri(glTarget, PGL.TEXTURE_MIN_FILTER, glMinFilter);
@@ -1228,7 +1228,7 @@ public class Texture implements PConstants {
*/
protected void release() {
if (glName != 0) {
pg.finalizeTextureObject(glName, context.id());
pg.finalizeTextureObject(glName, context);
glName = 0;
}
}
@@ -1240,7 +1240,7 @@ public class Texture implements PConstants {
// Removing the texture object from the renderer's list so it
// doesn't get deleted by OpenGL. The texture object was
// automatically disposed when the old context was destroyed.
pg.removeTextureObject(glName, context.id());
pg.removeTextureObject(glName, context);
// And then set the id to zero, so it doesn't try to be
// deleted when the object's finalizer is invoked by the GC.