mirror of
https://github.com/processing/processing4.git
synced 2026-02-04 06:09:17 +01:00
Debugged offscreen rendering
This commit is contained in:
@@ -138,7 +138,7 @@ public class PFramebuffer implements PConstants {
|
||||
}
|
||||
|
||||
screenFb = screen;
|
||||
|
||||
|
||||
allocate();
|
||||
noDepth = false;
|
||||
|
||||
@@ -187,7 +187,9 @@ public class PFramebuffer implements PConstants {
|
||||
public void copy(PFramebuffer 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, 0, 0, dest.width, dest.height, PGL.GL_COLOR_BUFFER_BIT, PGL.GL_NEAREST);
|
||||
pgl.glBlitFramebuffer(0, 0, this.width, this.height,
|
||||
0, 0, dest.width, dest.height,
|
||||
PGL.GL_COLOR_BUFFER_BIT, PGL.GL_NEAREST);
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
@@ -362,7 +364,7 @@ public class PFramebuffer implements PConstants {
|
||||
if (multisample) {
|
||||
createColorBufferMultisample();
|
||||
}
|
||||
|
||||
|
||||
if (combinedDepthStencil) {
|
||||
createCombinedDepthStencilBuffer();
|
||||
} else {
|
||||
@@ -372,7 +374,7 @@ public class PFramebuffer implements PConstants {
|
||||
if (0 < stencilBits) {
|
||||
createStencilBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -408,7 +410,7 @@ public class PFramebuffer implements PConstants {
|
||||
pg.setFramebuffer(this);
|
||||
|
||||
glColorBufferMultisampleID = pg.createRenderBufferObject();
|
||||
pgl.glBindRenderbuffer(PGL.GL_RENDERBUFFER, glColorBufferMultisampleID);
|
||||
pgl.glBindRenderbuffer(PGL.GL_RENDERBUFFER, glColorBufferMultisampleID);
|
||||
pgl.glRenderbufferStorageMultisample(PGL.GL_RENDERBUFFER, nsamples, PGL.GL_RGBA8, width, height);
|
||||
pgl.glFramebufferRenderbuffer(PGL.GL_FRAMEBUFFER, PGL.GL_COLOR_ATTACHMENT0, PGL.GL_RENDERBUFFER, glColorBufferMultisampleID);
|
||||
|
||||
|
||||
@@ -139,8 +139,8 @@ public class PGL {
|
||||
public static final int GL_CLAMP_TO_EDGE = GL.GL_CLAMP_TO_EDGE;
|
||||
public static final int GL_REPEAT = GL.GL_REPEAT;
|
||||
|
||||
public static final int GL_RGBA8 = -1;
|
||||
public static final int GL_DEPTH24_STENCIL8 = -1;
|
||||
public static final int GL_RGBA8 = GL.GL_RGBA8;
|
||||
public static final int GL_DEPTH24_STENCIL8 = GL.GL_DEPTH24_STENCIL8;
|
||||
|
||||
public static final int GL_DEPTH_COMPONENT16 = GL.GL_DEPTH_COMPONENT16;
|
||||
public static final int GL_DEPTH_COMPONENT24 = GL.GL_DEPTH_COMPONENT24;
|
||||
@@ -876,7 +876,7 @@ public class PGL {
|
||||
// Pixels
|
||||
|
||||
|
||||
public void setReadBuffer(int buf) {
|
||||
public void glReadBuffer(int buf) {
|
||||
gl2.glReadBuffer(buf);
|
||||
}
|
||||
|
||||
@@ -886,7 +886,7 @@ public class PGL {
|
||||
}
|
||||
|
||||
|
||||
public void setDrawBuffer(int buf) {
|
||||
public void glDrawBuffer(int buf) {
|
||||
gl2.glDrawBuffer(buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -722,7 +722,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
deleteFinalizedRenderBufferObjects();
|
||||
|
||||
int[] temp = new int[1];
|
||||
pgl.glDeleteRenderbuffers(1, temp, 0);
|
||||
pgl.glGenRenderbuffers(1, temp, 0);
|
||||
int id = temp[0];
|
||||
|
||||
if (glRenderBuffers.containsKey(id)) {
|
||||
@@ -736,8 +736,8 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
protected void deleteRenderBufferObject(int id) {
|
||||
if (glRenderBuffers.containsKey(id)) {
|
||||
int[] temp = { id };
|
||||
pgl.glGenRenderbuffers(1, temp, 0);
|
||||
int[] temp = { id };
|
||||
pgl.glDeleteRenderbuffers(1, temp, 0);
|
||||
glRenderBuffers.remove(id);
|
||||
}
|
||||
}
|
||||
@@ -1374,13 +1374,13 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
pgl.updatePrimary();
|
||||
} else {
|
||||
if (!pgl.initialized) {
|
||||
initOffscreen();
|
||||
initOffscreen();
|
||||
}
|
||||
|
||||
pushFramebuffer();
|
||||
if (offscreenMultisample) {
|
||||
setFramebuffer(offscreenFramebufferMultisample);
|
||||
pgl.setDrawBuffer(0);
|
||||
pgl.glDrawBuffer(PGL.GL_COLOR_ATTACHMENT0);
|
||||
} else {
|
||||
setFramebuffer(offscreenFramebuffer);
|
||||
}
|
||||
@@ -4494,7 +4494,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
pixelBuffer.rewind();
|
||||
if (primarySurface) {
|
||||
pgl.setReadBuffer(PGL.GL_FRONT);
|
||||
pgl.glReadBuffer(PGL.GL_FRONT);
|
||||
}
|
||||
pgl.glReadPixels(0, 0, width, height, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, pixelBuffer);
|
||||
|
||||
@@ -4953,7 +4953,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
getsetBuffer.rewind();
|
||||
if (primarySurface) {
|
||||
pgl.setReadBuffer(PGL.GL_FRONT);
|
||||
pgl.glReadBuffer(PGL.GL_FRONT);
|
||||
}
|
||||
pgl.glReadPixels(x, height - y - 1, 1, 1, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, getsetBuffer);
|
||||
|
||||
@@ -4995,7 +4995,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
newbieBuffer.rewind();
|
||||
if (primarySurface) {
|
||||
pgl.setReadBuffer(PGL.GL_FRONT);
|
||||
pgl.glReadBuffer(PGL.GL_FRONT);
|
||||
}
|
||||
|
||||
pgl.glReadPixels(x, height - y - h, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, newbieBuffer);
|
||||
@@ -5577,24 +5577,23 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
pg = (PGraphicsOpenGL)parent.g;
|
||||
pgl.initOffscreenSurface(pg.pgl);
|
||||
|
||||
pgl.updateOffscreen(pg.pgl);;
|
||||
pgl.updateOffscreen(pg.pgl);
|
||||
loadTextureImpl(BILINEAR);
|
||||
|
||||
// In case of reinitialization (for example, when the smooth level
|
||||
// is changed), we make sure that all the OpenGL resources associated
|
||||
// to the surface are released by calling delete().
|
||||
if (offscreenFramebuffer != null) {
|
||||
offscreenFramebuffer = null;
|
||||
offscreenFramebuffer.release();
|
||||
}
|
||||
if (offscreenFramebufferMultisample != null) {
|
||||
offscreenFramebufferMultisample = null;
|
||||
offscreenFramebufferMultisample.release();
|
||||
}
|
||||
|
||||
// We need the GL2GL3 profile to access the glRenderbufferStorageMultisample
|
||||
// function used in multisampled (antialiased) offscreen rendering.
|
||||
if (PGraphicsOpenGL.fboMultisampleSupported && 1 < antialias) {
|
||||
int nsamples = antialias;
|
||||
offscreenFramebufferMultisample = new PFramebuffer(parent, texture.glWidth, texture.glHeight, nsamples, 0,
|
||||
offscreenFramebufferMultisample = new PFramebuffer(parent, texture.glWidth, texture.glHeight, antialias, 0,
|
||||
offscreenDepthBits, offscreenStencilBits,
|
||||
offscreenDepthBits == 24 && offscreenStencilBits == 8, false);
|
||||
|
||||
@@ -5606,15 +5605,15 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
offscreenFramebuffer = new PFramebuffer(parent, texture.glWidth, texture.glHeight, 1, 1,
|
||||
0, 0,
|
||||
false, false);
|
||||
|
||||
|
||||
} else {
|
||||
antialias = 0;
|
||||
offscreenFramebuffer = new PFramebuffer(parent, texture.glWidth, texture.glHeight, 1, 1,
|
||||
offscreenDepthBits, offscreenStencilBits,
|
||||
offscreenDepthBits == 24 && offscreenStencilBits == 8, false);
|
||||
offscreenMultisample = false;
|
||||
}
|
||||
|
||||
|
||||
offscreenFramebuffer.setColorBuffer(texture);
|
||||
offscreenFramebuffer.clear();
|
||||
}
|
||||
|
||||
@@ -2590,9 +2590,14 @@ public class PShape3D extends PShape {
|
||||
|
||||
protected void tessellateBox() {
|
||||
// TODO: move to InGeometry
|
||||
float w = params[0];
|
||||
float h = params[1];
|
||||
float d = params[2];
|
||||
float w, h, d;
|
||||
if (params.length == 1) {
|
||||
w = h = d = params[0];
|
||||
} else {
|
||||
w = params[0];
|
||||
h = params[1];
|
||||
d = params[2];
|
||||
}
|
||||
|
||||
float x1 = -w/2f; float x2 = w/2f;
|
||||
float y1 = -h/2f; float y2 = h/2f;
|
||||
|
||||
Reference in New Issue
Block a user