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

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;
}
}