Constants for max lights, tess vertices and indices moved to PGL

This commit is contained in:
codeanticode
2012-01-24 06:07:25 +00:00
parent 19ab49c297
commit 85360acebf
4 changed files with 100 additions and 96 deletions

View File

@@ -88,6 +88,15 @@ public class PGL {
/** Size of a float (in bytes). */
static final int SIZEOF_FLOAT = Float.SIZE / 8;
/** Maximum lights by default is 8, the minimum defined by OpenGL. */
public static final int MAX_LIGHTS = 8;
/** Maximum number of tessellated vertices. */
public static final int MAX_TESS_VERTICES = 100000;
/** Maximum number of indices */
public static final int MAX_TESS_INDICES = 3 * 100000;
public static final int LESS = GL.GL_LESS;
public static final int LESS_OR_EQUAL = GL.GL_LEQUAL;
public static final int COUNTER_CLOCKWISE = GL.GL_CCW;

View File

@@ -174,11 +174,6 @@ public class PGraphicsOpenGL extends PGraphics {
// ........................................................
// Lights:
/**
* Maximum lights by default is 8, the minimum defined by OpenGL.
*/
public static final int MAX_LIGHTS = 8;
public boolean lights;
public int lightCount = 0;
@@ -370,9 +365,6 @@ public class PGraphicsOpenGL extends PGraphics {
public static final int MIN_ARRAYCOPY_SIZE = 2;
public static final int MAX_TESS_VERTICES = 1000000;
public static final int MAX_TESS_INDICES = 3000000;
public static final int DEFAULT_IN_VERTICES = 64;
public static final int DEFAULT_IN_EDGES = 128;
public static final int DEFAULT_IN_TEXTURES = 64;
@@ -498,17 +490,17 @@ public class PGraphicsOpenGL extends PGraphics {
}
if (!lightsAllocated) {
lightType = new int[MAX_LIGHTS];
lightPosition = new float[MAX_LIGHTS][4];
lightNormal = new float[MAX_LIGHTS][4];
lightDiffuse = new float[MAX_LIGHTS][4];
lightSpecular = new float[MAX_LIGHTS][4];
lightFalloffConstant = new float[MAX_LIGHTS];
lightFalloffLinear = new float[MAX_LIGHTS];
lightFalloffQuadratic = new float[MAX_LIGHTS];
lightSpotAngle = new float[MAX_LIGHTS];
lightSpotAngleCos = new float[MAX_LIGHTS];
lightSpotConcentration = new float[MAX_LIGHTS];
lightType = new int[PGL.MAX_LIGHTS];
lightPosition = new float[PGL.MAX_LIGHTS][4];
lightNormal = new float[PGL.MAX_LIGHTS][4];
lightDiffuse = new float[PGL.MAX_LIGHTS][4];
lightSpecular = new float[PGL.MAX_LIGHTS][4];
lightFalloffConstant = new float[PGL.MAX_LIGHTS];
lightFalloffLinear = new float[PGL.MAX_LIGHTS];
lightFalloffQuadratic = new float[PGL.MAX_LIGHTS];
lightSpotAngle = new float[PGL.MAX_LIGHTS];
lightSpotAngleCos = new float[PGL.MAX_LIGHTS];
lightSpotConcentration = new float[PGL.MAX_LIGHTS];
currentLightSpecular = new float[4];
lightsAllocated = true;
}
@@ -1126,25 +1118,25 @@ public class PGraphicsOpenGL extends PGraphics {
protected void createFillBuffers() {
glFillVertexBufferID = createVertexBufferObject();
pgl.bindVertexBuffer(glFillVertexBufferID);
pgl.initVertexBuffer(3 * MAX_TESS_VERTICES, vboMode);
pgl.initVertexBuffer(3 * PGL.MAX_TESS_VERTICES, vboMode);
glFillColorBufferID = createVertexBufferObject();
pgl.bindVertexBuffer(glFillColorBufferID);
pgl.initVertexBuffer(4 * MAX_TESS_VERTICES, vboMode);
pgl.initVertexBuffer(4 * PGL.MAX_TESS_VERTICES, vboMode);
glFillNormalBufferID = createVertexBufferObject();
pgl.bindVertexBuffer(glFillNormalBufferID);
pgl.initVertexBuffer(3 * MAX_TESS_VERTICES, vboMode);
pgl.initVertexBuffer(3 * PGL.MAX_TESS_VERTICES, vboMode);
glFillTexCoordBufferID = createVertexBufferObject();
pgl.bindVertexBuffer(glFillTexCoordBufferID);
pgl.initVertexBuffer(2 * MAX_TESS_VERTICES, vboMode);
pgl.initVertexBuffer(2 * PGL.MAX_TESS_VERTICES, vboMode);
pgl.unbindVertexBuffer();
glFillIndexBufferID = createVertexBufferObject();
pgl.bindIndexBuffer(glFillIndexBufferID);
pgl.initIndexBuffer(MAX_TESS_INDICES, vboMode);
pgl.initIndexBuffer(PGL.MAX_TESS_INDICES, vboMode);
pgl.unbindIndexBuffer();
}
@@ -1169,25 +1161,25 @@ public class PGraphicsOpenGL extends PGraphics {
protected void createLineBuffers() {
glLineVertexBufferID = createVertexBufferObject();
pgl.bindVertexBuffer(glLineVertexBufferID);
pgl.initVertexBuffer(3 * MAX_TESS_VERTICES, vboMode);
pgl.initVertexBuffer(3 * PGL.MAX_TESS_VERTICES, vboMode);
glLineColorBufferID = createVertexBufferObject();
pgl.bindVertexBuffer(glLineColorBufferID);
pgl.initVertexBuffer(4 * MAX_TESS_VERTICES, vboMode);
pgl.initVertexBuffer(4 * PGL.MAX_TESS_VERTICES, vboMode);
glLineNormalBufferID = createVertexBufferObject();
pgl.bindVertexBuffer(glLineNormalBufferID);
pgl.initVertexBuffer(3 * MAX_TESS_VERTICES, vboMode);
pgl.initVertexBuffer(3 * PGL.MAX_TESS_VERTICES, vboMode);
glLineAttribBufferID = createVertexBufferObject();
pgl.bindVertexBuffer(glLineAttribBufferID);
pgl.initVertexBuffer(4 * MAX_TESS_VERTICES, vboMode);
pgl.initVertexBuffer(4 * PGL.MAX_TESS_VERTICES, vboMode);
pgl.unbindVertexBuffer();
glLineIndexBufferID = createVertexBufferObject();
pgl.bindIndexBuffer(glLineIndexBufferID);
pgl.initIndexBuffer(MAX_TESS_INDICES, vboMode);
pgl.initIndexBuffer(PGL.MAX_TESS_INDICES, vboMode);
pgl.unbindIndexBuffer();
}
@@ -1212,25 +1204,25 @@ public class PGraphicsOpenGL extends PGraphics {
protected void createPointBuffers() {
glPointVertexBufferID = createVertexBufferObject();
pgl.bindVertexBuffer(glPointVertexBufferID);
pgl.initVertexBuffer(3 * MAX_TESS_VERTICES, vboMode);
pgl.initVertexBuffer(3 * PGL.MAX_TESS_VERTICES, vboMode);
glPointColorBufferID = createVertexBufferObject();
pgl.bindVertexBuffer(glPointColorBufferID);
pgl.initVertexBuffer(4 * MAX_TESS_VERTICES, vboMode);
pgl.initVertexBuffer(4 * PGL.MAX_TESS_VERTICES, vboMode);
glPointNormalBufferID = createVertexBufferObject();
pgl.bindVertexBuffer(glPointNormalBufferID);
pgl.initVertexBuffer(3 * MAX_TESS_VERTICES, vboMode);
pgl.initVertexBuffer(3 * PGL.MAX_TESS_VERTICES, vboMode);
glPointAttribBufferID = createVertexBufferObject();
pgl.bindVertexBuffer(glPointAttribBufferID);
pgl.initVertexBuffer(2 * MAX_TESS_VERTICES, vboMode);
pgl.initVertexBuffer(2 * PGL.MAX_TESS_VERTICES, vboMode);
pgl.unbindVertexBuffer();
glPointIndexBufferID = createVertexBufferObject();
pgl.bindIndexBuffer(glPointIndexBufferID);
pgl.initIndexBuffer(MAX_TESS_INDICES, vboMode);
pgl.initIndexBuffer(PGL.MAX_TESS_INDICES, vboMode);
pgl.unbindIndexBuffer();
}
@@ -4342,8 +4334,8 @@ public class PGraphicsOpenGL extends PGraphics {
*/
public void ambientLight(float r, float g, float b, float x, float y, float z) {
enableLighting();
if (lightCount == MAX_LIGHTS) {
throw new RuntimeException("can only create " + MAX_LIGHTS + " lights");
if (lightCount == PGL.MAX_LIGHTS) {
throw new RuntimeException("can only create " + PGL.MAX_LIGHTS + " lights");
}
colorCalc(r, g, b);
lightDiffuse[lightCount][0] = calcR;
@@ -4373,8 +4365,8 @@ public class PGraphicsOpenGL extends PGraphics {
public void directionalLight(float r, float g, float b, float nx, float ny, float nz) {
enableLighting();
if (lightCount == MAX_LIGHTS) {
throw new RuntimeException("can only create " + MAX_LIGHTS + " lights");
if (lightCount == PGL.MAX_LIGHTS) {
throw new RuntimeException("can only create " + PGL.MAX_LIGHTS + " lights");
}
colorCalc(r, g, b);
lightDiffuse[lightCount][0] = calcR;
@@ -4412,8 +4404,8 @@ public class PGraphicsOpenGL extends PGraphics {
public void pointLight(float r, float g, float b, float x, float y, float z) {
enableLighting();
if (lightCount == MAX_LIGHTS) {
throw new RuntimeException("can only create " + MAX_LIGHTS + " lights");
if (lightCount == PGL.MAX_LIGHTS) {
throw new RuntimeException("can only create " + PGL.MAX_LIGHTS + " lights");
}
colorCalc(r, g, b);
lightDiffuse[lightCount][0] = calcR;
@@ -4448,8 +4440,8 @@ public class PGraphicsOpenGL extends PGraphics {
public void spotLight(float r, float g, float b, float x, float y, float z,
float nx, float ny, float nz, float angle, float concentration) {
enableLighting();
if (lightCount == MAX_LIGHTS) {
throw new RuntimeException("can only create " + MAX_LIGHTS + " lights");
if (lightCount == PGL.MAX_LIGHTS) {
throw new RuntimeException("can only create " + PGL.MAX_LIGHTS + " lights");
}
colorCalc(r, g, b);
lightDiffuse[lightCount][0] = calcR;
@@ -6831,12 +6823,12 @@ public class PGraphicsOpenGL extends PGraphics {
}
public boolean isFull() {
return MAX_TESS_VERTICES <= fillVertexCount ||
MAX_TESS_VERTICES <= lineVertexCount ||
MAX_TESS_VERTICES <= pointVertexCount ||
MAX_TESS_INDICES <= fillIndexCount ||
MAX_TESS_INDICES <= fillIndexCount ||
MAX_TESS_INDICES <= fillIndexCount;
return PGL.MAX_TESS_VERTICES <= fillVertexCount ||
PGL.MAX_TESS_VERTICES <= lineVertexCount ||
PGL.MAX_TESS_VERTICES <= pointVertexCount ||
PGL.MAX_TESS_INDICES <= fillIndexCount ||
PGL.MAX_TESS_INDICES <= fillIndexCount ||
PGL.MAX_TESS_INDICES <= fillIndexCount;
}
public void addCounts(TessGeometry other) {