<commit_before>package org.helioviewer.jhv.opengl;

import java.awt.EventQueue;

import org.helioviewer.jhv.base.astronomy.Sun;
import org.helioviewer.jhv.base.math.Mat4;
import org.helioviewer.jhv.base.scale.GridScale;
import org.helioviewer.jhv.camera.Camera;
import org.helioviewer.jhv.camera.CameraHelper;
import org.helioviewer.jhv.display.Displayer;
import org.helioviewer.jhv.display.Viewport;
import org.helioviewer.jhv.export.ExportMovie;
import org.helioviewer.jhv.gui.ImageViewerGui;
import org.helioviewer.jhv.layers.Layers;

import com.jogamp.nativewindow.ScalableSurface;
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLContext;
import com.jogamp.opengl.GLEventListener;

public class GLListener implements GLEventListener {

    private final ScalableSurface surface;

    public GLListener(ScalableSurface surface) {
        this.surface = surface;
    }

    @Override
    public void init(GLAutoDrawable drawable) {
        final GLContext ctx = drawable.getContext();
        final GL2 gl = ctx.getGL().getGL2();
        final boolean multi = drawable.getChosenGLCapabilities().getNumSamples() != 0;

        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                ctx.makeCurrent();
                initImpl(gl, multi);
                ctx.release();
            }
        });
    }

    @Override
    public void dispose(GLAutoDrawable drawable) {
        GLText.dispose();
        final GL2 gl = drawable.getGL().getGL2();

        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                disposeImpl(gl);
                GLInfo.checkGLErrors(gl, "GLListener.dispose()");
            }
        });
    }

    private void initImpl(GL2 gl, boolean multi) {
        GLInfo.update(gl);
        GLInfo.updatePixelScale(surface);

        gl.glDisable(GL2.GL_TEXTURE_1D);
        gl.glDisable(GL2.GL_TEXTURE_2D);

        if (multi)
            gl.glEnable(GL2.GL_MULTISAMPLE);
        else {
            gl.glEnable(GL2.GL_LINE_SMOOTH);
            gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_NICEST);
        }

        gl.glEnable(GL2.GL_BLEND);
        gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
        gl.glBlendEquation(GL2.GL_FUNC_ADD);

        gl.glEnable(GL2.GL_DEPTH_TEST);
        gl.glDepthFunc(GL2.GL_LEQUAL);

        gl.glEnable(GL2.GL_CULL_FACE);
        gl.glCullFace(GL2.GL_BACK);

        gl.glClearColor(0, 0, 0, 0);
        gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);

        GLSLSolarShader.init(gl);
        ImageViewerGui.getRenderableContainer().init(gl);
    }

    private void disposeImpl(GL2 gl) {
        ImageViewerGui.getRenderableContainer().dispose(gl);
        GLSLSolarShader.dispose(gl);
    }

    private ExportMovie exporter;

    public void attachExport(ExportMovie me) {
        exporter = me;
    }

    public void detachExport() {
        exporter = null;
    }

    public boolean isRecording() {
        return exporter != null;
    }

    @Override
    public void reshape(GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                Displayer.setGLSize(x, y, width, height);
                Displayer.reshapeAll();
                ImageViewerGui.getRenderableMiniview().reshapeViewport();
                Displayer.render(1);
            }
        });
    }

    private static void renderBlackCircle(GL2 gl, double[] matrix) {
        gl.glPushMatrix();
        gl.glMultMatrixd(matrix, 0);
        {
            gl.glColor3f(0, 0, 0);
            GLHelper.drawCircleFront(gl, 0, 0, 0.98 * Sun.Radius, 30);
        }
        gl.glPopMatrix();
    }
<commit_msg>Do not render on reshape<commit_after>package org.helioviewer.jhv.opengl;

import java.awt.EventQueue;

import org.helioviewer.jhv.base.astronomy.Sun;
import org.helioviewer.jhv.base.math.Mat4;
import org.helioviewer.jhv.base.scale.GridScale;
import org.helioviewer.jhv.camera.Camera;
import org.helioviewer.jhv.camera.CameraHelper;
import org.helioviewer.jhv.display.Displayer;
import org.helioviewer.jhv.display.Viewport;
import org.helioviewer.jhv.export.ExportMovie;
import org.helioviewer.jhv.gui.ImageViewerGui;
import org.helioviewer.jhv.layers.Layers;

import com.jogamp.nativewindow.ScalableSurface;
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLContext;
import com.jogamp.opengl.GLEventListener;

public class GLListener implements GLEventListener {

    private final ScalableSurface surface;

    public GLListener(ScalableSurface surface) {
        this.surface = surface;
    }

    @Override
    public void init(GLAutoDrawable drawable) {
        final GLContext ctx = drawable.getContext();
        final GL2 gl = ctx.getGL().getGL2();
        final boolean multi = drawable.getChosenGLCapabilities().getNumSamples() != 0;

        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                ctx.makeCurrent();
                initImpl(gl, multi);
                ctx.release();
            }
        });
    }

    @Override
    public void dispose(GLAutoDrawable drawable) {
        GLText.dispose();
        final GL2 gl = drawable.getGL().getGL2();

        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                disposeImpl(gl);
                GLInfo.checkGLErrors(gl, "GLListener.dispose()");
            }
        });
    }

    private void initImpl(GL2 gl, boolean multi) {
        GLInfo.update(gl);
        GLInfo.updatePixelScale(surface);

        gl.glDisable(GL2.GL_TEXTURE_1D);
        gl.glDisable(GL2.GL_TEXTURE_2D);

        if (multi)
            gl.glEnable(GL2.GL_MULTISAMPLE);
        else {
            gl.glEnable(GL2.GL_LINE_SMOOTH);
            gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_NICEST);
        }

        gl.glEnable(GL2.GL_BLEND);
        gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
        gl.glBlendEquation(GL2.GL_FUNC_ADD);

        gl.glEnable(GL2.GL_DEPTH_TEST);
        gl.glDepthFunc(GL2.GL_LEQUAL);

        gl.glEnable(GL2.GL_CULL_FACE);
        gl.glCullFace(GL2.GL_BACK);

        gl.glClearColor(0, 0, 0, 0);
        gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);

        GLSLSolarShader.init(gl);
        ImageViewerGui.getRenderableContainer().init(gl);
    }

    private void disposeImpl(GL2 gl) {
        ImageViewerGui.getRenderableContainer().dispose(gl);
        GLSLSolarShader.dispose(gl);
    }

    private ExportMovie exporter;

    public void attachExport(ExportMovie me) {
        exporter = me;
    }

    public void detachExport() {
        exporter = null;
    }

    public boolean isRecording() {
        return exporter != null;
    }

    @Override
    public void reshape(GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                Displayer.setGLSize(x, y, width, height);
                Displayer.reshapeAll();
                ImageViewerGui.getRenderableMiniview().reshapeViewport();
            }
        });
    }

    private static void renderBlackCircle(GL2 gl, double[] matrix) {
        gl.glPushMatrix();
        gl.glMultMatrixd(matrix, 0);
        {
            gl.glColor3f(0, 0, 0);
            GLHelper.drawCircleFront(gl, 0, 0, 0.98 * Sun.Radius, 30);
        }
        gl.glPopMatrix();
    }

{'fraction_non_alphanumeric': 0.10630023334197562, 'fraction_numerical': 0.0115374643505315, 'mean_word_length': 2.409191338930623, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '823274', 'n_tokens_mistral': 2683, 'n_tokens_neox': 2538, 'n_words': 411}