mirror of
https://github.com/processing/processing4.git
synced 2026-02-18 12:55:49 +01:00
Added new hint to enable/disable perspective corrected lines
This commit is contained in:
@@ -104,19 +104,17 @@ void main() {
|
||||
float thickness = attribs.w;
|
||||
vec2 window_offset = perp * thickness;
|
||||
|
||||
/*
|
||||
if (0 < perspective) {
|
||||
// Perspective correction (lines will look thiner as they move away
|
||||
// from the view position).
|
||||
gl_Position.xy = clip_p.xy + window_offset.xy;
|
||||
gl_Position.zw = clip_p.zw;
|
||||
} else {
|
||||
*/
|
||||
// No perspective correction.
|
||||
float clip_p_w = clip_p.w;
|
||||
vec4 offset_p = windowToClipVector(window_offset, viewport, clip_p_w);
|
||||
gl_Position = clip_p + offset_p;
|
||||
//}
|
||||
}
|
||||
|
||||
vec4 color = vec4(0, 0, 0, 0);
|
||||
vec4 globalAmbient = gl_Color * gl_LightModel.ambient;
|
||||
|
||||
@@ -1413,7 +1413,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
}
|
||||
|
||||
if (hints[ENABLE_ACCURATE_2D]) {
|
||||
flushMode = FLUSH_CONTINUOUSLY;
|
||||
flushMode = FLUSH_CONTINUOUSLY;
|
||||
} else {
|
||||
flushMode = FLUSH_WHEN_FULL;
|
||||
}
|
||||
@@ -1737,8 +1737,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
// HINTS
|
||||
|
||||
public void hint(int which) {
|
||||
super.hint(which);
|
||||
boolean oldValue = hints[which];
|
||||
super.hint(which);
|
||||
boolean newValue = hints[which];
|
||||
|
||||
if (oldValue == newValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (which == DISABLE_DEPTH_TEST) {
|
||||
flush();
|
||||
pgl.disableDepthTest();
|
||||
@@ -1768,6 +1774,17 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
} else if (which == DISABLE_TEXTURE_CACHE) {
|
||||
flush();
|
||||
|
||||
} else if (which == DISABLE_PERSPECTIVE_CORRECTED_LINES) {
|
||||
if (0 < tessGeo.lineVertexCount && 0 < tessGeo.lineIndexCount) {
|
||||
flush();
|
||||
}
|
||||
|
||||
} else if (which == ENABLE_PERSPECTIVE_CORRECTED_LINES &&
|
||||
0 < tessGeo.lineVertexCount && 0 < tessGeo.lineIndexCount) {
|
||||
if (0 < tessGeo.lineVertexCount && 0 < tessGeo.lineIndexCount) {
|
||||
flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2442,6 +2459,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
protected void setupLineShader(int attrBufID, float[] attribs, int nvert) {
|
||||
lineShader.setVecUniform("viewport", viewport[0], viewport[1], viewport[2], viewport[3]);
|
||||
|
||||
if (hints[ENABLE_PERSPECTIVE_CORRECTED_LINES]) {
|
||||
lineShader.setIntUniform("perspective", 1);
|
||||
} else {
|
||||
lineShader.setIntUniform("perspective", 0);
|
||||
}
|
||||
|
||||
lineShader.setIntUniform("lights", lightCount);
|
||||
|
||||
lineShader.setVecUniform("eye", cameraEyeX, cameraEyeY, cameraEyeZ, 0);
|
||||
@@ -2457,6 +2480,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
protected void setupLineShader(int attrBufID) {
|
||||
lineShader.setVecUniform("viewport", viewport[0], viewport[1], viewport[2], viewport[3]);
|
||||
|
||||
if (hints[ENABLE_PERSPECTIVE_CORRECTED_LINES]) {
|
||||
lineShader.setIntUniform("perspective", 1);
|
||||
} else {
|
||||
lineShader.setIntUniform("perspective", 0);
|
||||
}
|
||||
|
||||
lineShader.setIntUniform("lights", lightCount);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user