mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Added check for maximum samples when calling smooth()
This commit is contained in:
@@ -34,6 +34,7 @@ import java.util.TimerTask;
|
||||
|
||||
import javax.media.opengl.GL;
|
||||
import javax.media.opengl.GL2;
|
||||
import javax.media.opengl.GL3;
|
||||
import javax.media.opengl.GLAutoDrawable;
|
||||
import javax.media.opengl.GLCapabilities;
|
||||
import javax.media.opengl.GLContext;
|
||||
@@ -152,6 +153,8 @@ public class PGL {
|
||||
|
||||
public static final int GL_ARRAY_BUFFER = GL.GL_ARRAY_BUFFER;
|
||||
public static final int GL_ELEMENT_ARRAY_BUFFER = GL.GL_ELEMENT_ARRAY_BUFFER;
|
||||
|
||||
public static final int GL_SAMPLES = GL.GL_SAMPLES;
|
||||
|
||||
public static final int GL_FRAMEBUFFER_COMPLETE = GL.GL_FRAMEBUFFER_COMPLETE;
|
||||
public static final int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
|
||||
@@ -180,10 +183,10 @@ public class PGL {
|
||||
public static final int GL_EXTENSIONS = GL.GL_EXTENSIONS;
|
||||
|
||||
public static final int GL_MAX_TEXTURE_SIZE = GL.GL_MAX_TEXTURE_SIZE;
|
||||
public static final int GL_MAX_SAMPLES = GL2.GL_MAX_SAMPLES;
|
||||
public static final int GL_ALIASED_LINE_WIDTH_RANGE = GL.GL_ALIASED_LINE_WIDTH_RANGE;
|
||||
public static final int GL_ALIASED_POINT_SIZE_RANGE = GL.GL_ALIASED_POINT_SIZE_RANGE;
|
||||
public static final int GL_SAMPLES = GL.GL_SAMPLES;
|
||||
|
||||
|
||||
public static final int GLU_TESS_WINDING_NONZERO = GLU.GLU_TESS_WINDING_NONZERO;
|
||||
public static final int GLU_TESS_WINDING_ODD = GLU.GLU_TESS_WINDING_ODD;
|
||||
|
||||
|
||||
@@ -96,9 +96,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
/** Some hardware limits */
|
||||
static public int maxTextureSize;
|
||||
static public int maxSamples;
|
||||
static public float maxPointSize;
|
||||
static public float maxLineWidth;
|
||||
|
||||
|
||||
/** OpenGL information strings */
|
||||
static public String OPENGL_VENDOR;
|
||||
static public String OPENGL_RENDERER;
|
||||
@@ -1428,12 +1429,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
flushMode = FLUSH_WHEN_FULL;
|
||||
}
|
||||
|
||||
int[] temp = { 0 };
|
||||
pgl.glGetIntegerv(PGL.GL_SAMPLES, temp, 0);
|
||||
if (antialias != temp[0]) {
|
||||
PGraphics.showWarning("Smooth level " + antialias + " not supported. Using " + temp[0] + " instead.");
|
||||
antialias = temp[0];
|
||||
}
|
||||
if (primarySurface) {
|
||||
int[] temp = { 0 };
|
||||
pgl.glGetIntegerv(PGL.GL_SAMPLES, temp, 0);
|
||||
if (antialias != temp[0]) {
|
||||
PGraphics.showWarning("Smooth level " + antialias + " not supported. Using " + temp[0] + " instead.");
|
||||
antialias = temp[0];
|
||||
}
|
||||
}
|
||||
if (antialias < 2) {
|
||||
pgl.glDisable(PGL.GL_MULTISAMPLE);
|
||||
pgl.glEnable(PGL.GL_POINT_SMOOTH);
|
||||
@@ -2933,6 +2936,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
public void smooth(int level) {
|
||||
smooth = true;
|
||||
|
||||
if (maxSamples < level) {
|
||||
PGraphics.showWarning("Smooth level not supported by the video card. Using " + maxSamples + " instead.");
|
||||
level = maxSamples;
|
||||
}
|
||||
|
||||
if (antialias != level) {
|
||||
antialias = level;
|
||||
if (antialias == 1) {
|
||||
@@ -5642,6 +5650,9 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
pgl.glGetIntegerv(PGL.GL_MAX_TEXTURE_SIZE, temp, 0);
|
||||
maxTextureSize = temp[0];
|
||||
|
||||
pgl.glGetIntegerv(PGL.GL_MAX_SAMPLES, temp, 0);
|
||||
maxSamples = temp[0];
|
||||
|
||||
pgl.glGetIntegerv(PGL.GL_ALIASED_LINE_WIDTH_RANGE, temp, 0);
|
||||
maxLineWidth = temp[1];
|
||||
@@ -9107,4 +9118,4 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user