From 2c3b444839543eb64e174137cfd4c7c0d2b4b72d Mon Sep 17 00:00:00 2001 From: benfry Date: Thu, 31 May 2012 14:13:56 +0000 Subject: [PATCH] cleaning up name space from GL mess --- core/src/processing/core/PApplet.java | 12 -- core/src/processing/core/PConstants.java | 42 ------- core/src/processing/core/PGraphics.java | 13 --- .../{PFramebuffer.java => FrameBuffer.java} | 22 ++-- .../src/processing/opengl/PFontTexture.java | 16 +-- .../processing/opengl/PGraphicsOpenGL.java | 106 +++++++++++------- .../src/processing/opengl/PShapeOpenGL.java | 2 +- .../opengl/{PTexture.java => Texture.java} | 66 ++++++++--- 8 files changed, 133 insertions(+), 146 deletions(-) rename java/libraries/opengl/src/processing/opengl/{PFramebuffer.java => FrameBuffer.java} (95%) rename java/libraries/opengl/src/processing/opengl/{PTexture.java => Texture.java} (90%) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 4a9573050..55c81423d 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -9939,18 +9939,6 @@ public class PApplet extends Applet } - public void textureWrap(int wrap) { - if (recorder != null) recorder.textureWrap(wrap); - g.textureWrap(wrap); - } - - - public void textureQuality(int quality) { - if (recorder != null) recorder.textureQuality(quality); - g.textureQuality(quality); - } - - /** * ( begin auto-generated from texture.xml ) * diff --git a/core/src/processing/core/PConstants.java b/core/src/processing/core/PConstants.java index 448724d08..4334fc81f 100644 --- a/core/src/processing/core/PConstants.java +++ b/core/src/processing/core/PConstants.java @@ -432,48 +432,6 @@ public interface PConstants { // text alignment modes // are inherited from LEFT, CENTER, RIGHT - // textures - - /** This constant identifies the texture target GL_TEXTURE_2D, that is, - * textures with normalized coordinates */ - public static final int TEXTURE2D = 0; - - /** Texture quality constants */ - public static final int LOW = 0; - public static final int MEDIUM = 1; - public static final int HIGH = 2; - public static final int BEST = 3; - - /** Point sampling: both magnification and minification filtering are set to nearest */ - //public static final int POINT = 2; // shared with shape feature - /** Linear sampling: magnification filtering is nearest, minification set to linear */ - public static final int LINEAR = 3; - /** Bilinear sampling: both magnification filtering is set to linear and minification - * either to linear-mipmap-nearest (linear interplation is used within a mipmap, but - * not between different mipmaps). */ - public static final int BILINEAR = 4; - /** Trilinear sampling: magnification filtering set to linear, minification to - * linear-mipmap-linear, which offers the best mipmap quality since linear - * interpolation to compute the value in each of two maps and then interpolates linearly - * between these two value. */ - public static final int TRILINEAR = 5; - - /** This constant identifies the clamp-to-edge wrapping mode */ - public static final int CLAMP = 0; - /** This constant identifies the repeat wrapping mode */ - public static final int REPEAT = 1; - - - // shaders - - static public final int FLAT_SHADER = 0; - static public final int LIGHT_SHADER = 1; - static public final int TEXTURE_SHADER = 2; - static public final int FULL_SHADER = 3; - static public final int LINE3D_SHADER = 4; - static public final int POINT3D_SHADER = 5; - - // stroke modes static final int SQUARE = 1 << 0; // called 'butt' in the svg spec diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index 52a396edb..43bd5c01f 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -545,9 +545,6 @@ public class PGraphics extends PImage implements PConstants { */ public int textureMode = IMAGE; - public int textureWrap = CLAMP; - public int textureQuality = BEST; - /** * Current horizontal coordinate for texture, will always * be between 0 and 1, even if using textureMode(IMAGE). @@ -1067,16 +1064,6 @@ public class PGraphics extends PImage implements PConstants { } - public void textureWrap(int wrap) { - this.textureWrap = wrap; - } - - - public void textureQuality(int quality) { - this.textureQuality = quality; - } - - /** * ( begin auto-generated from texture.xml ) * diff --git a/java/libraries/opengl/src/processing/opengl/PFramebuffer.java b/java/libraries/opengl/src/processing/opengl/FrameBuffer.java similarity index 95% rename from java/libraries/opengl/src/processing/opengl/PFramebuffer.java rename to java/libraries/opengl/src/processing/opengl/FrameBuffer.java index 52610130d..49ceb13ce 100644 --- a/java/libraries/opengl/src/processing/opengl/PFramebuffer.java +++ b/java/libraries/opengl/src/processing/opengl/FrameBuffer.java @@ -39,7 +39,7 @@ import java.nio.IntBuffer; * By Andres Colubri. */ -public class PFramebuffer implements PConstants { +public class FrameBuffer implements PConstants { protected PApplet parent; protected PGraphicsOpenGL pg; protected PGL pgl; @@ -61,22 +61,22 @@ public class PFramebuffer implements PConstants { protected int nsamples; protected int numColorBuffers; - protected PTexture[] colorBufferTex; + protected Texture[] colorBufferTex; protected boolean screenFb; protected boolean noDepth; protected IntBuffer pixelBuffer; - PFramebuffer(PApplet parent, int w, int h) { + FrameBuffer(PApplet parent, int w, int h) { this(parent, w, h, 1, 1, 0, 0, false, false); } - PFramebuffer(PApplet parent, int w, int h, boolean screen) { + FrameBuffer(PApplet parent, int w, int h, boolean screen) { this(parent, w, h, 1, 1, 0, 0, false, screen); } - PFramebuffer(PApplet parent, int w, int h, int samples, int colorBuffers, + FrameBuffer(PApplet parent, int w, int h, int samples, int colorBuffers, int depthBits, int stencilBits, boolean packedDepthStencil, boolean screen) { this.parent = parent; @@ -109,7 +109,7 @@ public class PFramebuffer implements PConstants { } numColorBuffers = colorBuffers; - colorBufferTex = new PTexture[numColorBuffers]; + colorBufferTex = new Texture[numColorBuffers]; for (int i = 0; i < numColorBuffers; i++) { colorBufferTex[i] = null; } @@ -171,7 +171,7 @@ public class PFramebuffer implements PConstants { pg.popFramebuffer(); } - public void copy(PFramebuffer dest) { + public void copy(FrameBuffer dest) { pgl.glBindFramebuffer(PGL.GL_READ_FRAMEBUFFER, this.glFboID); pgl.glBindFramebuffer(PGL.GL_DRAW_FRAMEBUFFER, dest.glFboID); pgl.glBlitFramebuffer(0, 0, this.width, this.height, @@ -228,17 +228,17 @@ public class PFramebuffer implements PConstants { // Color buffer setters. - public void setColorBuffer(PTexture tex) { - setColorBuffers(new PTexture[] { tex }, 1); + public void setColorBuffer(Texture tex) { + setColorBuffers(new Texture[] { tex }, 1); } - public void setColorBuffers(PTexture[] textures) { + public void setColorBuffers(Texture[] textures) { setColorBuffers(textures, textures.length); } - public void setColorBuffers(PTexture[] textures, int n) { + public void setColorBuffers(Texture[] textures, int n) { if (screenFb) return; if (numColorBuffers != PApplet.min(n, textures.length)) { diff --git a/java/libraries/opengl/src/processing/opengl/PFontTexture.java b/java/libraries/opengl/src/processing/opengl/PFontTexture.java index f06dc8575..b4fdd28c4 100644 --- a/java/libraries/opengl/src/processing/opengl/PFontTexture.java +++ b/java/libraries/opengl/src/processing/opengl/PFontTexture.java @@ -59,7 +59,7 @@ class PFontTexture implements PConstants { protected int offsetX; protected int offsetY; protected int lineHeight; - protected PTexture[] textures = null; + protected Texture[] textures = null; protected PImage[] images = null; protected int currentTex; protected int lastTex; @@ -117,20 +117,20 @@ class PFontTexture implements PConstants { resize = false; } - PTexture tex; + Texture tex; if (is3D) { // Bilinear sampling ensures that the texture doesn't look pixelated either // when it is magnified or minified... - tex = new PTexture(parent, w, h, new PTexture.Parameters(ARGB, BILINEAR, false)); + tex = new Texture(parent, w, h, new Texture.Parameters(ARGB, Texture.BILINEAR, false)); } else { // ...however, the effect of bilinear sampling is to add some blurriness to the text // in its original size. In 2D, we assume that text will be shown at its original // size, so linear sampling is chosen instead (which only affects minimized text). - tex = new PTexture(parent, w, h, new PTexture.Parameters(ARGB, LINEAR, false)); + tex = new Texture(parent, w, h, new Texture.Parameters(ARGB, Texture.LINEAR, false)); } if (textures == null) { - textures = new PTexture[1]; + textures = new Texture[1]; textures[0] = tex; images = new PImage[1]; images[0] = pg.wrapTexture(tex); @@ -139,7 +139,7 @@ class PFontTexture implements PConstants { // Replacing old smaller texture with larger one. // But first we must copy the contents of the older // texture into the new one. - PTexture tex0 = textures[currentTex]; + Texture tex0 = textures[currentTex]; tex.put(tex0); textures[currentTex] = tex; @@ -148,8 +148,8 @@ class PFontTexture implements PConstants { images[currentTex].height = tex.height; } else { // Adding new texture to the list. - PTexture[] tempTex = textures; - textures = new PTexture[textures.length + 1]; + Texture[] tempTex = textures; + textures = new Texture[textures.length + 1]; PApplet.arrayCopy(tempTex, textures, tempTex.length); textures[tempTex.length] = tex; currentTex = textures.length - 1; diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index 263d4a38f..314e103e2 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -46,7 +46,18 @@ import java.util.Stack; * OpenGL renderer. * */ -public class PGraphicsOpenGL extends PGraphics { +public class PGraphicsOpenGL extends PGraphics { + // shaders + static public final int FLAT_SHADER = 0; + static public final int LIGHT_SHADER = 1; + static public final int TEXTURE_SHADER = 2; + static public final int FULL_SHADER = 3; + static public final int LINE3D_SHADER = 4; + static public final int POINT3D_SHADER = 5; + + public int textureWrap = Texture.CLAMP; + public int textureQuality = Texture.BEST; + /** Interface between Processing and OpenGL */ public PGL pgl; @@ -311,16 +322,16 @@ public class PGraphicsOpenGL extends PGraphics { // Framebuffer stack: - static protected Stack fbStack; - static protected PFramebuffer screenFramebuffer; - static protected PFramebuffer currentFramebuffer; + static protected Stack fbStack; + static protected FrameBuffer screenFramebuffer; + static protected FrameBuffer currentFramebuffer; // ....................................................... // Offscreen rendering: - protected PFramebuffer offscreenFramebuffer; - protected PFramebuffer offscreenFramebufferMultisample; + protected FrameBuffer offscreenFramebuffer; + protected FrameBuffer offscreenFramebufferMultisample; protected boolean offscreenMultisample; protected boolean offscreenNotCurrent; @@ -331,7 +342,7 @@ public class PGraphicsOpenGL extends PGraphics { /** A handy reference to the PTexture bound to the drawing surface * (off or on-screen) */ - protected PTexture texture; + protected Texture texture; /** IntBuffer wrapping the pixels array. */ protected IntBuffer pixelBuffer; @@ -1038,7 +1049,7 @@ public class PGraphicsOpenGL extends PGraphics { } - public void setFramebuffer(PFramebuffer fbo) { + public void setFramebuffer(FrameBuffer fbo) { currentFramebuffer = fbo; currentFramebuffer.bind(); } @@ -1893,9 +1904,9 @@ public class PGraphicsOpenGL extends PGraphics { clearColorBuffer = false; if (fbStack == null) { - fbStack = new Stack(); + fbStack = new Stack(); - screenFramebuffer = new PFramebuffer(parent, width, height, true); + screenFramebuffer = new FrameBuffer(parent, width, height, true); setFramebuffer(screenFramebuffer); } @@ -2040,6 +2051,17 @@ public class PGraphicsOpenGL extends PGraphics { } } + + public void textureWrap(int wrap) { + this.textureWrap = wrap; + } + + + public void textureQuality(int quality) { + this.textureQuality = quality; + } + + public void texture(PImage image) { if (flushMode == FLUSH_WHEN_FULL && hints[DISABLE_TEXTURE_CACHE] && image != textureImage0) { @@ -2357,7 +2379,7 @@ public class PGraphicsOpenGL extends PGraphics { texCache.beginRender(); for (int i = 0; i < texCache.size; i++) { - PTexture tex = texCache.getTexture(i); + Texture tex = texCache.getTexture(i); // If the renderer is 2D, then lights should always be false, // so no need to worry about that. @@ -4876,8 +4898,8 @@ public class PGraphicsOpenGL extends PGraphics { protected void loadTextureImpl(int sampling, boolean mipmap) { if (width == 0 || height == 0) return; if (texture == null || texture.contextIsOutdated()) { - PTexture.Parameters params = new PTexture.Parameters(ARGB, sampling, mipmap); - texture = new PTexture(parent, width, height, params); + Texture.Parameters params = new Texture.Parameters(ARGB, sampling, mipmap); + texture = new Texture(parent, width, height, params); texture.setFlippedY(true); this.setCache(pgPrimary, texture); this.setParams(pgPrimary, params); @@ -5144,7 +5166,7 @@ public class PGraphicsOpenGL extends PGraphics { * drawing surface, making sure is updated to reflect the current contents * off the screen (or offscreen drawing surface). */ - public PTexture getTexture() { + public Texture getTexture() { loadTexture(); return texture; } @@ -5156,8 +5178,8 @@ public class PGraphicsOpenGL extends PGraphics { * * @param img the image to have a texture metadata associated to it */ - public PTexture getTexture(PImage img) { - PTexture tex = (PTexture)img.getCache(pgPrimary); + public Texture getTexture(PImage img) { + Texture tex = (Texture)img.getCache(pgPrimary); if (tex == null) { tex = addTexture(img); } else { @@ -5185,26 +5207,26 @@ public class PGraphicsOpenGL extends PGraphics { * to the metadata cache of the image. * @param img the image to have a texture metadata associated to it */ - protected PTexture addTexture(PImage img) { - PTexture.Parameters params = (PTexture.Parameters)img.getParams(pgPrimary); + protected Texture addTexture(PImage img) { + Texture.Parameters params = (Texture.Parameters)img.getParams(pgPrimary); if (params == null) { - params = new PTexture.Parameters(); + params = new Texture.Parameters(); if (hints[DISABLE_TEXTURE_MIPMAPS]) { params.mipmaps = false; } else { params.mipmaps = true; } - if (textureQuality == LOW) { + if (textureQuality == Texture.LOW) { params.sampling = POINT; - } else if (textureQuality == MEDIUM) { - params.sampling = LINEAR; - } else if (textureQuality == HIGH) { - params.sampling = BILINEAR; - } else if (textureQuality == BEST) { + } else if (textureQuality == Texture.MEDIUM) { + params.sampling = Texture.LINEAR; + } else if (textureQuality == Texture.HIGH) { + params.sampling = Texture.BILINEAR; + } else if (textureQuality == Texture.BEST) { if (params.mipmaps) { - params.sampling = TRILINEAR; + params.sampling = Texture.TRILINEAR; } else { - params.sampling = BILINEAR; + params.sampling = Texture.BILINEAR; PGraphics.showWarning("BEST texture quality requires mipmaps, will switch to HIGH."); } } @@ -5215,7 +5237,7 @@ public class PGraphicsOpenGL extends PGraphics { if (img.parent == null) { img.parent = parent; } - PTexture tex = new PTexture(img.parent, img.width, img.height, params); + Texture tex = new Texture(img.parent, img.width, img.height, params); img.loadPixels(); if (img.pixels != null) tex.set(img.pixels); img.setCache(pgPrimary, tex); @@ -5223,7 +5245,7 @@ public class PGraphicsOpenGL extends PGraphics { } - protected PImage wrapTexture(PTexture tex) { + protected PImage wrapTexture(Texture tex) { // We don't use the PImage(int width, int height, int mode) constructor to // avoid initializing the pixels array. PImage img = new PImage(); @@ -5236,7 +5258,7 @@ public class PGraphicsOpenGL extends PGraphics { } - protected void updateTexture(PImage img, PTexture tex) { + protected void updateTexture(PImage img, Texture tex) { if (tex != null) { int x = img.getModifiedX1(); int y = img.getModifiedY1(); @@ -5277,7 +5299,7 @@ public class PGraphicsOpenGL extends PGraphics { pgl.initOffscreenSurface(pgPrimary.pgl); pgl.updateOffscreen(pgPrimary.pgl); - loadTextureImpl(BILINEAR, false); + loadTextureImpl(Texture.BILINEAR, false); // In case of reinitialization (for example, when the smooth level // is changed), we make sure that all the OpenGL resources associated @@ -5290,7 +5312,7 @@ public class PGraphicsOpenGL extends PGraphics { } if (PGraphicsOpenGL.fboMultisampleSupported && 1 < quality) { - offscreenFramebufferMultisample = new PFramebuffer(parent, texture.glWidth, texture.glHeight, quality, 0, + offscreenFramebufferMultisample = new FrameBuffer(parent, texture.glWidth, texture.glHeight, quality, 0, depthBits, stencilBits, depthBits == 24 && stencilBits == 8 && packedDepthStencilSupported, false); @@ -5299,13 +5321,13 @@ public class PGraphicsOpenGL extends PGraphics { // The offscreen framebuffer where the multisampled image is finally drawn to doesn't // need depth and stencil buffers since they are part of the multisampled framebuffer. - offscreenFramebuffer = new PFramebuffer(parent, texture.glWidth, texture.glHeight, 1, 1, + offscreenFramebuffer = new FrameBuffer(parent, texture.glWidth, texture.glHeight, 1, 1, 0, 0, false, false); } else { quality = 0; - offscreenFramebuffer = new PFramebuffer(parent, texture.glWidth, texture.glHeight, 1, 1, + offscreenFramebuffer = new FrameBuffer(parent, texture.glWidth, texture.glHeight, 1, 1, depthBits, stencilBits, depthBits == 24 && stencilBits == 8 && packedDepthStencilSupported, false); offscreenMultisample = false; @@ -5586,7 +5608,7 @@ public class PGraphicsOpenGL extends PGraphics { public void setEmissiveAttribute(int vboId, int size, int type, int stride, int offset) { } public void setShininessAttribute(int vboId, int size, int type, int stride, int offset) { } public void setTexcoordAttribute(int vboId, int size, int type, int stride, int offset) { } - public void setTexture(PTexture tex) { } + public void setTexture(Texture tex) { } } @@ -5824,7 +5846,7 @@ public class PGraphicsOpenGL extends PGraphics { setAttribute(inTexcoordLoc, vboId, size, type, false, stride, offset); } - public void setTexture(PTexture tex) { + public void setTexture(Texture tex) { float scaleu = 1; float scalev = 1; float dispu = 0; @@ -5909,7 +5931,7 @@ public class PGraphicsOpenGL extends PGraphics { setAttribute(inTexcoordLoc, vboId, size, type, false, stride, offset); } - public void setTexture(PTexture tex) { + public void setTexture(Texture tex) { float scaleu = 1; float scalev = 1; float dispu = 0; @@ -6172,7 +6194,7 @@ public class PGraphicsOpenGL extends PGraphics { int[] firstCache; int[] lastCache; boolean hasTexture; - PTexture tex0; + Texture tex0; TexCache() { allocate(); @@ -6210,9 +6232,9 @@ public class PGraphicsOpenGL extends PGraphics { return textures[i]; } - PTexture getTexture(int i) { + Texture getTexture(int i) { PImage img = textures[i]; - PTexture tex = null; + Texture tex = null; if (img != null) { tex = pgPrimary.getTexture(img); @@ -6235,7 +6257,7 @@ public class PGraphicsOpenGL extends PGraphics { for (int i = 0; i < size; i++) { PImage img = textures[i]; if (img != null) { - PTexture tex = pgPrimary.getTexture(img); + Texture tex = pgPrimary.getTexture(img); if (tex != null) { tex.unbind(); } @@ -6246,7 +6268,7 @@ public class PGraphicsOpenGL extends PGraphics { for (int i = 0; i < size; i++) { PImage img = textures[i]; if (img != null) { - PTexture tex = pgPrimary.getTexture(img); + Texture tex = pgPrimary.getTexture(img); if (tex != null) { pgl.disableTexturing(tex.glTarget); } diff --git a/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java b/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java index 4fb73bc9b..511b9c191 100644 --- a/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java @@ -3872,7 +3872,7 @@ public class PShapeOpenGL extends PShape { protected void renderPolys(PGraphicsOpenGL g, PImage textureImage) { - PTexture tex = null; + Texture tex = null; if (textureImage != null) { tex = g.getTexture(textureImage); if (tex != null) { diff --git a/java/libraries/opengl/src/processing/opengl/PTexture.java b/java/libraries/opengl/src/processing/opengl/Texture.java similarity index 90% rename from java/libraries/opengl/src/processing/opengl/PTexture.java rename to java/libraries/opengl/src/processing/opengl/Texture.java index c3a5b6bee..460ae16e0 100644 --- a/java/libraries/opengl/src/processing/opengl/PTexture.java +++ b/java/libraries/opengl/src/processing/opengl/Texture.java @@ -38,9 +38,41 @@ import java.util.NoSuchElementException; * By Andres Colubri * */ -public class PTexture implements PConstants { +public class Texture implements PConstants { public int width, height; + /** + * This constant identifies the texture target GL_TEXTURE_2D, that is, + * textures with normalized coordinates + */ + public static final int TEXTURE2D = 0; + + /** Texture quality constants */ + public static final int LOW = 0; + public static final int MEDIUM = 1; + public static final int HIGH = 2; + public static final int BEST = 3; + + /** Point sampling: both magnification and minification filtering are set to nearest */ + //public static final int POINT = 2; // shared with shape feature + /** Linear sampling: magnification filtering is nearest, minification set to linear */ + public static final int LINEAR = 3; + /** Bilinear sampling: both magnification filtering is set to linear and minification + * either to linear-mipmap-nearest (linear interplation is used within a mipmap, but + * not between different mipmaps). */ + public static final int BILINEAR = 4; + /** Trilinear sampling: magnification filtering set to linear, minification to + * linear-mipmap-linear, which offers the best mipmap quality since linear + * interpolation to compute the value in each of two maps and then interpolates linearly + * between these two value. */ + public static final int TRILINEAR = 5; + + /** This constant identifies the clamp-to-edge wrapping mode */ + public static final int CLAMP = 0; + /** This constant identifies the repeat wrapping mode */ + public static final int REPEAT = 1; + + protected PApplet parent; // The Processing applet protected PGraphicsOpenGL pg; // The main renderer protected PGL pgl; // The interface between Processing and OpenGL. @@ -65,7 +97,7 @@ public class PTexture implements PConstants { protected boolean flippedY; protected int[] tempPixels = null; - protected PFramebuffer tempFbo = null; + protected FrameBuffer tempFbo = null; protected Object bufferSource; protected LinkedList bufferCache = null; @@ -84,7 +116,7 @@ public class PTexture implements PConstants { * @param width int * @param height int */ - public PTexture(PApplet parent, int width, int height) { + public Texture(PApplet parent, int width, int height) { this(parent, width, height, new Parameters()); } @@ -97,7 +129,7 @@ public class PTexture implements PConstants { * @param height int * @param params Parameters */ - public PTexture(PApplet parent, int width, int height, Object params) { + public Texture(PApplet parent, int width, int height, Object params) { this.parent = parent; pg = (PGraphicsOpenGL)parent.g; @@ -168,7 +200,7 @@ public class PTexture implements PConstants { release(); // Creating new texture with the appropriate size. - PTexture tex = new PTexture(parent, wide, high, getParameters()); + Texture tex = new Texture(parent, wide, high, getParameters()); // Copying the contents of this texture into tex. tex.set(this); @@ -198,23 +230,23 @@ public class PTexture implements PConstants { public void set(PImage img) { - PTexture tex = (PTexture)img.getCache(pg); + Texture tex = (Texture)img.getCache(pg); set(tex); } public void set(PImage img, int x, int y, int w, int h) { - PTexture tex = (PTexture)img.getCache(pg); + Texture tex = (Texture)img.getCache(pg); set(tex, x, y, w, h); } - public void set(PTexture tex) { + public void set(Texture tex) { copyTexels(tex, 0, 0, tex.width, tex.height, true); } - public void set(PTexture tex, int x, int y, int w, int h) { + public void set(Texture tex, int x, int y, int w, int h) { copyTexels(tex, x, y, w, h, true); } @@ -346,7 +378,7 @@ public class PTexture implements PConstants { int size = glWidth * glHeight; if (tempFbo == null) { - tempFbo = new PFramebuffer(parent, glWidth, glHeight); + tempFbo = new FrameBuffer(parent, glWidth, glHeight); } // Attaching the texture to the color buffer of a FBO, binding the FBO and reading the pixels @@ -374,12 +406,12 @@ public class PTexture implements PConstants { // destination). - public void put(PTexture tex) { + public void put(Texture tex) { copyTexels(tex, 0, 0, tex.width, tex.height, false); } - public void put(PTexture tex, int x, int y, int w, int h) { + public void put(Texture tex, int x, int y, int w, int h) { copyTexels(tex, x, y, w, h, false); } @@ -863,13 +895,13 @@ public class PTexture implements PConstants { // Copies source texture tex into this. - protected void copyTexels(PTexture tex, int x, int y, int w, int h, boolean scale) { + protected void copyTexels(Texture tex, int x, int y, int w, int h, boolean scale) { if (tex == null) { throw new RuntimeException("PTexture: source texture is null"); } if (tempFbo == null) { - tempFbo = new PFramebuffer(parent, glWidth, glHeight); + tempFbo = new FrameBuffer(parent, glWidth, glHeight); } // This texture is the color (destination) buffer of the FBO. @@ -911,7 +943,7 @@ public class PTexture implements PConstants { pgl.glTexSubImage2D(glTarget, level, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, buffer); } - protected void copyObject(PTexture src) { + protected void copyObject(Texture src) { // The OpenGL texture of this object is replaced with the one from the source object, // so we delete the former to avoid resource wasting. release(); @@ -948,7 +980,7 @@ public class PTexture implements PConstants { Parameters res = new Parameters(); if (glTarget == PGL.GL_TEXTURE_2D) { - res.target = TEXTURE2D; + res.target = TEXTURE2D; } if (glFormat == PGL.GL_RGB) { @@ -1134,7 +1166,7 @@ public class PTexture implements PConstants { this.mipmaps = mipmaps; this.wrapU = CLAMP; this.wrapV = CLAMP; - } + } public Parameters(Parameters src) { set(src);