mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
use texture point sampling when user requests noSmooth()
This commit is contained in:
@@ -3513,10 +3513,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
lastSmoothCall = parent.frameCount;
|
||||
|
||||
quality = level;
|
||||
System.out.println(quality);
|
||||
|
||||
if (quality == 1) {
|
||||
if (quality <= 1) {
|
||||
quality = 0;
|
||||
textureSampling = Texture.POINT;
|
||||
} else {
|
||||
textureSampling = Texture.TRILINEAR;
|
||||
}
|
||||
|
||||
// This will trigger a surface restart next time
|
||||
@@ -3531,6 +3533,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
if (smoothDisabled) return;
|
||||
|
||||
smooth = false;
|
||||
textureSampling = Texture.POINT;
|
||||
|
||||
if (1 < quality) {
|
||||
smoothCallCount++;
|
||||
@@ -6392,7 +6395,8 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
protected void checkTexture(Texture tex) {
|
||||
if (!tex.colorBuffer() &&
|
||||
tex.usingMipmaps == hints[DISABLE_TEXTURE_MIPMAPS]) {
|
||||
(tex.usingMipmaps == hints[DISABLE_TEXTURE_MIPMAPS] ||
|
||||
tex.currentSampling() != textureSampling)) {
|
||||
if (hints[DISABLE_TEXTURE_MIPMAPS]) {
|
||||
tex.usingMipmaps(false, textureSampling);
|
||||
} else {
|
||||
|
||||
@@ -357,8 +357,7 @@ public class Texture implements PConstants {
|
||||
if (PGraphicsOpenGL.autoMipmapGenSupported) {
|
||||
pgl.generateMipmap(glTarget);
|
||||
} else {
|
||||
// TODO: finish manual mipmap generation,
|
||||
// https://github.com/processing/processing/issues/3335
|
||||
manualMipmap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,8 +423,7 @@ public class Texture implements PConstants {
|
||||
if (PGraphicsOpenGL.autoMipmapGenSupported) {
|
||||
pgl.generateMipmap(glTarget);
|
||||
} else {
|
||||
// TODO: finish manual mipmap generation,
|
||||
// https://github.com/processing/processing/issues/3335
|
||||
manualMipmap();
|
||||
}
|
||||
}
|
||||
pgl.bindTexture(glTarget, 0);
|
||||
@@ -518,8 +516,9 @@ public class Texture implements PConstants {
|
||||
|
||||
|
||||
public void usingMipmaps(boolean mipmaps, int sampling) {
|
||||
int glMagFilter0 = glMagFilter;
|
||||
int glMinFilter0 = glMinFilter;
|
||||
if (mipmaps) {
|
||||
usingMipmaps = true;
|
||||
if (sampling == POINT) {
|
||||
glMagFilter = PGL.NEAREST;
|
||||
glMinFilter = PGL.NEAREST;
|
||||
@@ -528,14 +527,17 @@ public class Texture implements PConstants {
|
||||
glMagFilter = PGL.NEAREST;
|
||||
glMinFilter =
|
||||
PGL.MIPMAPS_ENABLED ? PGL.LINEAR_MIPMAP_NEAREST : PGL.LINEAR;
|
||||
usingMipmaps = true;
|
||||
} else if (sampling == BILINEAR) {
|
||||
glMagFilter = PGL.LINEAR;
|
||||
glMinFilter =
|
||||
PGL.MIPMAPS_ENABLED ? PGL.LINEAR_MIPMAP_NEAREST : PGL.LINEAR;
|
||||
usingMipmaps = true;
|
||||
} else if (sampling == TRILINEAR) {
|
||||
glMagFilter = PGL.LINEAR;
|
||||
glMinFilter =
|
||||
PGL.MIPMAPS_ENABLED ? PGL.LINEAR_MIPMAP_LINEAR : PGL.LINEAR;
|
||||
usingMipmaps = true;
|
||||
} else {
|
||||
throw new RuntimeException("Unknown texture filtering mode");
|
||||
}
|
||||
@@ -555,17 +557,19 @@ public class Texture implements PConstants {
|
||||
}
|
||||
}
|
||||
|
||||
bind();
|
||||
pgl.texParameteri(glTarget, PGL.TEXTURE_MIN_FILTER, glMinFilter);
|
||||
pgl.texParameteri(glTarget, PGL.TEXTURE_MAG_FILTER, glMagFilter);
|
||||
if (usingMipmaps) {
|
||||
if (PGraphicsOpenGL.autoMipmapGenSupported) {
|
||||
pgl.generateMipmap(glTarget);
|
||||
} else {
|
||||
// TODO: need manual generation here..
|
||||
if (glMagFilter0 != glMagFilter || glMinFilter0 != glMinFilter) {
|
||||
bind();
|
||||
pgl.texParameteri(glTarget, PGL.TEXTURE_MIN_FILTER, glMinFilter);
|
||||
pgl.texParameteri(glTarget, PGL.TEXTURE_MAG_FILTER, glMagFilter);
|
||||
if (usingMipmaps) {
|
||||
if (PGraphicsOpenGL.autoMipmapGenSupported) {
|
||||
pgl.generateMipmap(glTarget);
|
||||
} else {
|
||||
manualMipmap();
|
||||
}
|
||||
}
|
||||
unbind();
|
||||
}
|
||||
unbind();
|
||||
}
|
||||
|
||||
|
||||
@@ -652,6 +656,23 @@ public class Texture implements PConstants {
|
||||
}
|
||||
|
||||
|
||||
public int currentSampling() {
|
||||
if (glMagFilter == PGL.NEAREST && glMinFilter == PGL.NEAREST) {
|
||||
return POINT;
|
||||
} else if (glMagFilter == PGL.NEAREST &&
|
||||
glMinFilter == (PGL.MIPMAPS_ENABLED ? PGL.LINEAR_MIPMAP_NEAREST : PGL.LINEAR)) {
|
||||
return LINEAR;
|
||||
} else if (glMagFilter == PGL.LINEAR &&
|
||||
glMinFilter == (PGL.MIPMAPS_ENABLED ? PGL.LINEAR_MIPMAP_NEAREST : PGL.LINEAR)) {
|
||||
return BILINEAR;
|
||||
} else if (glMagFilter == PGL.LINEAR &&
|
||||
glMinFilter == PGL.LINEAR_MIPMAP_LINEAR) {
|
||||
return TRILINEAR;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
// Bind/unbind
|
||||
@@ -780,6 +801,12 @@ public class Texture implements PConstants {
|
||||
}
|
||||
|
||||
|
||||
protected void manualMipmap() {
|
||||
// TODO: finish manual mipmap generation,
|
||||
// https://github.com/processing/processing/issues/3335
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
// Buffer sink interface.
|
||||
|
||||
Reference in New Issue
Block a user