mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
enable/disable depth mask
This commit is contained in:
@@ -3232,6 +3232,12 @@ public class PGraphics extends PImage implements PConstants {
|
||||
textLeading = (textAscent() + textDescent()) * 1.275f;
|
||||
}
|
||||
|
||||
protected void beginTextScreenMode() {
|
||||
}
|
||||
|
||||
protected void endTextScreenMode() {
|
||||
}
|
||||
|
||||
// ........................................................
|
||||
|
||||
|
||||
@@ -3319,7 +3325,7 @@ public class PGraphics extends PImage implements PConstants {
|
||||
defaultFontOrDeath("text");
|
||||
}
|
||||
|
||||
if (textMode == SCREEN) loadPixels();
|
||||
if (textMode == SCREEN) beginTextScreenMode();
|
||||
|
||||
if (textAlignY == CENTER) {
|
||||
y += textAscent() / 2;
|
||||
@@ -3334,7 +3340,7 @@ public class PGraphics extends PImage implements PConstants {
|
||||
textBuffer[0] = c;
|
||||
textLineAlignImpl(textBuffer, 0, 1, x, y);
|
||||
|
||||
if (textMode == SCREEN) updatePixels();
|
||||
if (textMode == SCREEN) endTextScreenMode();
|
||||
}
|
||||
|
||||
|
||||
@@ -3375,8 +3381,6 @@ public class PGraphics extends PImage implements PConstants {
|
||||
defaultFontOrDeath("text");
|
||||
}
|
||||
|
||||
if (textMode == SCREEN) loadPixels();
|
||||
|
||||
int length = str.length();
|
||||
if (length > textBuffer.length) {
|
||||
textBuffer = new char[length + 10];
|
||||
@@ -3392,6 +3396,8 @@ public class PGraphics extends PImage implements PConstants {
|
||||
* not be converted to a char array before drawing.
|
||||
*/
|
||||
public void text(char[] chars, int start, int stop, float x, float y) {
|
||||
if (textMode == SCREEN) beginTextScreenMode();
|
||||
|
||||
// If multiple lines, sum the height of the additional lines
|
||||
float high = 0; //-textAscent();
|
||||
for (int i = start; i < stop; i++) {
|
||||
@@ -3429,7 +3435,8 @@ public class PGraphics extends PImage implements PConstants {
|
||||
if (start < stop) { //length) {
|
||||
textLineAlignImpl(chars, start, index, x, y);
|
||||
}
|
||||
if (textMode == SCREEN) updatePixels();
|
||||
|
||||
if (textMode == SCREEN) endTextScreenMode();
|
||||
}
|
||||
|
||||
|
||||
@@ -3475,7 +3482,7 @@ public class PGraphics extends PImage implements PConstants {
|
||||
defaultFontOrDeath("text");
|
||||
}
|
||||
|
||||
if (textMode == SCREEN) loadPixels();
|
||||
if (textMode == SCREEN) beginTextScreenMode();
|
||||
|
||||
float hradius, vradius;
|
||||
switch (rectMode) {
|
||||
@@ -3584,7 +3591,7 @@ public class PGraphics extends PImage implements PConstants {
|
||||
}
|
||||
}
|
||||
|
||||
if (textMode == SCREEN) updatePixels();
|
||||
if (textMode == SCREEN) endTextScreenMode();
|
||||
}
|
||||
|
||||
|
||||
@@ -3705,8 +3712,7 @@ public class PGraphics extends PImage implements PConstants {
|
||||
text(PApplet.nfs(num, 0, 3), x, y, z);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// TEXT IMPL
|
||||
|
||||
@@ -1501,7 +1501,14 @@ public class PGraphics2D extends PGraphics {
|
||||
|
||||
// These will be handled entirely by PGraphics.
|
||||
|
||||
|
||||
|
||||
protected void beginTextScreenMode() {
|
||||
loadPixels();
|
||||
}
|
||||
|
||||
protected void endTextScreenMode() {
|
||||
updatePixels();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -524,10 +524,13 @@ public class PGraphics3D extends PGraphics {
|
||||
if (which == DISABLE_DEPTH_SORT) {
|
||||
flush();
|
||||
} else if (which == DISABLE_DEPTH_TEST) {
|
||||
if (zbuffer != null) { // will be null in OpenGL and others
|
||||
Arrays.fill(zbuffer, Float.MAX_VALUE);
|
||||
}
|
||||
|
||||
//if (zbuffer != null) { // will be null in OpenGL and others
|
||||
// Arrays.fill(zbuffer, Float.MAX_VALUE);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
super.hint(which);
|
||||
}
|
||||
|
||||
@@ -1007,7 +1010,7 @@ public class PGraphics3D extends PGraphics {
|
||||
if (sx >= 0 && sx < width && sy >= 0 && sy < height) {
|
||||
int index = sy*width + sx;
|
||||
pixels[index] = points[i][STROKE_COLOR];
|
||||
zbuffer[index] = a[TZ];
|
||||
if (!hints[DISABLE_DEPTH_MASK]) zbuffer[index] = a[TZ];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2970,6 +2973,13 @@ public class PGraphics3D extends PGraphics {
|
||||
return (textMode == MODEL) || (textMode == SCREEN);
|
||||
}
|
||||
|
||||
protected void beginTextScreenMode() {
|
||||
loadPixels();
|
||||
}
|
||||
|
||||
protected void endTextScreenMode() {
|
||||
updatePixels();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1130,7 +1130,13 @@ public class PGraphicsJava2D extends PGraphics /*PGraphics2D*/ {
|
||||
return super.textWidthImpl(buffer, start, stop);
|
||||
}
|
||||
|
||||
|
||||
protected void beginTextScreenMode() {
|
||||
loadPixels();
|
||||
}
|
||||
|
||||
protected void endTextScreenMode() {
|
||||
updatePixels();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -99,7 +99,9 @@ public class PLine implements PConstants
|
||||
|
||||
private PGraphics parent;
|
||||
|
||||
|
||||
private boolean noDepthTest;
|
||||
private boolean updateZBuffer;
|
||||
|
||||
public PLine(PGraphics g) {
|
||||
INTERPOLATE_Z = false;
|
||||
|
||||
@@ -126,6 +128,11 @@ public class PLine implements PConstants
|
||||
//m_stencil = parent.stencil;
|
||||
if (parent instanceof PGraphics3D) {
|
||||
m_zbuffer = ((PGraphics3D) parent).zbuffer;
|
||||
noDepthTest = parent.hints[DISABLE_DEPTH_TEST];
|
||||
updateZBuffer = !parent.hints[DISABLE_DEPTH_MASK];
|
||||
} else {
|
||||
noDepthTest = true;
|
||||
updateZBuffer = false;
|
||||
}
|
||||
|
||||
// other things to reset
|
||||
@@ -526,9 +533,9 @@ public class PLine implements PConstants
|
||||
m_pixels[offset] = m_stroke;
|
||||
|
||||
} else {
|
||||
if (iz <= m_zbuffer[offset]) {
|
||||
if (noDepthTest || iz <= m_zbuffer[offset]) {
|
||||
m_pixels[offset] = m_stroke;
|
||||
m_zbuffer[offset] = iz;
|
||||
if (updateZBuffer) m_zbuffer[offset] = iz;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -542,7 +549,7 @@ public class PLine implements PConstants
|
||||
float iz = m_z0;
|
||||
int offset = y0 * SCREEN_WIDTH + x0;
|
||||
|
||||
if ((m_zbuffer == null) || iz <= m_zbuffer[offset]) {
|
||||
if (noDepthTest || (m_zbuffer == null) || iz <= m_zbuffer[offset]) {
|
||||
int alpha = ia >> 16;
|
||||
int r0 = m_pixels[offset];
|
||||
int g0 = r0 & 0xFF00;
|
||||
@@ -555,7 +562,7 @@ public class PLine implements PConstants
|
||||
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
(r0 & 0xFF0000) | (g0 & 0xFF00) | (b0 & 0xFF);
|
||||
if (m_zbuffer != null) m_zbuffer[offset] = iz;
|
||||
if (updateZBuffer && m_zbuffer != null) m_zbuffer[offset] = iz;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -578,7 +585,7 @@ public class PLine implements PConstants
|
||||
for (int j = 0x8000 + (x0<<16); y0 <= length; ++y0) {
|
||||
offset = y0 * SCREEN_WIDTH + (j>>16);
|
||||
m_pixels[offset] = m_stroke;
|
||||
if (m_zbuffer != null) m_zbuffer[offset] = m_z0;
|
||||
if (updateZBuffer && m_zbuffer != null) m_zbuffer[offset] = m_z0;
|
||||
j+=dt;
|
||||
}
|
||||
|
||||
@@ -588,7 +595,7 @@ public class PLine implements PConstants
|
||||
for (int j = 0x8000 + (y0<<16); x0 <= length; ++x0) {
|
||||
offset = (j>>16) * SCREEN_WIDTH + x0;
|
||||
m_pixels[offset] = m_stroke;
|
||||
if (m_zbuffer != null) m_zbuffer[offset] = m_z0;
|
||||
if (updateZBuffer && m_zbuffer != null) m_zbuffer[offset] = m_z0;
|
||||
j+=dt;
|
||||
}
|
||||
}
|
||||
@@ -666,7 +673,7 @@ public class PLine implements PConstants
|
||||
offset = y0 * SCREEN_WIDTH + (j>>16);
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
((ir & 0xFF0000) | ((ig >> 8) & 0xFF00) | (ib >> 16));
|
||||
if (m_zbuffer != null) m_zbuffer[offset] = m_z0;
|
||||
if (updateZBuffer && m_zbuffer != null) m_zbuffer[offset] = m_z0;
|
||||
ir += dr;
|
||||
ig += dg;
|
||||
ib += db;
|
||||
@@ -679,7 +686,7 @@ public class PLine implements PConstants
|
||||
offset = (j>>16) * SCREEN_WIDTH + x0;
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
((ir & 0xFF0000) | ((ig >> 8) & 0xFF00) | (ib >> 16));
|
||||
if (m_zbuffer != null) m_zbuffer[offset] = m_z0;
|
||||
if (updateZBuffer && m_zbuffer != null) m_zbuffer[offset] = m_z0;
|
||||
ir += dr;
|
||||
ig += dg;
|
||||
ib += db;
|
||||
@@ -720,7 +727,7 @@ public class PLine implements PConstants
|
||||
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
(r0 & 0xFF0000) | (g0 & 0xFF00) | (b0 & 0xFF);
|
||||
if (m_zbuffer != null) m_zbuffer[offset] = m_z0;
|
||||
if (updateZBuffer && m_zbuffer != null) m_zbuffer[offset] = m_z0;
|
||||
|
||||
ir+= dr;
|
||||
ig+= dg;
|
||||
@@ -751,7 +758,7 @@ public class PLine implements PConstants
|
||||
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
(r0 & 0xFF0000) | (g0 & 0xFF00) | (b0 & 0xFF);
|
||||
if (m_zbuffer != null) m_zbuffer[offset] = m_z0;
|
||||
if (updateZBuffer && m_zbuffer != null) m_zbuffer[offset] = m_z0;
|
||||
|
||||
ir+= dr;
|
||||
ig+= dg;
|
||||
@@ -773,9 +780,9 @@ public class PLine implements PConstants
|
||||
for (int j = 0x8000 + (x0<<16); y0 <= length; ++y0) {
|
||||
offset = y0 * SCREEN_WIDTH + (j>>16);
|
||||
if (offset < m_pixels.length) {
|
||||
if (iz <= m_zbuffer[offset]) {
|
||||
if (noDepthTest || iz <= m_zbuffer[offset]) {
|
||||
m_pixels[offset] = m_stroke;
|
||||
m_zbuffer[offset] = iz;
|
||||
if (updateZBuffer) m_zbuffer[offset] = iz;
|
||||
}
|
||||
}
|
||||
iz+=dz;
|
||||
@@ -787,9 +794,9 @@ public class PLine implements PConstants
|
||||
for (int j = 0x8000 + (y0<<16); x0 <= length; ++x0) {
|
||||
offset = (j>>16) * SCREEN_WIDTH + x0;
|
||||
if (offset < m_pixels.length) {
|
||||
if (iz <= m_zbuffer[offset]) {
|
||||
if (noDepthTest || iz <= m_zbuffer[offset]) {
|
||||
m_pixels[offset] = m_stroke;
|
||||
m_zbuffer[offset] = iz;
|
||||
if (updateZBuffer) m_zbuffer[offset] = iz;
|
||||
}
|
||||
}
|
||||
iz+=dz;
|
||||
@@ -815,7 +822,7 @@ public class PLine implements PConstants
|
||||
for (int j = 0x8000 + (x0<<16); y0 <= length; ++y0) {
|
||||
offset = y0 * SCREEN_WIDTH + (j>>16);
|
||||
if (offset < m_pixels.length) {
|
||||
if (iz <= m_zbuffer[offset]) {
|
||||
if (noDepthTest || iz <= m_zbuffer[offset]) {
|
||||
int alpha = ia >> 16;
|
||||
int r0 = m_pixels[offset];
|
||||
int g0 = r0 & 0xFF00;
|
||||
@@ -827,7 +834,7 @@ public class PLine implements PConstants
|
||||
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
(r0 & 0xFF0000) | (g0 & 0xFF00) | (b0 & 0xFF);
|
||||
m_zbuffer[offset] = iz;
|
||||
if (updateZBuffer) m_zbuffer[offset] = iz;
|
||||
}
|
||||
}
|
||||
iz +=dz;
|
||||
@@ -841,7 +848,7 @@ public class PLine implements PConstants
|
||||
offset = (j>>16) * SCREEN_WIDTH + x0;
|
||||
|
||||
if (offset < m_pixels.length) {
|
||||
if (iz <= m_zbuffer[offset]) {
|
||||
if (noDepthTest || iz <= m_zbuffer[offset]) {
|
||||
int alpha = ia >> 16;
|
||||
int r0 = m_pixels[offset];
|
||||
int g0 = r0 & 0xFF00;
|
||||
@@ -853,7 +860,7 @@ public class PLine implements PConstants
|
||||
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
(r0 & 0xFF0000) | (g0 & 0xFF00) | (b0 & 0xFF);
|
||||
m_zbuffer[offset] = iz;
|
||||
if (updateZBuffer) m_zbuffer[offset] = iz;
|
||||
}
|
||||
}
|
||||
iz += dz;
|
||||
@@ -878,10 +885,10 @@ public class PLine implements PConstants
|
||||
for (int j = 0x8000 + (x0<<16); y0 <= length; ++y0) {
|
||||
offset = y0 * SCREEN_WIDTH + (j>>16);
|
||||
|
||||
if (iz <= m_zbuffer[offset]) {
|
||||
if (noDepthTest || iz <= m_zbuffer[offset]) {
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
((ir & 0xFF0000) | ((ig >> 8) & 0xFF00) | (ib >> 16));
|
||||
m_zbuffer[offset] = iz;
|
||||
if (updateZBuffer) m_zbuffer[offset] = iz;
|
||||
}
|
||||
iz +=dz;
|
||||
ir += dr;
|
||||
@@ -893,10 +900,10 @@ public class PLine implements PConstants
|
||||
length += x0;
|
||||
for (int j = 0x8000 + (y0<<16); x0 <= length; ++x0) {
|
||||
offset = (j>>16) * SCREEN_WIDTH + x0;
|
||||
if (iz <= m_zbuffer[offset]) {
|
||||
if (noDepthTest || iz <= m_zbuffer[offset]) {
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
((ir & 0xFF0000) | ((ig >> 8) & 0xFF00) | (ib >> 16));
|
||||
m_zbuffer[offset] = iz;
|
||||
if (updateZBuffer) m_zbuffer[offset] = iz;
|
||||
}
|
||||
iz += dz;
|
||||
ir += dr;
|
||||
@@ -924,7 +931,7 @@ public class PLine implements PConstants
|
||||
for (int j = 0x8000 + (x0<<16); y0 <= length; ++y0) {
|
||||
offset = y0 * SCREEN_WIDTH + (j>>16);
|
||||
|
||||
if (iz <= m_zbuffer[offset]) {
|
||||
if (noDepthTest || iz <= m_zbuffer[offset]) {
|
||||
int pr = ir & 0xFF0000;
|
||||
int pg = (ig >> 8) & 0xFF00;
|
||||
int pb = (ib >> 16);
|
||||
@@ -942,7 +949,7 @@ public class PLine implements PConstants
|
||||
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
(r0 & 0xFF0000) | (g0 & 0xFF00) | (b0 & 0xFF);
|
||||
m_zbuffer[offset] = iz;
|
||||
if (updateZBuffer) m_zbuffer[offset] = iz;
|
||||
}
|
||||
iz+=dz;
|
||||
ir+= dr;
|
||||
@@ -957,7 +964,7 @@ public class PLine implements PConstants
|
||||
for (int j = 0x8000 + (y0<<16); x0 <= length; ++x0) {
|
||||
offset = (j>>16) * SCREEN_WIDTH + x0;
|
||||
|
||||
if (iz <= m_zbuffer[offset]) {
|
||||
if (noDepthTest || iz <= m_zbuffer[offset]) {
|
||||
int pr = ir & 0xFF0000;
|
||||
int pg = (ig >> 8) & 0xFF00;
|
||||
int pb = (ib >> 16);
|
||||
@@ -975,7 +982,7 @@ public class PLine implements PConstants
|
||||
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
(r0 & 0xFF0000) | (g0 & 0xFF00) | (b0 & 0xFF);
|
||||
m_zbuffer[offset] = iz;
|
||||
if (updateZBuffer) m_zbuffer[offset] = iz;
|
||||
}
|
||||
iz += dz;
|
||||
ir += dr;
|
||||
@@ -1016,7 +1023,7 @@ public class PLine implements PConstants
|
||||
int pg = (ig >> 8) & 0xFF00;
|
||||
int pb = (ib >> 16);
|
||||
|
||||
if ((m_zbuffer == null) || (iz <= m_zbuffer[offset])) {
|
||||
if (noDepthTest || (m_zbuffer == null) || (iz <= m_zbuffer[offset])) {
|
||||
int alpha = (((~xi >> 8) & 0xFF) * (ia >> 16)) >> 8;
|
||||
|
||||
int r0 = m_pixels[offset];
|
||||
@@ -1030,7 +1037,7 @@ public class PLine implements PConstants
|
||||
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
(r0 & 0xFF0000) | (g0 & 0xFF00) | (b0 & 0xFF);
|
||||
if (m_zbuffer != null) m_zbuffer[offset] = iz;
|
||||
if (updateZBuffer && m_zbuffer != null) m_zbuffer[offset] = iz;
|
||||
}
|
||||
|
||||
// this if() makes things slow. there should be a better way to check
|
||||
@@ -1044,7 +1051,7 @@ public class PLine implements PConstants
|
||||
|
||||
offset = (yi>>16) * SCREEN_WIDTH + temp;
|
||||
|
||||
if ((m_zbuffer == null) || (iz <= m_zbuffer[offset])) {
|
||||
if (noDepthTest || (m_zbuffer == null) || (iz <= m_zbuffer[offset])) {
|
||||
int alpha = (((xi >> 8) & 0xFF) * (ia >> 16)) >> 8;
|
||||
|
||||
int r0 = m_pixels[offset];
|
||||
@@ -1058,7 +1065,7 @@ public class PLine implements PConstants
|
||||
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
(r0 & 0xFF0000) | (g0 & 0xFF00) | (b0 & 0xFF);
|
||||
if (m_zbuffer != null) m_zbuffer[offset] = iz;
|
||||
if (updateZBuffer && m_zbuffer != null) m_zbuffer[offset] = iz;
|
||||
}
|
||||
|
||||
xi += dt;
|
||||
@@ -1083,7 +1090,7 @@ public class PLine implements PConstants
|
||||
int pg = (ig >> 8) & 0xFF00;
|
||||
int pb = (ib >> 16);
|
||||
|
||||
if ((m_zbuffer == null) || (iz <= m_zbuffer[offset])) {
|
||||
if (noDepthTest || (m_zbuffer == null) || (iz <= m_zbuffer[offset])) {
|
||||
int alpha = (((~yi >> 8) & 0xFF) * (ia >> 16)) >> 8;
|
||||
|
||||
int r0 = m_pixels[offset];
|
||||
@@ -1097,7 +1104,7 @@ public class PLine implements PConstants
|
||||
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
(r0 & 0xFF0000) | (g0 & 0xFF00) | (b0 & 0xFF);
|
||||
if (m_zbuffer != null) m_zbuffer[offset] = iz;
|
||||
if (updateZBuffer && m_zbuffer != null) m_zbuffer[offset] = iz;
|
||||
}
|
||||
|
||||
// see above [rocha]
|
||||
@@ -1110,7 +1117,7 @@ public class PLine implements PConstants
|
||||
|
||||
offset = temp * SCREEN_WIDTH + (xi>>16);
|
||||
|
||||
if ((m_zbuffer == null) || (iz <= m_zbuffer[offset])) {
|
||||
if (noDepthTest || (m_zbuffer == null) || (iz <= m_zbuffer[offset])) {
|
||||
int alpha = (((yi >> 8) & 0xFF) * (ia >> 16)) >> 8;
|
||||
|
||||
int r0 = m_pixels[offset];
|
||||
@@ -1124,7 +1131,7 @@ public class PLine implements PConstants
|
||||
|
||||
m_pixels[offset] = 0xFF000000 |
|
||||
(r0 & 0xFF0000) | (g0 & 0xFF00) | (b0 & 0xFF);
|
||||
if (m_zbuffer != null) m_zbuffer[offset] = iz;
|
||||
if (updateZBuffer && m_zbuffer != null) m_zbuffer[offset] = iz;
|
||||
}
|
||||
|
||||
xi += (1 << 16);
|
||||
|
||||
@@ -76,6 +76,7 @@ public class PSmoothTriangle implements PConstants {
|
||||
int r2, g2, b2, a2, a2orig;
|
||||
|
||||
boolean noDepthTest;
|
||||
boolean updateZBuffer;
|
||||
|
||||
PGraphics3D parent;
|
||||
int pixels[];
|
||||
@@ -188,7 +189,8 @@ public class PSmoothTriangle implements PConstants {
|
||||
pixels = parent.pixels;
|
||||
zbuffer = parent.zbuffer;
|
||||
|
||||
noDepthTest = false;//parent.hints[DISABLE_DEPTH_TEST];
|
||||
noDepthTest = parent.hints[DISABLE_DEPTH_TEST];
|
||||
updateZBuffer = !parent.hints[DISABLE_DEPTH_MASK];
|
||||
|
||||
// In 0148+, should always be true if this code is called at all
|
||||
//smooth = parent.smooth;
|
||||
@@ -561,7 +563,7 @@ public class PSmoothTriangle implements PConstants {
|
||||
if ((ta == 254) || (ta == 255)) { // if (ta & 0xf8) would be good
|
||||
// no need to blend
|
||||
pixels[offset+x] = 0xff000000 | (tr << 16) | (tg << 8) | tb;
|
||||
zbuffer[offset+x] = sp[Z];
|
||||
if (updateZBuffer) zbuffer[offset+x] = sp[Z];
|
||||
} else {
|
||||
// blend with pixel on screen
|
||||
int a1 = 255-ta;
|
||||
@@ -578,7 +580,7 @@ public class PSmoothTriangle implements PConstants {
|
||||
|
||||
//System.out.println("17");
|
||||
//check
|
||||
if (ta > ZBUFFER_MIN_COVERAGE) zbuffer[offset+x] = sp[Z];
|
||||
if (updateZBuffer && ta > ZBUFFER_MIN_COVERAGE) zbuffer[offset+x] = sp[Z];
|
||||
}
|
||||
|
||||
//System.out.println("18");
|
||||
@@ -601,7 +603,7 @@ public class PSmoothTriangle implements PConstants {
|
||||
if (weight == 255) {
|
||||
// no blend, no aa, just the rgba
|
||||
pixels[offset+x] = rgba;
|
||||
zbuffer[offset+x] = sp[Z];
|
||||
if (updateZBuffer) zbuffer[offset+x] = sp[Z];
|
||||
|
||||
} else {
|
||||
int r1 = (pixels[offset+x] >> 16) & 0xff;
|
||||
@@ -616,7 +618,7 @@ public class PSmoothTriangle implements PConstants {
|
||||
((g1*a1 + g2*a2) >> 8) << 8 |
|
||||
((b1*a1 + b2*a2) >> 8));
|
||||
|
||||
if (a2 > ZBUFFER_MIN_COVERAGE) zbuffer[offset+x] = sp[Z];
|
||||
if (updateZBuffer && a2 > ZBUFFER_MIN_COVERAGE) zbuffer[offset+x] = sp[Z];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,6 +194,7 @@ public class PTriangle implements PConstants
|
||||
private PGraphics3D parent;
|
||||
|
||||
private boolean noDepthTest;
|
||||
private boolean updateZBuffer;
|
||||
//private boolean argbSurface;
|
||||
|
||||
/** */
|
||||
@@ -264,6 +265,7 @@ public class PTriangle implements PConstants
|
||||
m_zbuffer = parent.zbuffer;
|
||||
|
||||
noDepthTest = parent.hints[DISABLE_DEPTH_TEST];
|
||||
updateZBuffer = !parent.hints[DISABLE_DEPTH_MASK];
|
||||
//argbSurface = parent.format == PConstants.ARGB;
|
||||
|
||||
// other things to reset
|
||||
@@ -1102,7 +1104,7 @@ public class PTriangle implements PConstants
|
||||
|
||||
for ( ; xstart < xend; xstart++ ) {
|
||||
if (noDepthTest || (iz <= m_zbuffer[xstart])) {
|
||||
m_zbuffer[xstart] = iz;
|
||||
if (updateZBuffer) m_zbuffer[xstart] = iz;
|
||||
m_pixels[xstart] = m_fill;
|
||||
// m_stencil[xstart] = p;
|
||||
}
|
||||
@@ -1223,7 +1225,7 @@ public class PTriangle implements PConstants
|
||||
|
||||
for ( ; xstart < xend; xstart++ ) {
|
||||
if (noDepthTest || (iz <= m_zbuffer[xstart])) {
|
||||
m_zbuffer[xstart] = iz;
|
||||
if (updateZBuffer) m_zbuffer[xstart] = iz;
|
||||
m_pixels[xstart] = 0xFF000000 |
|
||||
((ir & 0xFF0000) | ((ig >> 8) & 0xFF00) | (ib >> 16));
|
||||
// m_stencil[xstart] = p;
|
||||
@@ -1860,7 +1862,7 @@ public class PTriangle implements PConstants
|
||||
// try-catch just in case pixel offset is out of range
|
||||
try{
|
||||
if (noDepthTest || (iz <= m_zbuffer[xstart])) {
|
||||
m_zbuffer[xstart] = iz;
|
||||
if (updateZBuffer) m_zbuffer[xstart] = iz;
|
||||
if (m_bilinear) {
|
||||
//We could (should?) add bounds checking on iu and iv here (keep in mind the 16 bit shift!).
|
||||
//This would also be the place to add looping texture mode (bounds check == clamped).
|
||||
@@ -3086,7 +3088,7 @@ public class PTriangle implements PConstants
|
||||
|
||||
try {
|
||||
if (noDepthTest || (iz <= m_zbuffer[xstart])) {
|
||||
m_zbuffer[xstart] = iz;
|
||||
if (updateZBuffer) m_zbuffer[xstart] = iz;
|
||||
|
||||
int red;
|
||||
int grn;
|
||||
|
||||
Reference in New Issue
Block a user