mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
getTexture method is now public in renderer class, and GL parameters in PTexture, PShape3D, PFramebuffer are also public
This commit is contained in:
@@ -45,13 +45,13 @@ public class PFramebuffer implements PConstants {
|
||||
protected GL gl;
|
||||
protected GL2GL3 gl2;
|
||||
|
||||
protected int glFboID;
|
||||
protected int glDepthBufferID;
|
||||
protected int glStencilBufferID;
|
||||
protected int glDepthStencilBufferID;
|
||||
protected int glColorBufferMultisampleID;
|
||||
protected int width;
|
||||
protected int height;
|
||||
public int glFboID;
|
||||
public int glDepthBufferID;
|
||||
public int glStencilBufferID;
|
||||
public int glDepthStencilBufferID;
|
||||
public int glColorBufferMultisampleID;
|
||||
public int width;
|
||||
public int height;
|
||||
|
||||
protected int numColorBuffers;
|
||||
protected int[] colorBufferAttchPoints;
|
||||
@@ -157,15 +157,15 @@ public class PFramebuffer implements PConstants {
|
||||
|
||||
for (int i = 0; i < numColorBuffers; i++) {
|
||||
colorBufferAttchPoints[i] = GL.GL_COLOR_ATTACHMENT0 + i;
|
||||
glColorBufferTargets[i] = textures[i].getGLTarget();
|
||||
glColorBufferIDs[i] = textures[i].getGLID();
|
||||
glColorBufferTargets[i] = textures[i].glTarget;
|
||||
glColorBufferIDs[i] = textures[i].glID;
|
||||
gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, colorBufferAttchPoints[i],
|
||||
glColorBufferTargets[i], glColorBufferIDs[i], 0);
|
||||
}
|
||||
|
||||
if (validFbo() && textures != null && 0 < textures.length) {
|
||||
width = textures[0].getGLWidth();
|
||||
height = textures[0].getGLHeight();
|
||||
width = textures[0].glWidth;
|
||||
height = textures[0].glHeight;
|
||||
}
|
||||
|
||||
pgl.popFramebuffer();
|
||||
@@ -174,8 +174,8 @@ public class PFramebuffer implements PConstants {
|
||||
glColorBufferTargets = new int[numColorBuffers];
|
||||
glColorBufferIDs = new int[numColorBuffers];
|
||||
for (int i = 0; i < numColorBuffers; i++) {
|
||||
glColorBufferTargets[i] = textures[i].getGLTarget();
|
||||
glColorBufferIDs[i] = textures[i].getGLID();
|
||||
glColorBufferTargets[i] = textures[i].glTarget;
|
||||
glColorBufferIDs[i] = textures[i].glID;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -354,7 +354,7 @@ public class PFramebuffer implements PConstants {
|
||||
public void backupScreen() {
|
||||
if (pixelBuffer == null) allocatePixelBuffer();
|
||||
gl.glReadPixels(0, 0, width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, pixelBuffer);
|
||||
copyToTexture(pixelBuffer, backupTexture.getGLID(), backupTexture.getGLTarget());
|
||||
copyToTexture(pixelBuffer, backupTexture.glID, backupTexture.glTarget);
|
||||
}
|
||||
|
||||
// Draws the contents of the backup texture to the screen.
|
||||
|
||||
@@ -127,23 +127,23 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
|
||||
// GL parameters
|
||||
|
||||
static protected boolean glparamsRead = false;
|
||||
static protected boolean glParamsRead = false;
|
||||
|
||||
/** Extensions used by Processing */
|
||||
static protected boolean npotTexSupported;
|
||||
static protected boolean mipmapGeneration;
|
||||
static protected boolean matrixGetSupported;
|
||||
static protected boolean vboSupported;
|
||||
static protected boolean fboSupported;
|
||||
static protected boolean blendEqSupported;
|
||||
static protected boolean texenvCrossbarSupported;
|
||||
static protected boolean fboMultisampleSupported;
|
||||
static public boolean npotTexSupported;
|
||||
static public boolean mipmapGeneration;
|
||||
static public boolean matrixGetSupported;
|
||||
static public boolean vboSupported;
|
||||
static public boolean fboSupported;
|
||||
static public boolean blendEqSupported;
|
||||
static public boolean texenvCrossbarSupported;
|
||||
static public boolean fboMultisampleSupported;
|
||||
|
||||
/** Some hardware limits */
|
||||
static protected int maxTextureSize;
|
||||
static protected float maxPointSize;
|
||||
static protected float maxLineWidth;
|
||||
static protected int maxTextureUnits;
|
||||
static public int maxTextureSize;
|
||||
static public float maxPointSize;
|
||||
static public float maxLineWidth;
|
||||
static public int maxTextureUnits;
|
||||
|
||||
/** OpenGL information strings */
|
||||
static public String OPENGL_VENDOR;
|
||||
@@ -899,7 +899,7 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
|
||||
getGLObjects();
|
||||
|
||||
if (!glparamsRead) {
|
||||
if (!glParamsRead) {
|
||||
getGLParameters();
|
||||
}
|
||||
|
||||
@@ -2383,9 +2383,9 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
break;
|
||||
}
|
||||
|
||||
gl.glEnable(tex.getGLTarget());
|
||||
gl.glEnable(tex.glTarget);
|
||||
gl.glActiveTexture(GL.GL_TEXTURE0 + t);
|
||||
gl.glBindTexture(tex.getGLTarget(), tex.getGLID());
|
||||
gl.glBindTexture(tex.glTarget, tex.glID);
|
||||
renderTextures[tcount] = tex;
|
||||
|
||||
tcount++;
|
||||
@@ -2400,9 +2400,9 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
} else if (images[0] != null) {
|
||||
PTexture tex = getTexture(images[0]);
|
||||
if (tex != null) {
|
||||
gl.glEnable(tex.getGLTarget());
|
||||
gl.glEnable(tex.glTarget);
|
||||
gl.glActiveTexture(GL.GL_TEXTURE0);
|
||||
gl.glBindTexture(tex.getGLTarget(), tex.getGLID());
|
||||
gl.glBindTexture(tex.glTarget, tex.glID);
|
||||
renderTextures[0] = tex;
|
||||
tcount = 1;
|
||||
}
|
||||
@@ -2766,7 +2766,7 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
for (int t = 0; t < tcount; t++) {
|
||||
PTexture tex = renderTextures[t];
|
||||
gl.glActiveTexture(GL.GL_TEXTURE0 + t);
|
||||
gl.glBindTexture(tex.getGLTarget(), 0);
|
||||
gl.glBindTexture(tex.glTarget, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -2777,7 +2777,7 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
// glBindTexture in the second iteration.
|
||||
for (int t = 0; t < tcount; t++) {
|
||||
PTexture tex = renderTextures[t];
|
||||
gl.glDisable(tex.getGLTarget());
|
||||
gl.glDisable(tex.glTarget);
|
||||
}
|
||||
|
||||
|
||||
@@ -6099,22 +6099,22 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
if (texBlendMode == REPLACE) {
|
||||
// Texture 0:
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE0);
|
||||
gl2f.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl2f.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
// Simply sample the texture:
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
|
||||
// Texture 1:
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE1);
|
||||
gl2f.glBindTexture(textures[1].getGLTarget(), textures[1].getGLID());
|
||||
gl2f.glBindTexture(textures[1].glTarget, textures[1].glID);
|
||||
// Sample the texture, replacing the previous one.
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
|
||||
} else if (texBlendMode == BLEND) {
|
||||
// Texture 0:
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE0);
|
||||
gl2f.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl2f.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
|
||||
// Texture 1:
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE1);
|
||||
gl2f.glBindTexture(textures[1].getGLTarget(), textures[1].getGLID());
|
||||
gl2f.glBindTexture(textures[1].glTarget, textures[1].glID);
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_COMBINE);
|
||||
// Interpolate RGB with RGB...
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_COMBINE_RGB, GL2.GL_INTERPOLATE);
|
||||
@@ -6137,12 +6137,12 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
} else if (texBlendMode == MULTIPLY) {
|
||||
// Texture 0:
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE0);
|
||||
gl2f.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl2f.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
// Simply sample the texture.
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
|
||||
// Texture 1:
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE1);
|
||||
gl2f.glBindTexture(textures[1].getGLTarget(), textures[1].getGLID());
|
||||
gl2f.glBindTexture(textures[1].glTarget, textures[1].glID);
|
||||
// Combine this texture with the previous one.
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_COMBINE);
|
||||
// Modulate (multiply) RGB with RGB:
|
||||
@@ -6159,11 +6159,11 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_OPERAND1_ALPHA, GL2.GL_SRC_ALPHA);
|
||||
} else if (texBlendMode == ADD) {
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE0);
|
||||
gl2f.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl2f.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
|
||||
// Add RGB with RGB:
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE1);
|
||||
gl2f.glBindTexture(textures[1].getGLTarget(), textures[1].getGLID());
|
||||
gl2f.glBindTexture(textures[1].glTarget, textures[1].glID);
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_COMBINE);
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_COMBINE_RGB, GL2.GL_ADD);
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_SRC0_RGB, GL2.GL_PREVIOUS);
|
||||
@@ -6179,11 +6179,11 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
} else if (texBlendMode == SUBTRACT) {
|
||||
// Texture 0:
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE0);
|
||||
gl2f.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl2f.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
|
||||
// Texture 1:
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE1);
|
||||
gl2f.glBindTexture(textures[1].getGLTarget(), textures[1].getGLID());
|
||||
gl2f.glBindTexture(textures[1].glTarget, textures[1].glID);
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_COMBINE);
|
||||
// Subtract RGB with RGB:
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_COMBINE_RGB, GL2.GL_SUBTRACT);
|
||||
@@ -6208,7 +6208,7 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
if (texBlendMode == REPLACE) {
|
||||
// Sampler 0:
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE0);
|
||||
gl2f.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl2f.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
// Replace using texture 1:
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_COMBINE);
|
||||
// Replace RGB:
|
||||
@@ -6224,7 +6224,7 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
} else if (texBlendMode == BLEND) {
|
||||
// Sampler 0: interpolation between textures 0 and 1 using alpha of 1.
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE0);
|
||||
gl2f.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl2f.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_COMBINE);
|
||||
// Interpolate RGB with RGB...
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_COMBINE_RGB, GL2.GL_INTERPOLATE);
|
||||
@@ -6249,7 +6249,7 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
} else if (texBlendMode == MULTIPLY) {
|
||||
// Sampler 0:
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE0);
|
||||
gl2f.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl2f.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
// Modulate (multiply) texture 0 with texture 1.
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_COMBINE);
|
||||
// Modulate RGB with RGB:
|
||||
@@ -6269,7 +6269,7 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
} else if (texBlendMode == ADD) {
|
||||
// Sampler 0:
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE0);
|
||||
gl2f.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl2f.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
// Add texture 0 to texture 1:
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_COMBINE);
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_COMBINE_RGB, GL2.GL_ADD);
|
||||
@@ -6288,7 +6288,7 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
} else if (texBlendMode == SUBTRACT) {
|
||||
// Sampler 0:
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE0);
|
||||
gl2f.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl2f.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
// Substract texture 1 from texture 0:
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_COMBINE);
|
||||
// Subtract RGB with RGB:
|
||||
@@ -6318,7 +6318,7 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
|
||||
protected void modulateWithPrimaryColor(int unit, PTexture tex) {
|
||||
gl2f.glActiveTexture(GL2.GL_TEXTURE0 + unit);
|
||||
gl2f.glBindTexture(tex.getGLTarget(), tex.getGLID());
|
||||
gl2f.glBindTexture(tex.glTarget, tex.glID);
|
||||
// Interpolate RGB of previous color (result of blending in sampler 0) with RGB
|
||||
// of primary color (tinted and lit from pixel)...
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_COMBINE);
|
||||
@@ -6372,12 +6372,22 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
|
||||
// TEXTURE UTILS
|
||||
|
||||
/**
|
||||
* This utility method returns the texture associated to the renderer's.
|
||||
* drawing surface, making sure is updated to reflect the current contents
|
||||
* off the screen (or offscreen drawing surface).
|
||||
*/
|
||||
public PTexture getTexture() {
|
||||
loadTexture();
|
||||
return texture;
|
||||
}
|
||||
|
||||
/**
|
||||
* This utility method returns the texture associated to the image.
|
||||
* creating and/or updating it if needed.
|
||||
* @param img the image to have a texture metadata associated to it
|
||||
*/
|
||||
protected PTexture getTexture(PImage img) {
|
||||
public PTexture getTexture(PImage img) {
|
||||
PTexture tex = (PTexture)img.getCache(ogl);
|
||||
if (tex == null) {
|
||||
tex = addTexture(img);
|
||||
@@ -6439,8 +6449,8 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
gl2f.glPushMatrix();
|
||||
gl2f.glLoadIdentity();
|
||||
|
||||
gl.glEnable(tex.getGLTarget());
|
||||
gl.glBindTexture(tex.getGLTarget(), tex.getGLID());
|
||||
gl.glEnable(tex.glTarget);
|
||||
gl.glBindTexture(tex.glTarget, tex.glID);
|
||||
gl.glDepthMask(false);
|
||||
gl.glDisable(GL.GL_BLEND);
|
||||
|
||||
@@ -6457,8 +6467,8 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
// with the current fragment color.
|
||||
gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
|
||||
|
||||
gl.glBindTexture(tex.getGLTarget(), 0);
|
||||
gl.glDisable(tex.getGLTarget());
|
||||
gl.glBindTexture(tex.glTarget, 0);
|
||||
gl.glDisable(tex.glTarget);
|
||||
|
||||
if (hints[DISABLE_DEPTH_MASK]) {
|
||||
gl.glDepthMask(false);
|
||||
@@ -6572,11 +6582,11 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
* Utility function to copy buffer to texture.
|
||||
*/
|
||||
protected void copyToTexture(PTexture tex, IntBuffer buffer, int x, int y, int w, int h) {
|
||||
gl.glEnable(tex.getGLTarget());
|
||||
gl.glBindTexture(tex.getGLTarget(), tex.getGLID());
|
||||
gl.glTexSubImage2D(tex.getGLTarget(), 0, x, y, w, h, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer);
|
||||
gl.glBindTexture(tex.getGLTarget(), 0);
|
||||
gl.glDisable(tex.getGLTarget());
|
||||
gl.glEnable(tex.glTarget);
|
||||
gl.glBindTexture(tex.glTarget, tex.glID);
|
||||
gl.glTexSubImage2D(tex.glTarget, 0, x, y, w, h, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer);
|
||||
gl.glBindTexture(tex.glTarget, 0);
|
||||
gl.glDisable(tex.glTarget);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
@@ -6764,8 +6774,7 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
boolean opengl4X = hints[ENABLE_OPENGL_4X_SMOOTH];
|
||||
|
||||
offscreenMultisample = false;
|
||||
offscreenFramebuffer = new PFramebuffer(parent, texture.getGLWidth(),
|
||||
texture.getGLHeight(), false);
|
||||
offscreenFramebuffer = new PFramebuffer(parent, texture.glWidth, texture.glHeight, false);
|
||||
|
||||
// We need the GL2GL3 profile to access the glRenderbufferStorageMultisample
|
||||
// function used in multisampled (antialiased) offscreen rendering.
|
||||
@@ -6776,8 +6785,7 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
} else if (opengl4X) {
|
||||
nsamples = 4;
|
||||
}
|
||||
offscreenFramebufferMultisample = new PFramebuffer(parent, texture.getGLWidth(),
|
||||
texture.getGLHeight(), false);
|
||||
offscreenFramebufferMultisample = new PFramebuffer(parent, texture.glWidth, texture.glHeight, false);
|
||||
try {
|
||||
offscreenFramebufferMultisample.addColorBufferMultisample(nsamples);
|
||||
offscreenMultisample = true;
|
||||
@@ -6918,7 +6926,7 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
gl.glGetIntegerv(GL2.GL_MAX_TEXTURE_UNITS, temp, 0);
|
||||
maxTextureUnits = PApplet.min(MAX_TEXTURES, temp[0]);
|
||||
|
||||
glparamsRead = true;
|
||||
glParamsRead = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -7255,9 +7263,9 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
if (0 < texCount) {
|
||||
for (int t = 0; t < texCount; t++) {
|
||||
PTexture tex = texturesArray[t];
|
||||
gl.glEnable(tex.getGLTarget());
|
||||
gl.glEnable(tex.glTarget);
|
||||
gl.glActiveTexture(GL.GL_TEXTURE0 + t);
|
||||
gl.glBindTexture(tex.getGLTarget(), tex.getGLID());
|
||||
gl.glBindTexture(tex.glTarget, tex.glID);
|
||||
gl2f.glClientActiveTexture(GL.GL_TEXTURE0 + t);
|
||||
gl2f.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
@@ -7269,13 +7277,13 @@ public class PGraphicsOpenGL2 extends PGraphics {
|
||||
for (int t = 0; t < texCount; t++) {
|
||||
PTexture tex = texturesArray[t];
|
||||
gl.glActiveTexture(GL.GL_TEXTURE0 + t);
|
||||
gl.glBindTexture(tex.getGLTarget(), 0);
|
||||
gl.glBindTexture(tex.glTarget, 0);
|
||||
gl2f.glClientActiveTexture(GL.GL_TEXTURE0 + t);
|
||||
gl2f.glDisableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
for (int t = 0; t < texCount; t++) {
|
||||
PTexture tex = texturesArray[t];
|
||||
gl.glDisable(tex.getGLTarget());
|
||||
gl.glDisable(tex.glTarget);
|
||||
}
|
||||
}
|
||||
gl2f.glDisableClientState(GL2.GL_NORMAL_ARRAY);
|
||||
|
||||
@@ -59,18 +59,20 @@ public class PShape3D extends PShape {
|
||||
protected static final int TEXCOORDS = 3;
|
||||
|
||||
// ROOT shape properties:
|
||||
|
||||
// STATIC, DYNAMIC, or STREAM
|
||||
protected int glUsage;
|
||||
|
||||
// Number of texture buffers currently in use:
|
||||
protected int numTexBuffers;
|
||||
|
||||
// STATIC, DYNAMIC, or STREAM
|
||||
// TODO: vertex, color, normal and texcoord data can potentially have
|
||||
// different usage modes.
|
||||
public int glUsage;
|
||||
|
||||
// The OpenGL IDs for the different VBOs
|
||||
protected int glVertexBufferID;
|
||||
protected int glColorBufferID;
|
||||
protected int glNormalBufferID;
|
||||
protected int[] glTexCoordBufferID;
|
||||
public int glVertexBufferID;
|
||||
public int glColorBufferID;
|
||||
public int glNormalBufferID;
|
||||
public int[] glTexCoordBufferID;
|
||||
|
||||
// The float buffers (directly allocated) used to put data into the VBOs
|
||||
protected FloatBuffer vertexBuffer;
|
||||
@@ -2359,9 +2361,9 @@ public class PShape3D extends PShape {
|
||||
break;
|
||||
}
|
||||
|
||||
gl.glEnable(tex.getGLTarget());
|
||||
gl.glEnable(tex.glTarget);
|
||||
gl.glActiveTexture(GL.GL_TEXTURE0 + t);
|
||||
gl.glBindTexture(tex.getGLTarget(), tex.getGLID());
|
||||
gl.glBindTexture(tex.glTarget, tex.glID);
|
||||
renderTextures[numTextures] = tex;
|
||||
numTextures++;
|
||||
} else {
|
||||
@@ -2439,11 +2441,11 @@ public class PShape3D extends PShape {
|
||||
for (int t = 0; t < numTextures; t++) {
|
||||
PTexture tex = renderTextures[t];
|
||||
gl.glActiveTexture(GL.GL_TEXTURE0 + t);
|
||||
gl.glBindTexture(tex.getGLTarget(), 0);
|
||||
gl.glBindTexture(tex.glTarget, 0);
|
||||
}
|
||||
for (int t = 0; t < numTextures; t++) {
|
||||
PTexture tex = renderTextures[t];
|
||||
gl.glDisable(tex.getGLTarget());
|
||||
gl.glDisable(tex.glTarget);
|
||||
}
|
||||
if (pointSprites) {
|
||||
gl.glDisable(GL2.GL_POINT_SPRITE);
|
||||
|
||||
@@ -43,16 +43,16 @@ public class PTexture implements PConstants {
|
||||
protected PGraphicsOpenGL2 ogl;
|
||||
protected GL gl;
|
||||
|
||||
protected int glID;
|
||||
protected int glTarget;
|
||||
protected int glFormat;
|
||||
protected int glMinFilter;
|
||||
protected int glMagFilter;
|
||||
protected int glWrapS;
|
||||
protected int glWrapT;
|
||||
|
||||
protected int glWidth;
|
||||
protected int glHeight;
|
||||
// These are public but use at your own risk!
|
||||
public int glID;
|
||||
public int glTarget;
|
||||
public int glFormat;
|
||||
public int glMinFilter;
|
||||
public int glMagFilter;
|
||||
public int glWrapS;
|
||||
public int glWrapT;
|
||||
public int glWidth;
|
||||
public int glHeight;
|
||||
|
||||
protected boolean usingMipmaps;
|
||||
protected float maxTexCoordU;
|
||||
@@ -350,83 +350,12 @@ public class PTexture implements PConstants {
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
// Get OpenGL parameters
|
||||
|
||||
|
||||
protected int getGLWidth() {
|
||||
return glWidth;
|
||||
}
|
||||
|
||||
|
||||
protected int getGLHeight() {
|
||||
return glHeight;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provides the ID of the OpenGL texture object.
|
||||
* @return int
|
||||
*/
|
||||
protected int getGLID() {
|
||||
return glID;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the texture target.
|
||||
* @return int
|
||||
*/
|
||||
protected int getGLTarget() {
|
||||
return glTarget;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the texture internal format.
|
||||
* @return int
|
||||
*/
|
||||
protected int getGLFormat() {
|
||||
return glFormat;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the texture minimization filter.
|
||||
* @return int
|
||||
*/
|
||||
protected int getGLMinFilter() {
|
||||
return glMinFilter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the texture magnification filter.
|
||||
* @return int
|
||||
*/
|
||||
protected int getGLMagFilter() {
|
||||
return glMagFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the texture wrapping mode for the S coordinate.
|
||||
* @return int
|
||||
*/
|
||||
protected int getGLWrapS() {
|
||||
return glWrapS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the texture wrapping mode for the T coordinate.
|
||||
* @return int
|
||||
*/
|
||||
protected int getGLWrapT() {
|
||||
return glWrapT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true or false whether or not the texture is using mipmaps.
|
||||
* @return boolean
|
||||
*/
|
||||
protected boolean usingMipmaps() {
|
||||
public boolean usingMipmaps() {
|
||||
return usingMipmaps;
|
||||
}
|
||||
|
||||
@@ -435,7 +364,7 @@ public class PTexture implements PConstants {
|
||||
* Returns the maximum possible value for the texture coordinate U (horizontal).
|
||||
* @return float
|
||||
*/
|
||||
protected float getMaxTexCoordU() {
|
||||
public float getMaxTexCoordU() {
|
||||
return maxTexCoordU;
|
||||
}
|
||||
|
||||
@@ -444,7 +373,7 @@ public class PTexture implements PConstants {
|
||||
* Returns the maximum possible value for the texture coordinate V (vertical).
|
||||
* @return float
|
||||
*/
|
||||
protected float getMaxTexCoordV() {
|
||||
public float getMaxTexCoordV() {
|
||||
return maxTexCoordV;
|
||||
}
|
||||
|
||||
@@ -453,7 +382,7 @@ public class PTexture implements PConstants {
|
||||
* Returns true if the texture is flipped along the horizontal direction.
|
||||
* @return boolean;
|
||||
*/
|
||||
protected boolean isFlippedX() {
|
||||
public boolean isFlippedX() {
|
||||
return flippedX;
|
||||
}
|
||||
|
||||
@@ -462,7 +391,7 @@ public class PTexture implements PConstants {
|
||||
* Sets the texture as flipped or not flipped on the horizontal direction.
|
||||
* @param v boolean;
|
||||
*/
|
||||
protected void setFlippedX(boolean v) {
|
||||
public void setFlippedX(boolean v) {
|
||||
flippedX = v;
|
||||
}
|
||||
|
||||
@@ -471,7 +400,7 @@ public class PTexture implements PConstants {
|
||||
* Returns true if the texture is flipped along the vertical direction.
|
||||
* @return boolean;
|
||||
*/
|
||||
protected boolean isFlippedY() {
|
||||
public boolean isFlippedY() {
|
||||
return flippedY;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user