package org.helioviewer.gl3d.model.image;

import javax.media.opengl.GL;

import org.helioviewer.base.physics.Constants;
import org.helioviewer.gl3d.shader.GL3DImageFragmentShaderProgram;
import org.helioviewer.gl3d.shader.GL3DImageVertexShaderProgram;
import org.helioviewer.gl3d.shader.GL3DShaderFactory;
import org.helioviewer.gl3d.view.GL3DView;
import org.helioviewer.viewmodel.metadata.HelioviewerMetaData;
import org.helioviewer.viewmodel.view.opengl.shader.GLFragmentShaderProgram;
import org.helioviewer.viewmodel.view.opengl.shader.GLVertexShaderProgram;

public class GL3DStereoImageLayer extends GL3DImageLayer {
    private GL3DImageSphere sphere = null;

    public GL3DStereoImageLayer(GL3DView mainView) {
        super("Stereo Image Layer", mainView);
    }

    @Override
    protected void createImageMeshNodes(GL gl) {
        this.gl = gl;
        HelioviewerMetaData hvMetaData = (HelioviewerMetaData) metaDataView.getMetaData();

        GL3DImageVertexShaderProgram vertex = new GL3DImageVertexShaderProgram();
        GLVertexShaderProgram vertexShader = GL3DShaderFactory.createVertexShaderProgram(gl, vertex);
        this.imageTextureView.setVertexShader(vertex);

        GLFragmentShaderProgram coronaFragmentShader = GL3DShaderFactory.createFragmentShaderProgram(gl, this.coronaFragmentShader);

        this.imageTextureView.metadata = this.metaDataView.getMetaData();

        // Don't display sphere for corona images
        if (!hvMetaData.getDetector().startsWith("COR")) {
            this.sphereFragmentShader = new GL3DImageFragmentShaderProgram();
            GLFragmentShaderProgram sphereFragmentShader = GL3DShaderFactory.createFragmentShaderProgram(gl, this.sphereFragmentShader);
            sphere = new GL3DImageSphere(imageTextureView, vertexShader, sphereFragmentShader, this);
            this.addNode(sphere);
            this.sphereFragmentShader.setCutOffRadius(Constants.SunRadius / this.imageTextureView.metadata.getPhysicalImageWidth());
        }

    }

    @Override
    protected GL3DImageMesh getImageSphere() {
        return this.sphere;
    }

}

@@ -71,122 +71,8 @@
 L;%0A%0A
-import org.helioviewer.base.physics.Constants;%0Aimport org.helioviewer.gl3d.shader.GL3DImageFragmentShaderProgram;%0A
 impo
@@ -233,148 +233,8 @@
 ew;%0A
-import org.helioviewer.viewmodel.metadata.HelioviewerMetaData;%0Aimport org.helioviewer.viewmodel.view.opengl.shader.GLFragmentShaderProgram;%0A
 impo
@@ -595,109 +595,69 @@
 his.
-gl = gl;%0A        HelioviewerMetaData hvMetaData = (HelioviewerMetaData) metaDataView.getMetaData
+sphereFragmentShader = imageTextureView.getFragmentShader
 ();%0A
-%0A
     
@@ -695,16 +695,29 @@
 m vertex
+ShaderProgram
  = new G
@@ -846,16 +846,29 @@
 , vertex
+ShaderProgram
 );%0A     
@@ -918,146 +918,24 @@
 rtex
-);%0A%0A        GLFragmentShaderProgram coronaFragmentShader = GL3DShaderFactory.createFragmentShaderProgram(gl, this.coronaFragmentShader
+ShaderProgram
 );%0A
-%0A
     
@@ -1008,337 +1008,8 @@
 ();%0A
-%0A        // Don't display sphere for corona images%0A        if (!hvMetaData.getDetector().startsWith(%22COR%22)) %7B%0A            this.sphereFragmentShader = new GL3DImageFragmentShaderProgram();%0A            GLFragmentShaderProgram sphereFragmentShader = GL3DShaderFactory.createFragmentShaderProgram(gl, this.sphereFragmentShader);%0A    
     
@@ -1106,28 +1106,24 @@
 s);%0A        
-    
 this.addNode
@@ -1136,152 +1136,8 @@
 e);%0A
-            this.sphereFragmentShader.setCutOffRadius(Constants.SunRadius / this.imageTextureView.metadata.getPhysicalImageWidth());%0A        %7D%0A%0A
     

Change to match AIA