mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Code cleanup, updated TexturedSphere example, some more fixes
This commit is contained in:
@@ -28,6 +28,7 @@ int SINCOS_LENGTH = int(360.0 / SINCOS_PRECISION);
|
||||
|
||||
void setup() {
|
||||
size(1024, 768, P3D);
|
||||
smooth();
|
||||
texmap = loadImage("world32k.jpg");
|
||||
initializeSphere(sDetail);
|
||||
}
|
||||
@@ -43,8 +44,7 @@ void renderGlobe() {
|
||||
pushMatrix();
|
||||
noFill();
|
||||
stroke(255,200);
|
||||
strokeWeight(2);
|
||||
smooth();
|
||||
strokeWeight(2);
|
||||
popMatrix();
|
||||
lights();
|
||||
pushMatrix();
|
||||
@@ -169,4 +169,4 @@ void texturedSphere(float r, PImage t)
|
||||
vertex(sphereX[voff]*r, sphereY[voff]*r, sphereZ[voff]*r, u, v);
|
||||
endShape();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ import processing.core.PImage;
|
||||
*/
|
||||
class PFontTexture implements PConstants {
|
||||
protected PApplet parent;
|
||||
protected PGraphicsOpenGL ogl;
|
||||
protected PGraphicsOpenGL renderer;
|
||||
protected GLContext context;
|
||||
protected PFont font;
|
||||
|
||||
@@ -71,8 +71,8 @@ class PFontTexture implements PConstants {
|
||||
public PFontTexture(PApplet parent, PFont font, int maxw, int maxh) {
|
||||
this.parent = parent;
|
||||
this.font = font;
|
||||
ogl = (PGraphicsOpenGL)parent.g;
|
||||
context = ogl.getContext();
|
||||
renderer = (PGraphicsOpenGL)parent.g;
|
||||
context = renderer.getContext();
|
||||
|
||||
initTexture(maxw, maxh);
|
||||
}
|
||||
@@ -124,7 +124,7 @@ class PFontTexture implements PConstants {
|
||||
textures = new PTexture[1];
|
||||
textures[0] = tex;
|
||||
images = new PImage[1];
|
||||
images[0] = ogl.wrapTexture(tex);
|
||||
images[0] = renderer.wrapTexture(tex);
|
||||
currentTex = 0;
|
||||
} else if (resize) {
|
||||
// Replacing old smaller texture with larger one.
|
||||
@@ -134,7 +134,7 @@ class PFontTexture implements PConstants {
|
||||
tex.put(tex0);
|
||||
textures[currentTex] = tex;
|
||||
|
||||
images[currentTex].setCache(ogl, tex);
|
||||
images[currentTex].setCache(renderer, tex);
|
||||
images[currentTex].width = tex.width;
|
||||
images[currentTex].height = tex.height;
|
||||
} else {
|
||||
@@ -148,7 +148,7 @@ class PFontTexture implements PConstants {
|
||||
PImage[] tempImg = images;
|
||||
images = new PImage[textures.length + 1];
|
||||
PApplet.arrayCopy(tempImg, images, tempImg.length);
|
||||
images[tempImg.length] = ogl.wrapTexture(tex);
|
||||
images[tempImg.length] = renderer.wrapTexture(tex);
|
||||
}
|
||||
lastTex = currentTex;
|
||||
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2010 Ben Fry and Casey Reas
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
Copyright (c) 2010 Ben Fry and Casey Reas
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.opengl;
|
||||
@@ -38,7 +39,7 @@ import processing.core.PConstants;
|
||||
*/
|
||||
public class PFramebuffer implements PConstants {
|
||||
protected PApplet parent;
|
||||
protected PGraphicsOpenGL ogl;
|
||||
protected PGraphicsOpenGL renderer;
|
||||
protected PGL pgl;
|
||||
|
||||
public int glFboID;
|
||||
@@ -57,7 +58,6 @@ public class PFramebuffer implements PConstants {
|
||||
protected int nsamples;
|
||||
|
||||
protected int numColorBuffers;
|
||||
//protected int[] colorBufferAttchPoints;
|
||||
protected PTexture[] colorBufferTex;
|
||||
|
||||
protected boolean screenFb;
|
||||
@@ -79,9 +79,8 @@ public class PFramebuffer implements PConstants {
|
||||
int depthBits, int stencilBits, boolean combinedDepthStencil,
|
||||
boolean screen) {
|
||||
this.parent = parent;
|
||||
ogl = (PGraphicsOpenGL)parent.g;
|
||||
pgl = ogl.pgl;
|
||||
//gl.registerPGLObject(this);
|
||||
renderer = (PGraphicsOpenGL)parent.g;
|
||||
pgl = renderer.pgl;
|
||||
|
||||
glFboID = 0;
|
||||
glDepthBufferID = 0;
|
||||
@@ -110,10 +109,8 @@ public class PFramebuffer implements PConstants {
|
||||
}
|
||||
|
||||
numColorBuffers = colorBuffers;
|
||||
//colorBufferAttchPoints = new int[numColorBuffers];
|
||||
colorBufferTex = new PTexture[numColorBuffers];
|
||||
for (int i = 0; i < numColorBuffers; i++) {
|
||||
//colorBufferAttchPoints[i] = GL.GL_COLOR_ATTACHMENT0 + i;
|
||||
colorBufferTex[i] = null;
|
||||
}
|
||||
|
||||
@@ -155,19 +152,19 @@ public class PFramebuffer implements PConstants {
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
if (glFboID != 0) {
|
||||
ogl.finalizeFrameBufferObject(glFboID);
|
||||
renderer.finalizeFrameBufferObject(glFboID);
|
||||
}
|
||||
if (glDepthBufferID != 0) {
|
||||
ogl.finalizeRenderBufferObject(glDepthBufferID);
|
||||
renderer.finalizeRenderBufferObject(glDepthBufferID);
|
||||
}
|
||||
if (glStencilBufferID != 0) {
|
||||
ogl.finalizeRenderBufferObject(glStencilBufferID);
|
||||
renderer.finalizeRenderBufferObject(glStencilBufferID);
|
||||
}
|
||||
if (glColorBufferMultisampleID != 0) {
|
||||
ogl.finalizeRenderBufferObject(glColorBufferMultisampleID);
|
||||
renderer.finalizeRenderBufferObject(glColorBufferMultisampleID);
|
||||
}
|
||||
if (glDepthStencilBufferID != 0) {
|
||||
ogl.finalizeRenderBufferObject(glDepthStencilBufferID);
|
||||
renderer.finalizeRenderBufferObject(glDepthStencilBufferID);
|
||||
}
|
||||
} finally {
|
||||
super.finalize();
|
||||
@@ -175,33 +172,25 @@ public class PFramebuffer implements PConstants {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
ogl.pushFramebuffer();
|
||||
ogl.setFramebuffer(this);
|
||||
// getGl().glClearColor(0f, 0f, 0f, 0.0f);
|
||||
// getGl().glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);
|
||||
renderer.pushFramebuffer();
|
||||
renderer.setFramebuffer(this);
|
||||
pgl.setClearColor(0, 0, 0, 0);
|
||||
pgl.clearAllBuffers();
|
||||
ogl.popFramebuffer();
|
||||
renderer.popFramebuffer();
|
||||
}
|
||||
|
||||
public void copy(PFramebuffer dest) {
|
||||
// getGl().glBindFramebuffer(GL2.GL_READ_FRAMEBUFFER, this.glFboID);
|
||||
// getGl().glBindFramebuffer(GL2.GL_DRAW_FRAMEBUFFER, dest.glFboID);
|
||||
pgl.bindReadFramebuffer(this.glFboID);
|
||||
pgl.bindWriteFramebuffer(dest.glFboID);
|
||||
|
||||
// getGl2().glBlitFramebuffer(0, 0, this.width, this.height, 0, 0, dest.width, dest.height, GL.GL_COLOR_BUFFER_BIT, GL.GL_NEAREST);
|
||||
pgl.bindWriteFramebuffer(dest.glFboID);
|
||||
pgl.copyFramebuffer(this.width, this.height, dest.width, dest.height);
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
if (screenFb) {
|
||||
if (PGraphicsOpenGL.fboSupported) {
|
||||
// getGl().glBindFramebuffer(GL.GL_FRAMEBUFFER, 0);
|
||||
pgl.bindFramebuffer(0);
|
||||
}
|
||||
} else if (fboMode) {
|
||||
// getGl().glBindFramebuffer(GL.GL_FRAMEBUFFER, glFboID);
|
||||
pgl.bindFramebuffer(glFboID);
|
||||
} else {
|
||||
backupScreen();
|
||||
@@ -209,11 +198,10 @@ public class PFramebuffer implements PConstants {
|
||||
if (0 < numColorBuffers) {
|
||||
// Drawing the current contents of the first color buffer to emulate
|
||||
// front-back buffer swap.
|
||||
ogl.drawTexture(colorBufferTex[0].glTarget, colorBufferTex[0].glID, width, height, 0, 0, width, height, 0, 0, width, height);
|
||||
renderer.drawTexture(colorBufferTex[0].glTarget, colorBufferTex[0].glID, width, height, 0, 0, width, height, 0, 0, width, height);
|
||||
}
|
||||
|
||||
if (noDepth) {
|
||||
// getGl().glDisable(GL.GL_DEPTH_TEST);
|
||||
pgl.disableDepthTest();
|
||||
}
|
||||
}
|
||||
@@ -226,11 +214,9 @@ public class PFramebuffer implements PConstants {
|
||||
public void finish() {
|
||||
if (noDepth) {
|
||||
// No need to clear depth buffer because depth testing was disabled.
|
||||
if (ogl.hintEnabled(DISABLE_DEPTH_TEST)) {
|
||||
// getGl().glDisable(GL.GL_DEPTH_TEST);
|
||||
if (renderer.hintEnabled(DISABLE_DEPTH_TEST)) {
|
||||
pgl.disableDepthTest();
|
||||
} else {
|
||||
// getGl().glEnable(GL.GL_DEPTH_TEST);
|
||||
pgl.enableDepthTest();
|
||||
}
|
||||
}
|
||||
@@ -248,8 +234,6 @@ public class PFramebuffer implements PConstants {
|
||||
// no FBOs are available should be done before any onscreen drawing.
|
||||
pgl.setClearColor(0, 0, 0, 0);
|
||||
pgl.clearDepthBuffer();
|
||||
// getGl().glClearColor(0, 0, 0, 0);
|
||||
// getGl().glClear(GL.GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -258,7 +242,6 @@ public class PFramebuffer implements PConstants {
|
||||
public void backupScreen() {
|
||||
if (pixelBuffer == null) createPixelBuffer();
|
||||
pixelBuffer.rewind();
|
||||
//getGl().glReadPixels(0, 0, width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, pixelBuffer);
|
||||
pgl.readPixels(pixelBuffer, 0, 0, width, height);
|
||||
|
||||
copyToTexture(pixelBuffer, backupTexture.glID, backupTexture.glTarget);
|
||||
@@ -266,14 +249,13 @@ public class PFramebuffer implements PConstants {
|
||||
|
||||
// Draws the contents of the backup texture to the screen.
|
||||
public void restoreBackup() {
|
||||
ogl.drawTexture(backupTexture, 0, 0, width, height, 0, 0, width, height);
|
||||
renderer.drawTexture(backupTexture, 0, 0, width, height, 0, 0, width, height);
|
||||
}
|
||||
|
||||
// Copies current content of screen to color buffers.
|
||||
public void copyToColorBuffers() {
|
||||
if (pixelBuffer == null) createPixelBuffer();
|
||||
pixelBuffer.rewind();
|
||||
//getGl().glReadPixels(0, 0, width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, pixelBuffer);
|
||||
pgl.readPixels(pixelBuffer, 0, 0, width, height);
|
||||
for (int i = 0; i < numColorBuffers; i++) {
|
||||
copyToTexture(pixelBuffer, colorBufferTex[i].glID, colorBufferTex[i].glTarget);
|
||||
@@ -283,7 +265,6 @@ public class PFramebuffer implements PConstants {
|
||||
public void readPixels() {
|
||||
if (pixelBuffer == null) createPixelBuffer();
|
||||
pixelBuffer.rewind();
|
||||
// getGl().glReadPixels(0, 0, width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, pixelBuffer);
|
||||
pgl.readPixels(pixelBuffer, 0, 0, width, height);
|
||||
}
|
||||
|
||||
@@ -333,23 +314,21 @@ public class PFramebuffer implements PConstants {
|
||||
}
|
||||
|
||||
if (fboMode) {
|
||||
ogl.pushFramebuffer();
|
||||
ogl.setFramebuffer(this);
|
||||
renderer.pushFramebuffer();
|
||||
renderer.setFramebuffer(this);
|
||||
|
||||
// Making sure nothing is attached.
|
||||
for (int i = 0; i < numColorBuffers; i++) {
|
||||
// getGl().glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0 + i, GL.GL_TEXTURE_2D, 0, 0);
|
||||
pgl.cleanFramebufferTexture(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < numColorBuffers; i++) {
|
||||
pgl.setFramebufferTexture(i, colorBufferTex[i].glTarget, colorBufferTex[i].glID);
|
||||
// getGl().glFramebufferTexture2D(GL.GL_FRAMEBUFFER, colorBufferAttchPoints[i], colorBufferTex[i].glTarget, colorBufferTex[i].glID, 0);
|
||||
}
|
||||
|
||||
validateFbo();
|
||||
|
||||
ogl.popFramebuffer();
|
||||
renderer.popFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,7 +345,7 @@ public class PFramebuffer implements PConstants {
|
||||
glFboID = 0;
|
||||
} else if (fboMode) {
|
||||
//glFboID = ogl.createGLResource(PGraphicsOpenGL.GL_FRAME_BUFFER);
|
||||
glFboID = ogl.createFrameBufferObject();
|
||||
glFboID = renderer.createFrameBufferObject();
|
||||
} else {
|
||||
glFboID = 0;
|
||||
}
|
||||
@@ -391,23 +370,23 @@ public class PFramebuffer implements PConstants {
|
||||
|
||||
protected void release() {
|
||||
if (glFboID != 0) {
|
||||
ogl.finalizeFrameBufferObject(glFboID);
|
||||
renderer.finalizeFrameBufferObject(glFboID);
|
||||
glFboID = 0;
|
||||
}
|
||||
if (glDepthBufferID != 0) {
|
||||
ogl.finalizeRenderBufferObject(glDepthBufferID);
|
||||
renderer.finalizeRenderBufferObject(glDepthBufferID);
|
||||
glDepthBufferID = 0;
|
||||
}
|
||||
if (glStencilBufferID != 0) {
|
||||
ogl.finalizeRenderBufferObject(glStencilBufferID);
|
||||
renderer.finalizeRenderBufferObject(glStencilBufferID);
|
||||
glStencilBufferID = 0;
|
||||
}
|
||||
if (glColorBufferMultisampleID != 0) {
|
||||
ogl.finalizeRenderBufferObject(glColorBufferMultisampleID);
|
||||
renderer.finalizeRenderBufferObject(glColorBufferMultisampleID);
|
||||
glColorBufferMultisampleID = 0;
|
||||
}
|
||||
if (glDepthStencilBufferID != 0) {
|
||||
ogl.finalizeRenderBufferObject(glDepthStencilBufferID);
|
||||
renderer.finalizeRenderBufferObject(glDepthStencilBufferID);
|
||||
glDepthStencilBufferID = 0;
|
||||
}
|
||||
}
|
||||
@@ -417,19 +396,15 @@ public class PFramebuffer implements PConstants {
|
||||
if (screenFb) return;
|
||||
|
||||
if (fboMode) {
|
||||
ogl.pushFramebuffer();
|
||||
ogl.setFramebuffer(this);
|
||||
renderer.pushFramebuffer();
|
||||
renderer.setFramebuffer(this);
|
||||
|
||||
glColorBufferMultisampleID = ogl.createRenderBufferObject();
|
||||
glColorBufferMultisampleID = renderer.createRenderBufferObject();
|
||||
pgl.bindRenderbuffer(glColorBufferMultisampleID);
|
||||
pgl.setRenderbufferNumSamples(nsamples, width, height);
|
||||
pgl.setRenderbufferNumSamples(nsamples, PGL.RGBA8, width, height);
|
||||
pgl.setRenderbufferColorAttachment(glColorBufferMultisampleID);
|
||||
|
||||
// getGl().glBindRenderbuffer(GL.GL_RENDERBUFFER, glColorBufferMultisampleID);
|
||||
// getGl2().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, nsamples, GL.GL_RGBA8, width, height);
|
||||
// getGl().glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_RENDERBUFFER, glColorBufferMultisampleID);
|
||||
|
||||
ogl.popFramebuffer();
|
||||
renderer.popFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,27 +417,22 @@ public class PFramebuffer implements PConstants {
|
||||
}
|
||||
|
||||
if (fboMode) {
|
||||
ogl.pushFramebuffer();
|
||||
ogl.setFramebuffer(this);
|
||||
renderer.pushFramebuffer();
|
||||
renderer.setFramebuffer(this);
|
||||
|
||||
glDepthStencilBufferID = ogl.createRenderBufferObject();
|
||||
glDepthStencilBufferID = renderer.createRenderBufferObject();
|
||||
pgl.bindRenderbuffer(glDepthStencilBufferID);
|
||||
//getGl().glBindRenderbuffer(GL.GL_RENDERBUFFER, glDepthStencilBufferID);
|
||||
|
||||
if (multisample) {
|
||||
// getGl2().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, nsamples, GL.GL_DEPTH24_STENCIL8, width, height);
|
||||
pgl.setRenderbufferNumSamples(nsamples, width, height);
|
||||
pgl.setRenderbufferNumSamples(nsamples, PGL.DEPTH_24BIT_STENCIL_8BIT, width, height);
|
||||
} else {
|
||||
pgl.setRenderbufferStorage(PGL.DEPTH_24BIT_STENCIL_8BIT, width, height);
|
||||
// getGl().glRenderbufferStorage(GL.GL_RENDERBUFFER, GL.GL_DEPTH24_STENCIL8, width, height);
|
||||
}
|
||||
|
||||
pgl.setRenderbufferDepthAttachment(glDepthStencilBufferID);
|
||||
pgl.setRenderbufferStencilAttachment(glDepthStencilBufferID);
|
||||
// getGl().glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, glDepthStencilBufferID);
|
||||
// getGl().glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, glDepthStencilBufferID);
|
||||
|
||||
ogl.popFramebuffer();
|
||||
renderer.popFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,11 +445,10 @@ public class PFramebuffer implements PConstants {
|
||||
}
|
||||
|
||||
if (fboMode) {
|
||||
ogl.pushFramebuffer();
|
||||
ogl.setFramebuffer(this);
|
||||
renderer.pushFramebuffer();
|
||||
renderer.setFramebuffer(this);
|
||||
|
||||
glDepthBufferID = ogl.createRenderBufferObject();
|
||||
//getGl().glBindRenderbuffer(GL.GL_RENDERBUFFER, glDepthBufferID);
|
||||
glDepthBufferID = renderer.createRenderBufferObject();
|
||||
pgl.bindRenderbuffer(glDepthBufferID);
|
||||
|
||||
int glConst = PGL.DEPTH_16BIT;
|
||||
@@ -492,17 +461,14 @@ public class PFramebuffer implements PConstants {
|
||||
}
|
||||
|
||||
if (multisample) {
|
||||
//getGl2().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, nsamples, glConst, width, height);
|
||||
pgl.setRenderbufferNumSamples(nsamples, width, height);
|
||||
pgl.setRenderbufferNumSamples(nsamples, glConst, width, height);
|
||||
} else {
|
||||
//getGl().glRenderbufferStorage(GL.GL_RENDERBUFFER, glConst, width, height);
|
||||
pgl.setRenderbufferStorage(glConst, width, height);
|
||||
}
|
||||
|
||||
pgl.setRenderbufferDepthAttachment(glDepthBufferID);
|
||||
//getGl().glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, glDepthBufferID);
|
||||
|
||||
ogl.popFramebuffer();
|
||||
renderer.popFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,11 +481,10 @@ public class PFramebuffer implements PConstants {
|
||||
}
|
||||
|
||||
if (fboMode) {
|
||||
ogl.pushFramebuffer();
|
||||
ogl.setFramebuffer(this);
|
||||
renderer.pushFramebuffer();
|
||||
renderer.setFramebuffer(this);
|
||||
|
||||
glStencilBufferID = ogl.createRenderBufferObject();
|
||||
// getGl().glBindRenderbuffer(GL.GL_RENDERBUFFER, glStencilBufferID);
|
||||
glStencilBufferID = renderer.createRenderBufferObject();
|
||||
pgl.bindRenderbuffer(glStencilBufferID);
|
||||
|
||||
int glConst = PGL.STENCIL_1BIT;
|
||||
@@ -531,17 +496,14 @@ public class PFramebuffer implements PConstants {
|
||||
glConst = PGL.STENCIL_8BIT;
|
||||
}
|
||||
if (multisample) {
|
||||
// getGl2().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, nsamples, glConst, width, height);
|
||||
pgl.setRenderbufferNumSamples(nsamples, width, height);
|
||||
pgl.setRenderbufferNumSamples(nsamples, glConst, width, height);
|
||||
} else {
|
||||
// getGl().glRenderbufferStorage(GL.GL_RENDERBUFFER, glConst, width, height);
|
||||
pgl.setRenderbufferStorage(glConst, width, height);
|
||||
}
|
||||
|
||||
pgl.setRenderbufferStencilAttachment(glStencilBufferID);
|
||||
// getGl().glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, glStencilBufferID);
|
||||
|
||||
ogl.popFramebuffer();
|
||||
renderer.popFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,17 +523,10 @@ public class PFramebuffer implements PConstants {
|
||||
pgl.bindTexture(gltarget, glid);
|
||||
pgl.copyTexSubImage(buffer, gltarget, 0, 0, width, height);
|
||||
pgl.unbindTexture(gltarget);
|
||||
pgl.disableTexturing(gltarget);
|
||||
|
||||
// getGl().glEnable(gltarget);
|
||||
// getGl().glBindTexture(gltarget, glid);
|
||||
// getGl().glTexSubImage2D(gltarget, 0, 0, 0, width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer);
|
||||
// getGl().glBindTexture(gltarget, 0);
|
||||
// getGl().glDisable(gltarget);
|
||||
pgl.disableTexturing(gltarget);
|
||||
}
|
||||
|
||||
public boolean validateFbo() {
|
||||
// int status = getGl().glCheckFramebufferStatus(GL.GL_FRAMEBUFFER);
|
||||
int status = pgl.getFramebufferStatus();
|
||||
if (status == PGL.FRAMEBUFFER_COMPLETE) {
|
||||
return true;
|
||||
@@ -589,12 +544,4 @@ public class PFramebuffer implements PConstants {
|
||||
throw new RuntimeException("PFramebuffer: unknown framebuffer error (" + Integer.toHexString(status) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
// protected GL getGl() {
|
||||
// return ogl.gl;
|
||||
// }
|
||||
//
|
||||
// protected GL2GL3 getGl2() {
|
||||
// return ogl.gl2x;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,3 +1,26 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
Copyright (c) 2010 Ben Fry and Casey Reas
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.opengl;
|
||||
|
||||
import java.nio.Buffer;
|
||||
@@ -78,6 +101,7 @@ public class PGL {
|
||||
public static final int CLAMP_TO_EDGE = GL.GL_CLAMP_TO_EDGE;
|
||||
public static final int REPEAT = GL.GL_REPEAT;
|
||||
|
||||
public static final int RGBA8 = GL.GL_RGBA8;
|
||||
public static final int DEPTH_24BIT_STENCIL_8BIT = GL.GL_DEPTH24_STENCIL8;
|
||||
|
||||
public static final int DEPTH_16BIT = GL.GL_DEPTH_COMPONENT16;
|
||||
@@ -892,11 +916,11 @@ public class PGL {
|
||||
}
|
||||
|
||||
public void bindRenderbuffer(int id) {
|
||||
gl.glBindRenderbuffer(GL.GL_RENDERBUFFER,id);
|
||||
gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, id);
|
||||
}
|
||||
|
||||
public void setRenderbufferNumSamples(int samples, int w, int h) {
|
||||
gl2x.glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, samples, GL.GL_RGBA8, w, h);
|
||||
public void setRenderbufferNumSamples(int samples, int format, int w, int h) {
|
||||
gl2x.glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, samples, format, w, h);
|
||||
}
|
||||
|
||||
public void setRenderbufferStorage(int format, int w, int h) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -33,15 +33,13 @@ import java.net.URL;
|
||||
*/
|
||||
public class PShader {
|
||||
protected PApplet parent;
|
||||
protected PGraphicsOpenGL ogl;
|
||||
protected PGraphicsOpenGL renderer;
|
||||
protected PGL pgl;
|
||||
|
||||
protected int programObject;
|
||||
protected int vertexShader;
|
||||
//protected int geometryShader;
|
||||
protected int fragmentShader;
|
||||
protected boolean initialized;
|
||||
//protected int maxOutVertCount;
|
||||
|
||||
/**
|
||||
* Creates an instance of GLSLShader.
|
||||
@@ -50,19 +48,14 @@ public class PShader {
|
||||
*/
|
||||
public PShader(PApplet parent) {
|
||||
this.parent = parent;
|
||||
ogl = (PGraphicsOpenGL) parent.g;
|
||||
pgl = ogl.pgl;
|
||||
renderer = (PGraphicsOpenGL) parent.g;
|
||||
pgl = renderer.pgl;
|
||||
|
||||
programObject = ogl.createGLSLProgramObject();
|
||||
programObject = renderer.createGLSLProgramObject();
|
||||
|
||||
vertexShader = 0;
|
||||
//geometryShader = 0;
|
||||
fragmentShader = 0;
|
||||
initialized = false;
|
||||
|
||||
//IntBuffer buf = IntBuffer.allocate(1);
|
||||
//gl.glGetIntegerv(GL2.GL_MAX_GEOMETRY_OUTPUT_VERTICES, buf);
|
||||
//maxOutVertCount = buf.get(0);
|
||||
initialized = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,13 +76,13 @@ public class PShader {
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
if (vertexShader != 0) {
|
||||
ogl.finalizeGLSLVertShaderObject(vertexShader);
|
||||
renderer.finalizeGLSLVertShaderObject(vertexShader);
|
||||
}
|
||||
if (fragmentShader != 0) {
|
||||
ogl.finalizeGLSLFragShaderObject(fragmentShader);
|
||||
renderer.finalizeGLSLFragShaderObject(fragmentShader);
|
||||
}
|
||||
if (programObject != 0) {
|
||||
ogl.finalizeGLSLProgramObject(programObject);
|
||||
renderer.finalizeGLSLProgramObject(programObject);
|
||||
}
|
||||
} finally {
|
||||
super.finalize();
|
||||
@@ -159,8 +152,6 @@ public class PShader {
|
||||
* Links the shader program and validates it.
|
||||
*/
|
||||
public void setup() {
|
||||
// gl.glLinkProgram(programObject);
|
||||
// gl.glValidateProgram(programObject);
|
||||
pgl.linkProgram(programObject);
|
||||
pgl.validateProgram(programObject);
|
||||
checkLogInfo("GLSL program validation: ", programObject);
|
||||
@@ -187,7 +178,6 @@ public class PShader {
|
||||
// textures.
|
||||
// gl.glUniform1iARB(loc, unit);
|
||||
|
||||
//ogl.gl.getGL2().glUseProgramObjectARB(programObject);
|
||||
pgl.startProgram(programObject);
|
||||
}
|
||||
|
||||
@@ -195,7 +185,6 @@ public class PShader {
|
||||
* Stops the execution of the shader program.
|
||||
*/
|
||||
public void stop() {
|
||||
//ogl.gl.getGL2().glUseProgramObjectARB(0);
|
||||
pgl.stopProgram();
|
||||
}
|
||||
|
||||
@@ -206,7 +195,6 @@ public class PShader {
|
||||
* @return int
|
||||
*/
|
||||
public int getAttribLocation(String name) {
|
||||
// return gl.glGetAttribLocation(programObject, name);
|
||||
return pgl.getAttribLocation(programObject, name);
|
||||
}
|
||||
|
||||
@@ -217,7 +205,6 @@ public class PShader {
|
||||
* @return int
|
||||
*/
|
||||
public int getUniformLocation(String name) {
|
||||
// return gl.glGetUniformLocation(programObject, name);
|
||||
return pgl.getUniformLocation(programObject, name);
|
||||
}
|
||||
|
||||
@@ -231,7 +218,6 @@ public class PShader {
|
||||
public void setTexUniform(String name, int unit) {
|
||||
int loc = getUniformLocation(name);
|
||||
if (-1 < loc) {
|
||||
// gl.glUniform1i(loc, unit);
|
||||
pgl.setIntUniform(loc, unit);
|
||||
}
|
||||
}
|
||||
@@ -267,7 +253,6 @@ public class PShader {
|
||||
public void setIntUniform(String name, int x) {
|
||||
int loc = getUniformLocation(name);
|
||||
if (-1 < loc) {
|
||||
// gl.glUniform1i(loc, x);
|
||||
pgl.setIntUniform(loc, x);
|
||||
}
|
||||
}
|
||||
@@ -281,7 +266,6 @@ public class PShader {
|
||||
public void setFloatUniform(String name, float x) {
|
||||
int loc = getUniformLocation(name);
|
||||
if (-1 < loc) {
|
||||
//gl.glUniform1f(loc, x);
|
||||
pgl.setFloatUniform(loc, x);
|
||||
}
|
||||
}
|
||||
@@ -296,7 +280,6 @@ public class PShader {
|
||||
public void setVecUniform(String name, float x, float y) {
|
||||
int loc = getUniformLocation(name);
|
||||
if (-1 < loc) {
|
||||
// gl.glUniform2f(loc, x, y);
|
||||
pgl.setFloatUniform(loc, x, y);
|
||||
}
|
||||
}
|
||||
@@ -312,7 +295,6 @@ public class PShader {
|
||||
public void setVecUniform(String name, float x, float y, float z) {
|
||||
int loc = getUniformLocation(name);
|
||||
if (-1 < loc) {
|
||||
// gl.glUniform3f(loc, x, y, z);
|
||||
pgl.setFloatUniform(loc, x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -329,7 +311,6 @@ public class PShader {
|
||||
public void setVecUniform(String name, float x, float y, float z, float w) {
|
||||
int loc = getUniformLocation(name);
|
||||
if (-1 < loc) {
|
||||
// gl.glUniform4f(loc, x, y, z, w);
|
||||
pgl.setFloatUniform(loc, x, y, z, w);
|
||||
}
|
||||
}
|
||||
@@ -347,7 +328,6 @@ public class PShader {
|
||||
if (-1 < loc) {
|
||||
pgl.setMatUniform(loc, m00, m01,
|
||||
m10, m11);
|
||||
//gl.glUniformMatrix2fv(loc, 1, false, mat, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,7 +378,6 @@ public class PShader {
|
||||
public void setFloatAttribute(String name, float x) {
|
||||
int loc = getAttribLocation(name);
|
||||
if (-1 < loc) {
|
||||
// gl.glVertexAttrib1f(loc, x);
|
||||
pgl.setFloatAttrib(loc, x);
|
||||
}
|
||||
}
|
||||
@@ -413,7 +392,6 @@ public class PShader {
|
||||
public void setVecAttribute(String name, float x, float y) {
|
||||
int loc = getAttribLocation(name);
|
||||
if (-1 < loc) {
|
||||
// gl.glVertexAttrib2f(loc, x, y);
|
||||
pgl.setFloatAttrib(loc, x, y);
|
||||
}
|
||||
}
|
||||
@@ -429,7 +407,6 @@ public class PShader {
|
||||
public void setVecAttribute(String name, float x, float y, float z) {
|
||||
int loc = getAttribLocation(name);
|
||||
if (-1 < loc) {
|
||||
// gl.glVertexAttrib3f(loc, x, y, z);
|
||||
pgl.setFloatAttrib(loc, x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -446,7 +423,6 @@ public class PShader {
|
||||
public void setVecAttribute(String name, float x, float y, float z, float w) {
|
||||
int loc = getAttribLocation(name);
|
||||
if (-1 < loc) {
|
||||
// gl.glVertexAttrib4f(loc, x, y, z, w);
|
||||
pgl.setFloatAttrib(loc, x, y, z, w);
|
||||
}
|
||||
}
|
||||
@@ -456,15 +432,12 @@ public class PShader {
|
||||
* @param filename the shader's filename, used to print error log information
|
||||
*/
|
||||
private void attachVertexShader(String shaderSource, String file) {
|
||||
vertexShader = ogl.createGLSLVertShaderObject();
|
||||
vertexShader = renderer.createGLSLVertShaderObject();
|
||||
|
||||
// gl.glShaderSource(vertexShader, 1, new String[] { shaderSource }, (int[]) null, 0);
|
||||
// gl.glCompileShader(vertexShader);
|
||||
pgl.setShaderSource(vertexShader, shaderSource);
|
||||
pgl.compileShader(vertexShader);
|
||||
|
||||
checkLogInfo("Vertex shader " + file + " compilation: ", vertexShader);
|
||||
// ogl.gl.getGL2().glAttachObjectARB(programObject, vertexShader);
|
||||
pgl.attachShader(programObject, vertexShader);
|
||||
}
|
||||
|
||||
@@ -473,15 +446,12 @@ public class PShader {
|
||||
* @param filename the shader's filename, used to print error log information
|
||||
*/
|
||||
private void attachFragmentShader(String shaderSource, String file) {
|
||||
fragmentShader = ogl.createGLSLFragShaderObject();
|
||||
fragmentShader = renderer.createGLSLFragShaderObject();
|
||||
|
||||
// gl.glShaderSource(fragmentShader, 1, new String[] { shaderSource }, (int[]) null, 0);
|
||||
// gl.glCompileShader(fragmentShader);
|
||||
pgl.setShaderSource(fragmentShader, shaderSource);
|
||||
pgl.compileShader(fragmentShader);
|
||||
|
||||
checkLogInfo("Fragment shader " + file + " compilation: ", fragmentShader);
|
||||
// ogl.gl.getGL2().glAttachObjectARB(programObject, fragmentShader);
|
||||
pgl.attachShader(programObject, fragmentShader);
|
||||
}
|
||||
|
||||
@@ -499,15 +469,15 @@ public class PShader {
|
||||
|
||||
protected void release() {
|
||||
if (vertexShader != 0) {
|
||||
ogl.deleteGLSLVertShaderObject(vertexShader);
|
||||
renderer.deleteGLSLVertShaderObject(vertexShader);
|
||||
vertexShader = 0;
|
||||
}
|
||||
if (fragmentShader != 0) {
|
||||
ogl.deleteGLSLFragShaderObject(fragmentShader);
|
||||
renderer.deleteGLSLFragShaderObject(fragmentShader);
|
||||
fragmentShader = 0;
|
||||
}
|
||||
if (programObject != 0) {
|
||||
ogl.deleteGLSLProgramObject(programObject);
|
||||
renderer.deleteGLSLProgramObject(programObject);
|
||||
programObject = 0;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
Copyright (c) 2010 Ben Fry and Casey Reas
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -22,7 +23,6 @@
|
||||
|
||||
package processing.opengl;
|
||||
|
||||
import javax.media.opengl.GL;
|
||||
import javax.media.opengl.GLContext;
|
||||
import processing.core.PApplet;
|
||||
import processing.core.PConstants;
|
||||
@@ -37,10 +37,10 @@ import processing.core.PImage;
|
||||
public class PTexture implements PConstants {
|
||||
public int width, height;
|
||||
|
||||
protected PApplet parent; // The Processing applet
|
||||
protected PGraphicsOpenGL ogl; // The main renderer
|
||||
protected PGL pgl; // The interface between Processing and OpenGL.
|
||||
protected GLContext context; // The context that created this texture.
|
||||
protected PApplet parent; // The Processing applet
|
||||
protected PGraphicsOpenGL renderer; // The main renderer
|
||||
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!
|
||||
public int glID;
|
||||
@@ -91,9 +91,9 @@ public class PTexture implements PConstants {
|
||||
public PTexture(PApplet parent, int width, int height, Object params) {
|
||||
this.parent = parent;
|
||||
|
||||
ogl = (PGraphicsOpenGL)parent.g;
|
||||
pgl = ogl.pgl;
|
||||
context = ogl.getContext();
|
||||
renderer = (PGraphicsOpenGL)parent.g;
|
||||
pgl = renderer.pgl;
|
||||
context = renderer.getContext();
|
||||
|
||||
glID = 0;
|
||||
|
||||
@@ -104,7 +104,7 @@ public class PTexture implements PConstants {
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
if (glID != 0) {
|
||||
ogl.finalizeTextureObject(glID);
|
||||
renderer.finalizeTextureObject(glID);
|
||||
}
|
||||
} finally {
|
||||
super.finalize();
|
||||
@@ -190,13 +190,13 @@ public class PTexture implements PConstants {
|
||||
|
||||
|
||||
public void set(PImage img) {
|
||||
PTexture tex = (PTexture)img.getCache(ogl);
|
||||
PTexture tex = (PTexture)img.getCache(renderer);
|
||||
set(tex);
|
||||
}
|
||||
|
||||
|
||||
public void set(PImage img, int x, int y, int w, int h) {
|
||||
PTexture tex = (PTexture)img.getCache(ogl);
|
||||
PTexture tex = (PTexture)img.getCache(renderer);
|
||||
set(tex, x, y, w, h);
|
||||
}
|
||||
|
||||
@@ -239,8 +239,6 @@ public class PTexture implements PConstants {
|
||||
|
||||
pgl.enableTexturing(glTarget);
|
||||
pgl.bindTexture(glTarget, glID);
|
||||
// getGl().glEnable(glTarget);
|
||||
// getGl().glBindTexture(glTarget, glID);
|
||||
|
||||
if (usingMipmaps) {
|
||||
if (PGraphicsOpenGL.mipmapGeneration) {
|
||||
@@ -262,8 +260,6 @@ public class PTexture implements PConstants {
|
||||
rgbaPixels = null;
|
||||
}
|
||||
|
||||
// getGl().glBindTexture(glTarget, 0);
|
||||
// getGl().glDisable(glTarget);
|
||||
pgl.bindTexture(glTarget, 0);
|
||||
pgl.disableTexturing(glTarget);
|
||||
}
|
||||
@@ -294,18 +290,18 @@ public class PTexture implements PConstants {
|
||||
// Attaching the texture to the color buffer of a FBO, binding the FBO and reading the pixels
|
||||
// from the current draw buffer (which is the color buffer of the FBO).
|
||||
tempFbo.setColorBuffer(this);
|
||||
ogl.pushFramebuffer();
|
||||
ogl.setFramebuffer(tempFbo);
|
||||
renderer.pushFramebuffer();
|
||||
renderer.setFramebuffer(tempFbo);
|
||||
tempFbo.readPixels();
|
||||
ogl.popFramebuffer();
|
||||
renderer.popFramebuffer();
|
||||
} else {
|
||||
// Here we don't have FBOs, so the method above is of no use. What we do instead is
|
||||
// to draw the texture to the screen framebuffer, and then grab the pixels from there.
|
||||
ogl.pushFramebuffer();
|
||||
ogl.setFramebuffer(tempFbo);
|
||||
ogl.drawTexture(this, 0, 0, glWidth, glHeight, 0, 0, glWidth, glHeight);
|
||||
renderer.pushFramebuffer();
|
||||
renderer.setFramebuffer(tempFbo);
|
||||
renderer.drawTexture(this, 0, 0, glWidth, glHeight, 0, 0, glWidth, glHeight);
|
||||
tempFbo.readPixels();
|
||||
ogl.popFramebuffer();
|
||||
renderer.popFramebuffer();
|
||||
}
|
||||
|
||||
if (tempPixels == null) {
|
||||
@@ -408,15 +404,11 @@ public class PTexture implements PConstants {
|
||||
public void bind() {
|
||||
pgl.enableTexturing(glTarget);
|
||||
pgl.bindTexture(glTarget, glID);
|
||||
// getGl().glEnable(glTarget);
|
||||
// getGl().glBindTexture(glTarget, glID);
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
pgl.enableTexturing(glTarget);
|
||||
pgl.unbindTexture(glTarget);
|
||||
// getGl().glEnable(glTarget);
|
||||
// getGl().glBindTexture(glTarget, 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@@ -705,16 +697,10 @@ public class PTexture implements PConstants {
|
||||
protected void allocate() {
|
||||
release(); // Just in the case this object is being re-allocated.
|
||||
|
||||
// getGl().glEnable(glTarget);
|
||||
pgl.enableTexturing(glTarget);
|
||||
|
||||
glID = ogl.createTextureObject();
|
||||
glID = renderer.createTextureObject();
|
||||
|
||||
//getGl().glBindTexture(glTarget, glID);
|
||||
// getGl().glTexParameteri(glTarget, GL.GL_TEXTURE_MIN_FILTER, glMinFilter);
|
||||
// getGl().glTexParameteri(glTarget, GL.GL_TEXTURE_MAG_FILTER, glMagFilter);
|
||||
// getGl().glTexParameteri(glTarget, GL.GL_TEXTURE_WRAP_S, glWrapS);
|
||||
// getGl().glTexParameteri(glTarget, GL.GL_TEXTURE_WRAP_T, glWrapT);
|
||||
pgl.bindTexture(glTarget, glID);
|
||||
pgl.setTexMinFilter(glTarget, glMinFilter);
|
||||
pgl.setTexMagFilter(glTarget, glMagFilter);
|
||||
@@ -723,7 +709,6 @@ public class PTexture implements PConstants {
|
||||
|
||||
// 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)
|
||||
// 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
|
||||
@@ -732,8 +717,6 @@ public class PTexture implements PConstants {
|
||||
setTexels(0, 0, width, height, texels);
|
||||
texels = null;
|
||||
|
||||
// getGl().glBindTexture(glTarget, 0);
|
||||
// getGl().glDisable(glTarget);
|
||||
pgl.unbindTexture(glTarget);
|
||||
pgl.disableTexturing(glTarget);
|
||||
}
|
||||
@@ -744,7 +727,7 @@ public class PTexture implements PConstants {
|
||||
*/
|
||||
protected void release() {
|
||||
if (glID != 0) {
|
||||
ogl.finalizeTextureObject(glID);
|
||||
renderer.finalizeTextureObject(glID);
|
||||
glID = 0;
|
||||
}
|
||||
}
|
||||
@@ -770,19 +753,19 @@ public class PTexture implements PConstants {
|
||||
tempFbo.disableDepthTest();
|
||||
|
||||
// FBO copy:
|
||||
ogl.pushFramebuffer();
|
||||
ogl.setFramebuffer(tempFbo);
|
||||
renderer.pushFramebuffer();
|
||||
renderer.setFramebuffer(tempFbo);
|
||||
if (scale) {
|
||||
// Rendering tex into "this", and scaling the source rectangle
|
||||
// to cover the entire destination region.
|
||||
ogl.drawTexture(tex, x, y, w, h, 0, 0, width, height);
|
||||
renderer.drawTexture(tex, x, y, w, h, 0, 0, width, height);
|
||||
} else {
|
||||
// Rendering tex into "this" but without scaling so the contents
|
||||
// of the source texture fall in the corresponding texels of the
|
||||
// destination.
|
||||
ogl.drawTexture(tex, x, y, w, h, x, y, w, h);
|
||||
renderer.drawTexture(tex, x, y, w, h, x, y, w, h);
|
||||
}
|
||||
ogl.popFramebuffer();
|
||||
renderer.popFramebuffer();
|
||||
}
|
||||
|
||||
protected void setTexels(int x, int y, int w, int h, int[] pix) {
|
||||
@@ -803,7 +786,7 @@ public class PTexture implements PConstants {
|
||||
height = src.height;
|
||||
|
||||
parent = src.parent;
|
||||
ogl = src.ogl;
|
||||
renderer = src.renderer;
|
||||
|
||||
glID = src.glID;
|
||||
glTarget = src.glTarget;
|
||||
@@ -923,13 +906,6 @@ public class PTexture implements PConstants {
|
||||
flippedY = false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Utilities
|
||||
|
||||
// protected GL getGl() {
|
||||
// return ogl.pgl.gl;
|
||||
// }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Reference in New Issue
Block a user