Skip to content

Commit c079898

Browse files
committed
remove unhint(), add additional constants, rename
render/depth_sort-Lines/Triangles
1 parent d80dbe7 commit c079898

7 files changed

Lines changed: 59 additions & 40 deletions

File tree

core/api.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ resize() -> setSize() (roughly)
44
endShape() with no params is no longer 'final'
55
X/Y/Z -> TX/TY/TZ
66
MX/MY/MZ -> X/Y/Z (for sake of PShape)
7+
render_triangles -> renderTriangles()
8+
depth_sort_triangles -> sortTriangles()
9+
render_lines -> renderLines()
10+
depth_sort_lines -> sortLines()
711

812
//
913

@@ -16,15 +20,13 @@ MX/MY/MZ -> X/Y/Z (for sake of PShape)
1620
canDraw()
1721
beginDraw()
1822
endDraw()
19-
20-
flush() - flushDraw()?
23+
flush()
2124

2225
checkSettings()
2326
defaultSettings()
2427
reapplySettings()
2528

2629
hint()
27-
unhint()
2830

2931
public void beginShape()
3032
public void beginShape(int kind)

core/src/processing/core/PConstants.java

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -327,16 +327,26 @@ public interface PConstants {
327327
static final int WAIT = Cursor.WAIT_CURSOR;
328328

329329

330-
// hints
331-
332-
static final int ENABLE_OPENGL_2X_SMOOTH = 0;
333-
static final int ENABLE_OPENGL_4X_SMOOTH = 1;
334-
static final int ENABLE_NATIVE_FONTS = 2;
335-
static final int DISABLE_DEPTH_TEST = 5;
336-
static final int DISABLE_FLYING_POO = 6;
337-
static final int ENABLE_DEPTH_SORT = 7;
338-
static final int DISABLE_ERROR_REPORT = 8;
339-
static final int ENABLE_ACCURATE_TEXTURES = 9;
340-
341-
static final int HINT_COUNT = 10;
330+
// hints - hint values are positive for the alternate version,
331+
// negative of the same value returns to the normal/default state
332+
333+
static final int ENABLE_OPENGL_2X_SMOOTH = 1;
334+
static final int ENABLE_OPENGL_4X_SMOOTH = 2;
335+
336+
static final int ENABLE_NATIVE_FONTS = 3;
337+
static final int DISABLE_NATIVE_FONTS = -3;
338+
339+
static final int DISABLE_DEPTH_TEST = 4;
340+
static final int ENABLE_DEPTH_TEST = -4;
341+
342+
static final int ENABLE_DEPTH_SORT = 5;
343+
static final int DISABLE_DEPTH_SORT = -5;
344+
345+
static final int DISABLE_OPENGL_ERROR_REPORT = 6;
346+
static final int ENABLE_OPENGL_ERROR_REPORT = -6;
347+
348+
static final int ENABLE_ACCURATE_TEXTURES = 7;
349+
static final int DISABLE_ACCURATE_TEXTURES = -7;
350+
351+
static final int HINT_COUNT = 10;
342352
}

core/src/processing/core/PGraphics.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,11 @@ public boolean canDraw() { // ignore
662662
abstract public void endDraw(); // ignore
663663

664664

665+
protected void flush() {
666+
// no-op, mostly for P3D to write sorted stuff
667+
}
668+
669+
665670
protected void checkSettings() {
666671
if (!settingsInited) defaultSettings();
667672
}
@@ -782,11 +787,6 @@ protected void reapplySettings() {
782787
}
783788

784789

785-
protected void flush() {
786-
// no-op, mostly for P3D to write sorted stuff
787-
}
788-
789-
790790

791791
//////////////////////////////////////////////////////////////
792792

@@ -811,15 +811,11 @@ protected void flush() {
811811
* </UL>
812812
*/
813813
public void hint(int which) {
814-
hints[which] = true;
815-
}
816-
817-
818-
/**
819-
* Disable a hint() setting.
820-
*/
821-
public void unhint(int which) {
822-
hints[which] = false;
814+
if (which > 0) {
815+
hints[which] = true;
816+
} else {
817+
hints[-which] = false;
818+
}
823819
}
824820

825821

core/src/processing/core/PGraphics3D.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
/**
33-
* Subclass of PGraphics that handles 3D rendering for Java 1.1.
33+
* Subclass of PGraphics that handles 3D rendering.
3434
* It can render 3D inside a browser window and requires no plug-ins.
3535
* <p/>
3636
* The renderer is mostly set up based on the structure of the OpenGL API,
@@ -368,15 +368,15 @@ public void endDraw() {
368368
protected void flush() {
369369
if (triangleCount > 0) {
370370
if (hints[ENABLE_DEPTH_SORT]) {
371-
depth_sort_triangles();
371+
sortTriangles();
372372
}
373-
render_triangles();
373+
renderTriangles();
374374
}
375375
if (lineCount > 0) {
376376
if (hints[ENABLE_DEPTH_SORT]) {
377-
depth_sort_lines();
377+
sortLines();
378378
}
379-
render_lines();
379+
renderLines();
380380
}
381381
// Clear this out in case flush() is called again.
382382
// For instance, with hint(ENABLE_DEPTH_SORT), it will be called
@@ -971,8 +971,8 @@ public void endShape(int mode) {
971971

972972
// if true, the shapes will be rendered on endDraw
973973
if (!hints[ENABLE_DEPTH_SORT]) {
974-
if (fill) render_triangles();
975-
if (stroke) render_lines();
974+
if (fill) renderTriangles();
975+
if (stroke) renderLines();
976976
}
977977

978978
shape = 0;
@@ -1247,7 +1247,7 @@ protected final void add_triangle_no_clip(int a, int b, int c) {
12471247
}
12481248

12491249

1250-
protected void depth_sort_triangles() {
1250+
protected void sortTriangles() {
12511251
//System.out.println("sorting " + triangleCount + " triangles");
12521252
depth_sort_triangles_internal(0, triangleCount-1);
12531253
}
@@ -1305,7 +1305,7 @@ protected float depth_sort_triangles_compare(int a, int b) {
13051305
}
13061306

13071307

1308-
protected void render_triangles() {
1308+
protected void renderTriangles() {
13091309
if (raw != null) {
13101310
raw.colorMode(RGB, 1);
13111311
raw.noStroke();
@@ -1422,11 +1422,11 @@ protected void render_triangles() {
14221422
}
14231423

14241424

1425-
protected void depth_sort_lines() {
1425+
protected void sortLines() {
14261426
}
14271427

14281428

1429-
protected void render_lines() {
1429+
protected void renderLines() {
14301430
if (raw != null) {
14311431
raw.colorMode(RGB, 1);
14321432
raw.noFill();

core/src/processing/core/PLine.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ public void draw() {
233233
m_drawFlags &= ~R_SMOOTH;
234234
}
235235

236+
/*
236237
// line hack
237238
if (parent.hints[DISABLE_FLYING_POO]) {
238239
float nwidth2 = -SCREEN_WIDTH;
@@ -250,6 +251,7 @@ public void draw() {
250251
return; // this is a bad line
251252
}
252253
}
254+
*/
253255

254256
///////////////////////////////////////
255257
// line clipping

core/src/processing/core/PPolygon.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ public void render() {
221221
r[i] = 0; dr[i] = 0; l[i] = 0; dl[i] = 0;
222222
}
223223

224+
/*
224225
// hack to not make polygons fly into the screen
225226
if (parent.hints[DISABLE_FLYING_POO]) {
226227
float nwidth2 = -width * 2;
@@ -236,6 +237,7 @@ public void render() {
236237
}
237238
}
238239
}
240+
*/
239241

240242
if (smooth) {
241243
for (int i = 0; i < vertexCount; i++) {

core/todo.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ X delay() is broken
1717
X http://dev.processing.org/bugs/show_bug.cgi?id=894
1818
X remove extra ~ files from core.jar
1919
X also fix for other libraries in the make scripts across platforms
20+
X fix problems in PApplet regarding signed code
21+
X createInput() wasn't bothering to check files when not online
22+
X unhint() has been removed, see the reference for hint() for changes
2023

24+
_ decisions on image smoothing vs. text smoothing vs. all
25+
26+
_ make decisions about whether PGraphics is an abstract class or not
27+
_ method signature is a real problem
2128
_ clean up setMainDrawingSurface()
2229
_ should instead be inside size(), and init(), no?
2330

0 commit comments

Comments
 (0)