mirror of
https://github.com/processing/processing4.git
synced 2026-01-30 03:41:15 +01:00
Several fixes
This commit is contained in:
@@ -39,7 +39,7 @@ import processing.core.PConstants;
|
||||
public class PFramebuffer implements PConstants {
|
||||
protected PApplet parent;
|
||||
protected PGraphicsOpenGL ogl;
|
||||
protected PGLJava pgl;
|
||||
protected PGL pgl;
|
||||
|
||||
public int glFboID;
|
||||
public int glDepthBufferID;
|
||||
@@ -453,7 +453,7 @@ public class PFramebuffer implements PConstants {
|
||||
// getGl2().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, nsamples, GL.GL_DEPTH24_STENCIL8, width, height);
|
||||
pgl.setRenderbufferNumSamples(nsamples, width, height);
|
||||
} else {
|
||||
pgl.setRenderbufferStorage(PGLJava.DEPTH_24BIT_STENCIL_8BIT, width, height);
|
||||
pgl.setRenderbufferStorage(PGL.DEPTH_24BIT_STENCIL_8BIT, width, height);
|
||||
// getGl().glRenderbufferStorage(GL.GL_RENDERBUFFER, GL.GL_DEPTH24_STENCIL8, width, height);
|
||||
}
|
||||
|
||||
@@ -482,13 +482,13 @@ public class PFramebuffer implements PConstants {
|
||||
//getGl().glBindRenderbuffer(GL.GL_RENDERBUFFER, glDepthBufferID);
|
||||
pgl.bindRenderbuffer(glDepthBufferID);
|
||||
|
||||
int glConst = PGLJava.DEPTH_16BIT;
|
||||
int glConst = PGL.DEPTH_16BIT;
|
||||
if (depthBits == 16) {
|
||||
glConst = PGLJava.DEPTH_16BIT;
|
||||
glConst = PGL.DEPTH_16BIT;
|
||||
} else if (depthBits == 24) {
|
||||
glConst = PGLJava.DEPTH_24BIT;
|
||||
glConst = PGL.DEPTH_24BIT;
|
||||
} else if (depthBits == 32) {
|
||||
glConst = PGLJava.DEPTH_32BIT;
|
||||
glConst = PGL.DEPTH_32BIT;
|
||||
}
|
||||
|
||||
if (multisample) {
|
||||
@@ -522,13 +522,13 @@ public class PFramebuffer implements PConstants {
|
||||
// getGl().glBindRenderbuffer(GL.GL_RENDERBUFFER, glStencilBufferID);
|
||||
pgl.bindRenderbuffer(glStencilBufferID);
|
||||
|
||||
int glConst = PGLJava.STENCIL_1BIT;
|
||||
int glConst = PGL.STENCIL_1BIT;
|
||||
if (stencilBits == 1) {
|
||||
glConst = PGLJava.STENCIL_1BIT;
|
||||
glConst = PGL.STENCIL_1BIT;
|
||||
} else if (stencilBits == 4) {
|
||||
glConst = PGLJava.STENCIL_4BIT;
|
||||
glConst = PGL.STENCIL_4BIT;
|
||||
} else if (stencilBits == 8) {
|
||||
glConst = PGLJava.STENCIL_8BIT;
|
||||
glConst = PGL.STENCIL_8BIT;
|
||||
}
|
||||
if (multisample) {
|
||||
// getGl2().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, nsamples, glConst, width, height);
|
||||
@@ -573,17 +573,17 @@ public class PFramebuffer implements PConstants {
|
||||
public boolean validateFbo() {
|
||||
// int status = getGl().glCheckFramebufferStatus(GL.GL_FRAMEBUFFER);
|
||||
int status = pgl.getFramebufferStatus();
|
||||
if (status == PGLJava.FRAMEBUFFER_COMPLETE) {
|
||||
if (status == PGL.FRAMEBUFFER_COMPLETE) {
|
||||
return true;
|
||||
} else if (status == PGLJava.FRAMEBUFFER_INCOMPLETE_ATTACHMENT) {
|
||||
} else if (status == PGL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT (" + Integer.toHexString(status) + ")");
|
||||
} else if (status == PGLJava.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT) {
|
||||
} else if (status == PGL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT (" + Integer.toHexString(status) + ")");
|
||||
} else if (status == PGLJava.FRAMEBUFFER_INCOMPLETE_DIMENSIONS) {
|
||||
} else if (status == PGL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS (" + Integer.toHexString(status) + ")");
|
||||
} else if (status == PGLJava.FRAMEBUFFER_INCOMPLETE_FORMATS) {
|
||||
} else if (status == PGL.FRAMEBUFFER_INCOMPLETE_FORMATS) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_FORMATS (" + Integer.toHexString(status) + ")");
|
||||
} else if (status == PGLJava.FRAMEBUFFER_UNSUPPORTED) {
|
||||
} else if (status == PGL.FRAMEBUFFER_UNSUPPORTED) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_UNSUPPORTED" + Integer.toHexString(status));
|
||||
} else {
|
||||
throw new RuntimeException("PFramebuffer: unknown framebuffer error (" + Integer.toHexString(status) + ")");
|
||||
|
||||
@@ -41,39 +41,42 @@ import processing.core.PApplet;
|
||||
* Note that the programmable mode uses the non-backward compatible GL objects
|
||||
* (GL3, GL4, and not GL3bc, GL4bc) so no fixed mode calls are possible under this mode.
|
||||
*/
|
||||
public class PGLJava {
|
||||
public class PGL {
|
||||
/** Size of an int (in bytes). */
|
||||
static final int SIZEOF_INT = Integer.SIZE / 8;
|
||||
|
||||
/** Size of a float (in bytes). */
|
||||
static final int SIZEOF_FLOAT = Float.SIZE / 8;
|
||||
|
||||
public static final int LESS = GL.GL_LESS;
|
||||
public static final int LESS_OR_EQUAL = GL.GL_LEQUAL;
|
||||
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;
|
||||
public static final int CLOCKWISE = GL.GL_CW;
|
||||
public static final int FRONT = GL.GL_FRONT;
|
||||
public static final int BACK = GL.GL_BACK;
|
||||
public static final int BLEND_EQ_ADD = GL.GL_FUNC_ADD;
|
||||
public static final int BLEND_EQ_MIN = GL2.GL_MIN;
|
||||
public static final int BLEND_EQ_MAX = GL2.GL_MAX;
|
||||
public static final int CLOCKWISE = GL.GL_CW;
|
||||
public static final int FRONT = GL.GL_FRONT;
|
||||
public static final int BACK = GL.GL_BACK;
|
||||
|
||||
public static final int BLEND_EQ_ADD = GL.GL_FUNC_ADD;
|
||||
public static final int BLEND_EQ_MIN = GL2.GL_MIN;
|
||||
public static final int BLEND_EQ_MAX = GL2.GL_MAX;
|
||||
public static final int BLEND_EQ_REVERSE_SUBTRACT = GL.GL_FUNC_REVERSE_SUBTRACT;
|
||||
public static final int REPLACE = GL2.GL_REPLACE;
|
||||
|
||||
public static final int REPLACE = GL2.GL_REPLACE;
|
||||
public static final int MODULATE = GL2.GL_MODULATE;
|
||||
public static final int FLAT = GL2.GL_FLAT;
|
||||
|
||||
public static final int FLAT = GL2.GL_FLAT;
|
||||
public static final int SMOOTH = GL2.GL_SMOOTH;
|
||||
|
||||
public static final int TEXTURE_2D = GL.GL_TEXTURE_2D;
|
||||
public static final int RGB = GL.GL_RGB;
|
||||
public static final int RGBA = GL.GL_RGBA;
|
||||
public static final int ALPHA = GL.GL_ALPHA;
|
||||
public static final int RGB = GL.GL_RGB;
|
||||
public static final int RGBA = GL.GL_RGBA;
|
||||
public static final int ALPHA = GL.GL_ALPHA;
|
||||
|
||||
public static final int NEAREST = GL.GL_NEAREST;
|
||||
public static final int LINEAR = GL.GL_LINEAR;
|
||||
public static final int NEAREST = GL.GL_NEAREST;
|
||||
public static final int LINEAR = GL.GL_LINEAR;
|
||||
public static final int LINEAR_MIPMAP_LINEAR = GL.GL_LINEAR_MIPMAP_LINEAR;
|
||||
|
||||
public static final int CLAMP_TO_EDGE = GL.GL_CLAMP_TO_EDGE;
|
||||
public static final int REPEAT = GL.GL_REPEAT;
|
||||
public static final int REPEAT = GL.GL_REPEAT;
|
||||
|
||||
public static final int DEPTH_24BIT_STENCIL_8BIT = GL.GL_DEPTH24_STENCIL8;
|
||||
|
||||
@@ -85,16 +88,16 @@ public class PGLJava {
|
||||
public static final int STENCIL_4BIT = GL.GL_STENCIL_INDEX4;
|
||||
public static final int STENCIL_8BIT = GL.GL_STENCIL_INDEX8;
|
||||
|
||||
public static final int FRAMEBUFFER_COMPLETE = GL.GL_FRAMEBUFFER_COMPLETE;
|
||||
public static final int FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
|
||||
public static final int FRAMEBUFFER_COMPLETE = GL.GL_FRAMEBUFFER_COMPLETE;
|
||||
public static final int FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
|
||||
public static final int FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
|
||||
public static final int FRAMEBUFFER_INCOMPLETE_DIMENSIONS = GL.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
|
||||
public static final int FRAMEBUFFER_INCOMPLETE_FORMATS = GL.GL_FRAMEBUFFER_INCOMPLETE_FORMATS;
|
||||
public static final int FRAMEBUFFER_UNSUPPORTED = GL.GL_FRAMEBUFFER_UNSUPPORTED;
|
||||
public static final int FRAMEBUFFER_INCOMPLETE_DIMENSIONS = GL.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
|
||||
public static final int FRAMEBUFFER_INCOMPLETE_FORMATS = GL.GL_FRAMEBUFFER_INCOMPLETE_FORMATS;
|
||||
public static final int FRAMEBUFFER_UNSUPPORTED = GL.GL_FRAMEBUFFER_UNSUPPORTED;
|
||||
|
||||
public static final int STATIC_DRAW = GL.GL_STATIC_DRAW;
|
||||
public static final int STATIC_DRAW = GL.GL_STATIC_DRAW;
|
||||
public static final int DYNAMIC_DRAW = GL.GL_DYNAMIC_DRAW;
|
||||
public static final int STREAM_DRAW = GL2.GL_STREAM_DRAW;
|
||||
public static final int STREAM_DRAW = GL2.GL_STREAM_DRAW;
|
||||
|
||||
// Rendering pipeline modes
|
||||
public static final int FIXED = 0;
|
||||
@@ -128,7 +131,7 @@ public class PGLJava {
|
||||
|
||||
public GLU glu;
|
||||
|
||||
public PGLJava() {
|
||||
public PGL() {
|
||||
glu = new GLU();
|
||||
}
|
||||
|
||||
@@ -294,149 +297,160 @@ public class PGLJava {
|
||||
public void enableColorMaterial() {
|
||||
gl2f.glEnable(GL2.GL_COLOR_MATERIAL);
|
||||
}
|
||||
|
||||
public void disableColorMaterial() {
|
||||
gl2f.glDisable(GL2.GL_COLOR_MATERIAL);
|
||||
}
|
||||
|
||||
public void enableNormalization() {
|
||||
gl2f.glEnable(GL2.GL_NORMALIZE);
|
||||
}
|
||||
|
||||
public void disableNormalization() {
|
||||
gl2f.glDisable(GL2.GL_NORMALIZE);
|
||||
}
|
||||
|
||||
public void enableRescaleNormals() {
|
||||
gl2f.glEnable(GL2.GL_RESCALE_NORMAL);
|
||||
}
|
||||
|
||||
public void disableRescaleNormals() {
|
||||
gl2f.glDisable(GL2.GL_RESCALE_NORMAL);
|
||||
}
|
||||
|
||||
|
||||
void genVertexArray(int[] id) {
|
||||
public void genVertexArray(int[] id) {
|
||||
gl2x.glGenVertexArrays(1, id, 0);
|
||||
}
|
||||
|
||||
void delVertexArray(int[] id) {
|
||||
public void delVertexArray(int[] id) {
|
||||
gl2x.glDeleteVertexArrays(1, id, 0);
|
||||
}
|
||||
|
||||
void genTexture(int[] id) {
|
||||
public void genTexture(int[] id) {
|
||||
gl.glGenTextures(1, id, 0);
|
||||
}
|
||||
|
||||
void delTexture(int[] id) {
|
||||
public void delTexture(int[] id) {
|
||||
gl.glDeleteTextures(1, id, 0);
|
||||
}
|
||||
|
||||
void genBuffer(int[] id) {
|
||||
public void genBuffer(int[] id) {
|
||||
gl.glGenBuffers(1, id, 0);
|
||||
}
|
||||
|
||||
void delBuffer(int[] id) {
|
||||
public void delBuffer(int[] id) {
|
||||
gl.glDeleteBuffers(1, id, 0);
|
||||
}
|
||||
|
||||
void genFramebuffer(int[] id) {
|
||||
public void genFramebuffer(int[] id) {
|
||||
gl.glGenFramebuffers(1, id, 0);
|
||||
}
|
||||
|
||||
void delFramebuffer(int[] id) {
|
||||
public void delFramebuffer(int[] id) {
|
||||
gl.glDeleteFramebuffers(1, id, 0);
|
||||
}
|
||||
|
||||
void genRenderbuffer(int[] id) {
|
||||
public void genRenderbuffer(int[] id) {
|
||||
gl.glGenRenderbuffers(1, id, 0);
|
||||
}
|
||||
|
||||
void delRenderbuffer(int[] id) {
|
||||
public void delRenderbuffer(int[] id) {
|
||||
gl.glGenRenderbuffers(1, id, 0);
|
||||
}
|
||||
|
||||
void genProgram(int[] id) {
|
||||
public void genProgram(int[] id) {
|
||||
id[0] = gl2x.glCreateProgram();
|
||||
}
|
||||
|
||||
void delProgram(int[] id) {
|
||||
public void delProgram(int[] id) {
|
||||
gl2x.glDeleteProgram(id[0]);
|
||||
}
|
||||
|
||||
void genVertexShader(int[] id) {
|
||||
public void genVertexShader(int[] id) {
|
||||
id[0] = gl2x.glCreateShader(GL2.GL_VERTEX_SHADER);
|
||||
}
|
||||
|
||||
void delVertexShader(int[] id) {
|
||||
public void delVertexShader(int[] id) {
|
||||
gl2x.glDeleteShader(id[0]);
|
||||
}
|
||||
|
||||
void genFragmentShader(int[] id) {
|
||||
public void genFragmentShader(int[] id) {
|
||||
id[0] = gl2x.glCreateShader(GL2.GL_FRAGMENT_SHADER);
|
||||
}
|
||||
|
||||
void delFragmentShader(int[] id) {
|
||||
public void delFragmentShader(int[] id) {
|
||||
gl2x.glDeleteShader(id[0]);
|
||||
}
|
||||
|
||||
void bindVertexBuffer(int id) {
|
||||
public void bindVertexBuffer(int id) {
|
||||
gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, id);
|
||||
}
|
||||
|
||||
void initVertexBuffer(int size, int mode) {
|
||||
public void initVertexBuffer(int size, int mode) {
|
||||
gl2f.glBufferData(GL.GL_ARRAY_BUFFER, size * SIZEOF_FLOAT, null, mode);
|
||||
}
|
||||
|
||||
void copyVertexBufferData(float[] data, int size, int mode) {
|
||||
public void copyVertexBufferData(float[] data, int size, int mode) {
|
||||
gl2f.glBufferData(GL.GL_ARRAY_BUFFER, size * SIZEOF_FLOAT, FloatBuffer.wrap(data, 0, size), mode);
|
||||
}
|
||||
|
||||
void copyVertexBufferData(float[] data, int offset, int size, int mode) {
|
||||
public void copyVertexBufferData(float[] data, int offset, int size, int mode) {
|
||||
gl2f.glBufferData(GL.GL_ARRAY_BUFFER, size * SIZEOF_FLOAT, FloatBuffer.wrap(data, offset, size), mode);
|
||||
}
|
||||
|
||||
void copyVertexBufferSubData(float[] data, int offset, int size, int mode) {
|
||||
public void copyVertexBufferSubData(float[] data, int offset, int size, int mode) {
|
||||
gl2f.glBufferSubData(GL.GL_ARRAY_BUFFER, offset * SIZEOF_FLOAT, size * SIZEOF_FLOAT, FloatBuffer.wrap(data, 0, size));
|
||||
}
|
||||
|
||||
void setVertexFormat(int size, int stride, long offset) {
|
||||
public void setVertexFormat(int size, int stride, long offset) {
|
||||
gl2f.glVertexPointer(size, GL.GL_FLOAT, stride, offset);
|
||||
}
|
||||
|
||||
void setColorFormat(int size, int stride, long offset) {
|
||||
public void setColorFormat(int size, int stride, long offset) {
|
||||
gl2f.glColorPointer(size, GL.GL_FLOAT, stride, offset);
|
||||
}
|
||||
|
||||
void setNormalFormat(int size, int stride, long offset) {
|
||||
public void setNormalFormat(int size, int stride, long offset) {
|
||||
gl2f.glNormalPointer(GL.GL_FLOAT, 0, 0);
|
||||
}
|
||||
|
||||
void setTexCoordFormat(int size, int stride, long offset) {
|
||||
public void setTexCoordFormat(int size, int stride, long offset) {
|
||||
gl2f.glTexCoordPointer(size, GL.GL_FLOAT, stride, offset);
|
||||
}
|
||||
|
||||
void unbindVertexBuffer() {
|
||||
public void unbindVertexBuffer() {
|
||||
gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void bindIndexBuffer(int id) {
|
||||
public void bindIndexBuffer(int id) {
|
||||
gl2f.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, id);
|
||||
}
|
||||
|
||||
void initIndexBuffer(int size, int mode) {
|
||||
public void initIndexBuffer(int size, int mode) {
|
||||
gl2f.glBufferData(GL.GL_ELEMENT_ARRAY_BUFFER, size * SIZEOF_INT, null, mode);
|
||||
}
|
||||
|
||||
void copyIndexBufferData(int[] data, int size, int mode) {
|
||||
public void copyIndexBufferData(int[] data, int size, int mode) {
|
||||
gl2f.glBufferData(GL.GL_ELEMENT_ARRAY_BUFFER, size * SIZEOF_INT, IntBuffer.wrap(data, 0, size), mode);
|
||||
}
|
||||
|
||||
void copyIndexBufferData(int[] data, int offset, int size, int mode) {
|
||||
public void copyIndexBufferData(int[] data, int offset, int size, int mode) {
|
||||
gl2f.glBufferData(GL.GL_ELEMENT_ARRAY_BUFFER, size * SIZEOF_INT, IntBuffer.wrap(data, offset, size), mode);
|
||||
}
|
||||
|
||||
void copyIndexBufferSubData(int[] data, int offset, int size, int mode) {
|
||||
public void copyIndexBufferSubData(int[] data, int offset, int size, int mode) {
|
||||
gl2f.glBufferSubData(GL.GL_ELEMENT_ARRAY_BUFFER, offset * SIZEOF_INT, size * SIZEOF_INT, IntBuffer.wrap(data, 0, size));
|
||||
}
|
||||
|
||||
void renderIndexBuffer(int size) {
|
||||
public void renderIndexBuffer(int size) {
|
||||
gl2f.glDrawElements(GL.GL_TRIANGLES, size, GL.GL_UNSIGNED_INT, 0);
|
||||
}
|
||||
|
||||
void renderIndexBuffer(int offset, int size) {
|
||||
gl2f.glDrawElements(GL.GL_TRIANGLES, size, GL.GL_UNSIGNED_INT, offset * PGraphicsOpenGL.SIZEOF_INT);
|
||||
public void renderIndexBuffer(int offset, int size) {
|
||||
gl2f.glDrawElements(GL.GL_TRIANGLES, size, GL.GL_UNSIGNED_INT, offset * SIZEOF_INT);
|
||||
}
|
||||
|
||||
void unbindIndexBuffer() {
|
||||
public void unbindIndexBuffer() {
|
||||
gl2f.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
@@ -445,7 +459,7 @@ public class PGLJava {
|
||||
}
|
||||
|
||||
public void disableDepthTest() {
|
||||
gl.glEnable(GL.GL_DEPTH_TEST);
|
||||
gl.glDisable(GL.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
public void enableDepthMask() {
|
||||
@@ -69,7 +69,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
public GL4 gl4p;
|
||||
*/
|
||||
|
||||
protected PGLJava pgl;
|
||||
protected PGL pgl;
|
||||
|
||||
|
||||
|
||||
@@ -352,11 +352,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
*/
|
||||
static public boolean BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN;
|
||||
|
||||
/** Size of an int (in bytes). */
|
||||
protected static final int SIZEOF_INT = Integer.SIZE / 8;
|
||||
|
||||
/** Size of a float (in bytes). */
|
||||
protected static final int SIZEOF_FLOAT = Float.SIZE / 8;
|
||||
// /** Size of an int (in bytes). */
|
||||
// protected static final int SIZEOF_INT = Integer.SIZE / 8;
|
||||
//
|
||||
// /** Size of a float (in bytes). */
|
||||
// protected static final int SIZEOF_FLOAT = Float.SIZE / 8;
|
||||
|
||||
// ........................................................
|
||||
|
||||
@@ -431,7 +431,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
protected boolean defaultEdges = false;
|
||||
|
||||
protected int vboMode = PGLJava.STATIC_DRAW;
|
||||
protected int vboMode = PGL.STATIC_DRAW;
|
||||
|
||||
static public float FLOAT_EPS = Float.MIN_VALUE;
|
||||
// Calculation of the Machine Epsilon for float precision. From:
|
||||
@@ -452,7 +452,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
// INIT/ALLOCATE/FINISH
|
||||
|
||||
public PGraphicsOpenGL() {
|
||||
pgl = new PGLJava();
|
||||
pgl = new PGL();
|
||||
|
||||
tessellator = new Tessellator();
|
||||
|
||||
@@ -1498,7 +1498,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
}
|
||||
// use <= since that's what processing.core does
|
||||
//gl.glDepthFunc(GL.GL_LEQUAL);
|
||||
pgl.setDepthFunc(PGLJava.LESS_OR_EQUAL);
|
||||
pgl.setDepthFunc(PGL.LESS_OR_EQUAL);
|
||||
|
||||
if (hints[DISABLE_DEPTH_MASK]) {
|
||||
//gl.glDepthMask(false);
|
||||
@@ -1561,7 +1561,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
lightSpecular(0, 0, 0);
|
||||
|
||||
// because y is flipped
|
||||
pgl.setFrontFace(PGLJava.CLOCKWISE);
|
||||
pgl.setFrontFace(PGL.CLOCKWISE);
|
||||
//gl.glFrontFace(GL.GL_CW);
|
||||
|
||||
setSurfaceParams();
|
||||
@@ -1778,9 +1778,9 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
// defaults (plus these cannot be changed through the API
|
||||
// so they should remain constant anyways):
|
||||
//gl.glFrontFace(GL.GL_CW);
|
||||
pgl.setFrontFace(PGLJava.CLOCKWISE);
|
||||
pgl.setFrontFace(PGL.CLOCKWISE);
|
||||
//gl.glDepthFunc(GL.GL_LEQUAL);
|
||||
pgl.setDepthFunc(PGLJava.LESS_OR_EQUAL);
|
||||
pgl.setDepthFunc(PGL.LESS_OR_EQUAL);
|
||||
|
||||
setSurfaceParams();
|
||||
}
|
||||
@@ -2038,7 +2038,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
flush();
|
||||
textureImage = null;
|
||||
}
|
||||
|
||||
|
||||
tessellate(mode);
|
||||
|
||||
if (flushMode == FLUSH_CONTINUOUSLY ||
|
||||
@@ -2059,7 +2059,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
// textures are not mixed.
|
||||
textureImage = textureImage0;
|
||||
flush();
|
||||
}
|
||||
}
|
||||
super.texture(image);
|
||||
}
|
||||
|
||||
@@ -2159,11 +2159,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
if (textured && textureMode == IMAGE) {
|
||||
u /= textureImage.width;
|
||||
v /= textureImage.height;
|
||||
|
||||
PTexture tex = getTexture(textureImage);
|
||||
if (tex.isFlippedY()) {
|
||||
v = 1 - v;
|
||||
}
|
||||
|
||||
// TODO: GL texture shouldn't be retrieved
|
||||
// until rendering. So how to know if it
|
||||
// is flipped?
|
||||
// PTexture tex = getTexture(textureImage);
|
||||
// if (tex.isFlippedY()) {
|
||||
// v = 1 - v;
|
||||
// }
|
||||
}
|
||||
|
||||
inGeo.addVertex(x, y, z,
|
||||
@@ -2657,7 +2660,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
|
||||
protected void setupLineShader(int attrBufID, float[] attribs, int nvert) {
|
||||
int[] viewport = {0, 0, 0, 0};
|
||||
//int[] viewport = {0, 0, 0, 0};
|
||||
//gl2f.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
|
||||
lineShader.setVecUniform("viewport", viewport[0], viewport[1], viewport[2], viewport[3]);
|
||||
|
||||
@@ -2679,7 +2682,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
|
||||
protected void setupLineShader(int attrBufID) {
|
||||
int[] viewport = {0, 0, 0, 0};
|
||||
//int[] viewport = {0, 0, 0, 0};
|
||||
//gl2f.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
|
||||
lineShader.setVecUniform("viewport", viewport[0], viewport[1], viewport[2], viewport[3]);
|
||||
|
||||
@@ -5092,7 +5095,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
pixelBuffer.rewind();
|
||||
if (primarySurface) {
|
||||
pgl.setReadBuffer(PGLJava.FRONT);
|
||||
pgl.setReadBuffer(PGL.FRONT);
|
||||
// gl2x.glReadBuffer(GL.GL_FRONT);
|
||||
}
|
||||
pgl.readPixels(pixelBuffer, 0, 0, width, height);
|
||||
@@ -5537,7 +5540,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
getsetBuffer.rewind();
|
||||
if (primarySurface) {
|
||||
// gl2x.glReadBuffer(GL.GL_FRONT);
|
||||
pgl.setReadBuffer(PGLJava.FRONT);
|
||||
pgl.setReadBuffer(PGL.FRONT);
|
||||
}
|
||||
//gl.glReadPixels(x, height - y - 1, 1, 1, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, getsetBuffer);
|
||||
pgl.readPixels(getsetBuffer, x, height - y - 1, 1, 1);
|
||||
@@ -5579,7 +5582,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
newbieBuffer.rewind();
|
||||
if (primarySurface) {
|
||||
// gl2x.glReadBuffer(GL.GL_FRONT);
|
||||
pgl.setReadBuffer(PGLJava.FRONT);
|
||||
pgl.setReadBuffer(PGL.FRONT);
|
||||
}
|
||||
// gl.glReadPixels(x, height - y - h, w, h, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, newbieBuffer);
|
||||
pgl.readPixels(newbieBuffer, x, height - y - h, w, h);
|
||||
@@ -5795,7 +5798,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
if (mode == REPLACE) {
|
||||
// This is equivalent to disable blending.
|
||||
if (blendEqSupported) {
|
||||
pgl.setBlendEquation(PGLJava.BLEND_EQ_ADD);
|
||||
pgl.setBlendEquation(PGL.BLEND_EQ_ADD);
|
||||
//gl.glBlendEquation(GL.GL_FUNC_ADD);
|
||||
}
|
||||
//gl.glBlendFunc(GL.GL_ONE, GL.GL_ZERO);
|
||||
@@ -5803,21 +5806,21 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
} else if (mode == BLEND) {
|
||||
if (blendEqSupported) {
|
||||
//gl.glBlendEquation(GL.GL_FUNC_ADD);
|
||||
pgl.setBlendEquation(PGLJava.BLEND_EQ_ADD);
|
||||
pgl.setBlendEquation(PGL.BLEND_EQ_ADD);
|
||||
}
|
||||
//gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
|
||||
pgl.setDefaultBlend();
|
||||
} else if (mode == ADD) {
|
||||
if (blendEqSupported) {
|
||||
//gl.glBlendEquation(GL.GL_FUNC_ADD);
|
||||
pgl.setBlendEquation(PGLJava.BLEND_EQ_ADD);
|
||||
pgl.setBlendEquation(PGL.BLEND_EQ_ADD);
|
||||
}
|
||||
//gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);
|
||||
pgl.setAdditiveBlend();
|
||||
} else if (mode == SUBTRACT) {
|
||||
if (blendEqSupported) {
|
||||
//gl.glBlendEquation(GL.GL_FUNC_ADD);
|
||||
pgl.setBlendEquation(PGLJava.BLEND_EQ_ADD);
|
||||
pgl.setBlendEquation(PGL.BLEND_EQ_ADD);
|
||||
}
|
||||
//gl.glBlendFunc(GL.GL_ONE_MINUS_DST_COLOR, GL.GL_ZERO);
|
||||
pgl.setSubstractiveBlend();
|
||||
@@ -5825,7 +5828,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
if (blendEqSupported) {
|
||||
//gl.glBlendEquation(GL2.GL_MAX);
|
||||
//gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_DST_ALPHA);
|
||||
pgl.setBlendEquation(PGLJava.BLEND_EQ_MAX);
|
||||
pgl.setBlendEquation(PGL.BLEND_EQ_MAX);
|
||||
pgl.setLightestBlend();
|
||||
} else {
|
||||
PGraphics.showWarning("P3D: This blend mode is currently unsupported.");
|
||||
@@ -5834,7 +5837,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
if (blendEqSupported) {
|
||||
//gl.glBlendEquation(GL2.GL_MIN);
|
||||
//gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_DST_ALPHA);
|
||||
pgl.setBlendEquation(PGLJava.BLEND_EQ_MIN);
|
||||
pgl.setBlendEquation(PGL.BLEND_EQ_MIN);
|
||||
pgl.setDarkestBlend();
|
||||
} else {
|
||||
PGraphics.showWarning("P3D: This blend mode is currently unsupported.");
|
||||
@@ -5843,7 +5846,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
if (blendEqSupported) {
|
||||
//gl.glBlendEquation(GL.GL_FUNC_REVERSE_SUBTRACT);
|
||||
//gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE);
|
||||
pgl.setBlendEquation(PGLJava.BLEND_EQ_REVERSE_SUBTRACT);
|
||||
pgl.setBlendEquation(PGL.BLEND_EQ_REVERSE_SUBTRACT);
|
||||
pgl.setDifferenceBlend();
|
||||
|
||||
} else {
|
||||
@@ -5852,21 +5855,21 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
} else if (mode == EXCLUSION) {
|
||||
if (blendEqSupported) {
|
||||
//gl.glBlendEquation(GL.GL_FUNC_ADD);
|
||||
pgl.setBlendEquation(PGLJava.BLEND_EQ_ADD);
|
||||
pgl.setBlendEquation(PGL.BLEND_EQ_ADD);
|
||||
}
|
||||
//gl.glBlendFunc(GL.GL_ONE_MINUS_DST_COLOR, GL.GL_ONE_MINUS_SRC_COLOR);
|
||||
pgl.setExclussionBlend();
|
||||
} else if (mode == MULTIPLY) {
|
||||
if (blendEqSupported) {
|
||||
//gl.glBlendEquation(GL.GL_FUNC_ADD);
|
||||
pgl.setBlendEquation(PGLJava.BLEND_EQ_ADD);
|
||||
pgl.setBlendEquation(PGL.BLEND_EQ_ADD);
|
||||
}
|
||||
//gl.glBlendFunc(GL.GL_DST_COLOR, GL.GL_SRC_COLOR);
|
||||
pgl.setMultiplyBlend();
|
||||
} else if (mode == SCREEN) {
|
||||
if (blendEqSupported) {
|
||||
//gl.glBlendEquation(GL.GL_FUNC_ADD);
|
||||
pgl.setBlendEquation(PGLJava.BLEND_EQ_ADD);
|
||||
pgl.setBlendEquation(PGL.BLEND_EQ_ADD);
|
||||
}
|
||||
// gl.glBlendFunc(GL.GL_ONE_MINUS_DST_COLOR, GL.GL_ONE);
|
||||
pgl.setScreenBlend();
|
||||
@@ -5883,7 +5886,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
pgl.enableBlend();
|
||||
if (blendEqSupported) {
|
||||
//gl.glBlendEquation(GL.GL_FUNC_ADD);
|
||||
pgl.setBlendEquation(PGLJava.BLEND_EQ_ADD);
|
||||
pgl.setBlendEquation(PGL.BLEND_EQ_ADD);
|
||||
}
|
||||
//gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
|
||||
pgl.setDefaultBlend();
|
||||
@@ -5939,7 +5942,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
public PTexture getTexture(PImage img) {
|
||||
PTexture tex = (PTexture)img.getCache(ogl);
|
||||
if (tex == null) {
|
||||
tex = addTexture(img);
|
||||
tex = addTexture(img);
|
||||
} else {
|
||||
if (context.hashCode() != tex.context.hashCode()) {
|
||||
// The texture was created with a different context. We need
|
||||
@@ -5975,7 +5978,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
params = PTexture.newParameters();
|
||||
img.setParams(ogl, params);
|
||||
}
|
||||
PTexture tex = new PTexture(img.parent, img.width, img.height, params);
|
||||
PTexture tex = new PTexture(img.parent, img.width, img.height, params);
|
||||
img.loadPixels();
|
||||
if (img.pixels != null) tex.set(img.pixels);
|
||||
img.setCache(ogl, tex);
|
||||
@@ -6038,7 +6041,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
// The texels of the texture replace the color of wherever is on the screen.
|
||||
// gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
|
||||
pgl.setTexEnvironmentMode(PGLJava.REPLACE);
|
||||
pgl.setTexEnvironmentMode(PGL.REPLACE);
|
||||
|
||||
|
||||
drawTexture(tw, th, crop, x, y, w, h);
|
||||
@@ -6046,7 +6049,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
// Returning to the default texture environment mode, GL_MODULATE. This allows tinting a texture
|
||||
// with the current fragment color.
|
||||
// gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
|
||||
pgl.setTexEnvironmentMode(PGLJava.MODULATE);
|
||||
pgl.setTexEnvironmentMode(PGL.MODULATE);
|
||||
|
||||
// gl.glBindTexture(target, 0);
|
||||
// gl.glDisable(target);
|
||||
@@ -6188,7 +6191,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
// The default shade model is GL_SMOOTH, but we set
|
||||
// here just in case...
|
||||
//gl2f.glShadeModel(GL2.GL_SMOOTH);
|
||||
pgl.setShadeModel(PGLJava.SMOOTH);
|
||||
pgl.setShadeModel(PGL.SMOOTH);
|
||||
|
||||
|
||||
// The ambient and diffuse components for each vertex are taken
|
||||
@@ -6298,7 +6301,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
//profile = GLProfile.get(GLProfile.GL2ES1);
|
||||
//profile = GLProfile.get(GLProfile.GL4bc);
|
||||
//profile = GLProfile.getMaxProgrammable();
|
||||
pgl.pipeline = PGLJava.FIXED;
|
||||
pgl.pipeline = PGL.FIXED;
|
||||
|
||||
/*
|
||||
// Profile auto-selection disabled for the time being.
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.net.URL;
|
||||
public class PShader {
|
||||
protected PApplet parent;
|
||||
protected PGraphicsOpenGL ogl;
|
||||
protected PGLJava pgl;
|
||||
protected PGL pgl;
|
||||
|
||||
protected int programObject;
|
||||
protected int vertexShader;
|
||||
|
||||
@@ -74,7 +74,7 @@ import java.util.Hashtable;
|
||||
|
||||
public class PShape3D extends PShape {
|
||||
protected PGraphicsOpenGL ogl;
|
||||
protected PGLJava pgl;
|
||||
protected PGL pgl;
|
||||
|
||||
protected PShape3D root;
|
||||
protected int glMode;
|
||||
@@ -243,7 +243,7 @@ public class PShape3D extends PShape {
|
||||
ogl = (PGraphicsOpenGL)parent.g;
|
||||
pgl = ogl.pgl;
|
||||
|
||||
glMode = PGLJava.STATIC_DRAW;
|
||||
glMode = PGL.STATIC_DRAW;
|
||||
|
||||
glFillVertexBufferID = 0;
|
||||
glFillColorBufferID = 0;
|
||||
@@ -322,11 +322,11 @@ public class PShape3D extends PShape {
|
||||
|
||||
public void setMode(int mode) {
|
||||
if (mode == STATIC) {
|
||||
glMode = PGLJava.STATIC_DRAW;
|
||||
glMode = PGL.STATIC_DRAW;
|
||||
} else if (mode == DYNAMIC) {
|
||||
glMode = PGLJava.DYNAMIC_DRAW;
|
||||
glMode = PGL.DYNAMIC_DRAW;
|
||||
} else if (mode == STREAM) {
|
||||
glMode = PGLJava.STREAM_DRAW;
|
||||
glMode = PGL.STREAM_DRAW;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -623,10 +623,13 @@ public class PShape3D extends PShape {
|
||||
u /= texture.width;
|
||||
v /= texture.height;
|
||||
|
||||
PTexture tex = ogl.getTexture(texture);
|
||||
if (tex.isFlippedY()) {
|
||||
v = 1 - v;
|
||||
}
|
||||
// TODO: GL texture shouldn't be retrieved
|
||||
// until rendering. So how to know if it
|
||||
// is flipped?
|
||||
// PTexture tex = ogl.getTexture(texture);
|
||||
// if (tex.isFlippedY()) {
|
||||
// v = 1 - v;
|
||||
// }
|
||||
}
|
||||
|
||||
float sR, sG, sB, sA, sW;
|
||||
@@ -2716,9 +2719,9 @@ public class PShape3D extends PShape {
|
||||
// size * PGraphicsOpenGL.SIZEOF_INT, IntBuffer.wrap(indices));
|
||||
// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
|
||||
|
||||
pgl.bindIndexBuffer(glFillTexCoordBufferID);
|
||||
pgl.bindIndexBuffer(glFillIndexBufferID);
|
||||
pgl.copyIndexBufferSubData(indices, offset, size, glMode);
|
||||
pgl.unbindVertexBuffer();
|
||||
pgl.unbindIndexBuffer();
|
||||
}
|
||||
|
||||
|
||||
@@ -3318,7 +3321,7 @@ public class PShape3D extends PShape {
|
||||
pgl.enableTexCoordArrays();
|
||||
|
||||
|
||||
pgl.bindVertexBuffer(root.glFillColorBufferID);
|
||||
pgl.bindVertexBuffer(root.glFillVertexBufferID);
|
||||
pgl.setVertexFormat(3, 0, 0);
|
||||
// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, root.glFillColorBufferID);
|
||||
// getGl().glVertexPointer(3, GL.GL_FLOAT, 0, 0);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
package processing.opengl;
|
||||
|
||||
import javax.media.opengl.GL;
|
||||
import javax.media.opengl.GLContext;
|
||||
import processing.core.PApplet;
|
||||
import processing.core.PConstants;
|
||||
@@ -38,7 +39,7 @@ public class PTexture implements PConstants {
|
||||
|
||||
protected PApplet parent; // The Processing applet
|
||||
protected PGraphicsOpenGL ogl; // The main renderer
|
||||
protected PGLJava pgl; // The interface between Processing and OpenGL.
|
||||
protected PGL pgl; // The interface between Processing and OpenGL.
|
||||
protected GLContext context; // The context that created this texture.
|
||||
|
||||
// These are public but use at your own risk!
|
||||
@@ -95,8 +96,8 @@ public class PTexture implements PConstants {
|
||||
context = ogl.getContext();
|
||||
|
||||
glID = 0;
|
||||
|
||||
init(width, height, (Parameters)params);
|
||||
|
||||
init(width, height, (Parameters)params);
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +150,7 @@ public class PTexture implements PConstants {
|
||||
public void init(int width, int height, Parameters params) {
|
||||
setParameters(params);
|
||||
setSize(width, height);
|
||||
allocate();
|
||||
allocate();
|
||||
}
|
||||
|
||||
|
||||
@@ -264,7 +265,7 @@ public class PTexture implements PConstants {
|
||||
// getGl().glBindTexture(glTarget, 0);
|
||||
// getGl().glDisable(glTarget);
|
||||
pgl.bindTexture(glTarget, 0);
|
||||
pgl.enableTexturing(glTarget);
|
||||
pgl.disableTexturing(glTarget);
|
||||
}
|
||||
|
||||
|
||||
@@ -707,7 +708,7 @@ public class PTexture implements PConstants {
|
||||
// getGl().glEnable(glTarget);
|
||||
pgl.enableTexturing(glTarget);
|
||||
|
||||
glID = ogl.createTextureObject();
|
||||
glID = ogl.createTextureObject();
|
||||
|
||||
//getGl().glBindTexture(glTarget, glID);
|
||||
// getGl().glTexParameteri(glTarget, GL.GL_TEXTURE_MIN_FILTER, glMinFilter);
|
||||
@@ -719,12 +720,11 @@ public class PTexture implements PConstants {
|
||||
pgl.setTexMagFilter(glTarget, glMagFilter);
|
||||
pgl.setTexWrapS(glTarget, glWrapS);
|
||||
pgl.setTexWrapT(glTarget, glWrapT);
|
||||
|
||||
|
||||
|
||||
// First, we use glTexImage2D to set the full size of the texture (glW/glH might be diff
|
||||
// from w/h in the case that the GPU doesn't support NPOT textures)
|
||||
//getGl().glTexImage2D(glTarget, 0, glFormat, glWidth, glHeight, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, null);
|
||||
pgl.initTex(glFormat, glFormat, glWidth, glHeight);
|
||||
// pgl.gl.glTexImage2D(glTarget, 0, glFormat, glWidth, glHeight, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, null);
|
||||
pgl.initTex(glTarget, glFormat, glWidth, glHeight);
|
||||
|
||||
// Once OpenGL knows the size of the new texture, we make sure it doesn't
|
||||
// contain any garbage in the region of interest (0, 0, width, height):
|
||||
@@ -830,35 +830,35 @@ public class PTexture implements PConstants {
|
||||
public Parameters getParameters() {
|
||||
Parameters res = new Parameters();
|
||||
|
||||
if (glTarget == PGLJava.TEXTURE_2D) {
|
||||
if (glTarget == PGL.TEXTURE_2D) {
|
||||
res.target = TEXTURE2D;
|
||||
}
|
||||
|
||||
if (glFormat == PGLJava.RGB) {
|
||||
if (glFormat == PGL.RGB) {
|
||||
res.format = RGB;
|
||||
} else if (glFormat == PGLJava.RGBA) {
|
||||
} else if (glFormat == PGL.RGBA) {
|
||||
res.format = ARGB;
|
||||
} else if (glFormat == PGLJava.ALPHA) {
|
||||
} else if (glFormat == PGL.ALPHA) {
|
||||
res.format = ALPHA;
|
||||
}
|
||||
|
||||
if (glMinFilter == PGLJava.NEAREST) {
|
||||
if (glMinFilter == PGL.NEAREST) {
|
||||
res.sampling = POINT;
|
||||
} else if (glMinFilter == PGLJava.LINEAR) {
|
||||
} else if (glMinFilter == PGL.LINEAR) {
|
||||
res.sampling = BILINEAR;
|
||||
} else if (glMinFilter == PGLJava.LINEAR_MIPMAP_LINEAR) {
|
||||
} else if (glMinFilter == PGL.LINEAR_MIPMAP_LINEAR) {
|
||||
res.sampling = TRILINEAR;
|
||||
}
|
||||
|
||||
if (glWrapS == PGLJava.CLAMP_TO_EDGE) {
|
||||
if (glWrapS == PGL.CLAMP_TO_EDGE) {
|
||||
res.wrapU = CLAMP;
|
||||
} else if (glWrapS == PGLJava.REPEAT) {
|
||||
} else if (glWrapS == PGL.REPEAT) {
|
||||
res.wrapU = REPEAT;
|
||||
}
|
||||
|
||||
if (glWrapT == PGLJava.CLAMP_TO_EDGE) {
|
||||
if (glWrapT == PGL.CLAMP_TO_EDGE) {
|
||||
res.wrapV = CLAMP;
|
||||
} else if (glWrapT == PGLJava.REPEAT) {
|
||||
} else if (glWrapT == PGL.REPEAT) {
|
||||
res.wrapV = REPEAT;
|
||||
}
|
||||
|
||||
@@ -873,51 +873,51 @@ public class PTexture implements PConstants {
|
||||
*/
|
||||
protected void setParameters(Parameters params) {
|
||||
if (params.target == TEXTURE2D) {
|
||||
glTarget = PGLJava.TEXTURE_2D;
|
||||
glTarget = PGL.TEXTURE_2D;
|
||||
} else {
|
||||
throw new RuntimeException("OPENGL2: Unknown texture target");
|
||||
}
|
||||
|
||||
if (params.format == RGB) {
|
||||
glFormat = PGLJava.RGB;
|
||||
glFormat = PGL.RGB;
|
||||
} else if (params.format == ARGB) {
|
||||
glFormat = PGLJava.RGBA;
|
||||
glFormat = PGL.RGBA;
|
||||
} else if (params.format == ALPHA) {
|
||||
glFormat = PGLJava.ALPHA;
|
||||
glFormat = PGL.ALPHA;
|
||||
} else {
|
||||
throw new RuntimeException("OPENGL2: Unknown texture format");
|
||||
}
|
||||
|
||||
if (params.sampling == POINT) {
|
||||
glMagFilter = PGLJava.NEAREST;
|
||||
glMinFilter = PGLJava.NEAREST;
|
||||
glMagFilter = PGL.NEAREST;
|
||||
glMinFilter = PGL.NEAREST;
|
||||
} else if (params.sampling == BILINEAR) {
|
||||
glMagFilter = PGLJava.LINEAR;
|
||||
glMinFilter = PGLJava.LINEAR;
|
||||
glMagFilter = PGL.LINEAR;
|
||||
glMinFilter = PGL.LINEAR;
|
||||
} else if (params.sampling == TRILINEAR) {
|
||||
glMagFilter = PGLJava.LINEAR;
|
||||
glMinFilter = PGLJava.LINEAR_MIPMAP_LINEAR;
|
||||
glMagFilter = PGL.LINEAR;
|
||||
glMinFilter = PGL.LINEAR_MIPMAP_LINEAR;
|
||||
} else {
|
||||
throw new RuntimeException("OPENGL2: Unknown texture filtering mode");
|
||||
}
|
||||
|
||||
if (params.wrapU == CLAMP) {
|
||||
glWrapS = PGLJava.CLAMP_TO_EDGE;
|
||||
glWrapS = PGL.CLAMP_TO_EDGE;
|
||||
} else if (params.wrapU == REPEAT) {
|
||||
glWrapS = PGLJava.REPEAT;
|
||||
glWrapS = PGL.REPEAT;
|
||||
} else {
|
||||
throw new RuntimeException("OPENGL2: Unknown wrapping mode");
|
||||
}
|
||||
|
||||
if (params.wrapV == CLAMP) {
|
||||
glWrapT = PGLJava.CLAMP_TO_EDGE;
|
||||
glWrapT = PGL.CLAMP_TO_EDGE;
|
||||
} else if (params.wrapV == REPEAT) {
|
||||
glWrapT = PGLJava.REPEAT;
|
||||
glWrapT = PGL.REPEAT;
|
||||
} else {
|
||||
throw new RuntimeException("OPENGL2: Unknown wrapping mode");
|
||||
}
|
||||
|
||||
usingMipmaps = glMinFilter == PGLJava.LINEAR_MIPMAP_LINEAR;
|
||||
usingMipmaps = glMinFilter == PGL.LINEAR_MIPMAP_LINEAR;
|
||||
|
||||
flippedX = false;
|
||||
flippedY = false;
|
||||
|
||||
Reference in New Issue
Block a user