FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

catches attempts to draw outside animation thread, fixes #4196 · jekyllwrite/processing@44387f1 · GitHub

Repository navigation

Commit 44387f1

Browse files
committed
catches attempts to draw outside animation thread, fixes processing#4196
1 parent 7e0a1d6 commit 44387f1

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎core/src/processing/opengl/PGraphicsOpenGL.java‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,12 @@ public class PGraphicsOpenGL extends PGraphics {
509509
"to render this geometry properly, using default shader instead.";
510510
static final String TESSELLATION_ERROR =
511511
"Tessellation Error: %1$s";
512+
static final String GL_THREAD_NOT_CURRENT =
513+
"You are trying to draw outside OpenGL's animation thread.\n" +
514+
"Place all drawing commands in the draw() function, or inside\n" +
515+
"your own functions as long as they are called from draw(),\n" +
516+
"but not in event handling functions such as keyPressed()\n" +
517+
"or mousePressed().";
512518

513519
//////////////////////////////////////////////////////////////
514520

@@ -1455,6 +1461,11 @@ protected boolean pointBuffersContextIsOutdated() {
14551461

14561462
@Override
14571463
public void beginDraw() {
1464+
if (!pgl.threadIsCurrent()) {
1465+
PGraphics.showWarning(GL_THREAD_NOT_CURRENT);
1466+
return;
1467+
}
1468+
14581469
if (primaryGraphics) {
14591470
if (!initialized) {
14601471
initPrimary();

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL