Skip to content

Commit

Permalink
Fixed issue #1103.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsschmidt1337 committed Aug 25, 2024
1 parent 3af976c commit 51afcdf
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/org/nschmidt/ldparteditor/data/GL33ModelRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2277,6 +2277,10 @@ private void renderThread() {
idCount.set(0);
}

public void stop() {
isRunning.set(false);
}

public void dispose() {
isRunning.set(false);
GL30.glDeleteVertexArrays(vao);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,10 @@ private void renderThread() {
idCount.set(0);
}

public void stop() {
isRunning.set(false);
}

public void dispose() {
isRunning.set(false);
GL30.glDeleteVertexArrays(vao);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,9 @@ public void closeView() {
}
}

GLCanvas canvas = c3d.getCanvas();
OpenGLRenderer renderer = c3d.getRenderer();
renderer.stop();
GLCanvas canvas = c3d.getCanvas();
if (!canvas.isCurrent()) {
canvas.setCurrent();
GL.setCapabilities(c3d.getCapabilities());
Expand Down
1 change: 1 addition & 0 deletions src/org/nschmidt/ldparteditor/opengl/OpenGLRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public abstract class OpenGLRenderer {
protected final Composite3D c3d;

public abstract Composite3D getC3D();
public abstract void stop();
public abstract void dispose();
public abstract void init();
public abstract void drawScene();
Expand Down
5 changes: 5 additions & 0 deletions src/org/nschmidt/ldparteditor/opengl/OpenGLRenderer20.java
Original file line number Diff line number Diff line change
Expand Up @@ -2484,6 +2484,11 @@ private void drawGrid3D(float gridSize, final float gridSize10, final float grid
GL11.glEnd();
}

@Override
public void stop() {
// Do nothing.
}

@Override
public void dispose() {
GL20.glUseProgram(0);
Expand Down
7 changes: 7 additions & 0 deletions src/org/nschmidt/ldparteditor/opengl/OpenGLRenderer33.java
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,13 @@ private void drawGrid3D(float gridSize, final float gridSize10, final float grid
helper.drawLinesRGBgeneral(grid);
}

@Override
public void stop() {
// Stop the renderers.
modelRenderer.stop();
modelRendererLDrawStandard.stop();
}

@Override
public void dispose() {
// Properly de-allocate all resources once they've outlived their purpose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2344,6 +2344,9 @@ protected void handleShellCloseEvent() {

// NEVER DELETE THIS!
final int s = renders.size();
for (int i = 0; i < s; i++) {
renders.get(i).stop();
}
for (int i = 0; i < s; i++) {
try {
GLCanvas canvas = canvasList.get(i);
Expand Down

0 comments on commit 51afcdf

Please sign in to comment.