~helioviewer/jhelioviewer/trunk

« back to all changes in this revision

Viewing changes to src/viewmodel/src/org/helioviewer/viewmodel/view/opengl/GLTextureHelper.java

  • Committer: Daniel Mueller
  • Date: 2014-03-18 09:37:47 UTC
  • mfrom: (499.1.9 stereo-masks)
  • Revision ID: daniel.mueller@esa.int-20140318093747-b3uggn7qj1xe6wz1
Merged Andre's stereo-masks branch into trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
import java.util.HashMap;
15
15
 
16
16
import javax.media.opengl.GL;
 
17
import javax.media.opengl.GL2;
17
18
import javax.media.opengl.glu.GLU;
18
19
 
19
20
import org.helioviewer.base.logging.Log;
52
53
 
53
54
    private static HashMap<Integer, Vector2dDouble> allTextures = new HashMap<Integer, Vector2dDouble>();
54
55
 
55
 
    private final static int[] formatMap = { GL.GL_LUMINANCE4, GL.GL_LUMINANCE4, GL.GL_LUMINANCE4, GL.GL_LUMINANCE4, GL.GL_LUMINANCE8, GL.GL_LUMINANCE8, GL.GL_LUMINANCE8, GL.GL_LUMINANCE8, GL.GL_LUMINANCE12, GL.GL_LUMINANCE12, GL.GL_LUMINANCE12, GL.GL_LUMINANCE12, GL.GL_LUMINANCE16, GL.GL_LUMINANCE16, GL.GL_LUMINANCE16, GL.GL_LUMINANCE16 };
 
56
    private final static int[] formatMap = { GL2.GL_LUMINANCE4, GL2.GL_LUMINANCE4, GL2.GL_LUMINANCE4, GL2.GL_LUMINANCE4, GL2.GL_LUMINANCE8, GL2.GL_LUMINANCE8, GL2.GL_LUMINANCE8, GL2.GL_LUMINANCE8, GL2.GL_LUMINANCE12, GL2.GL_LUMINANCE12, GL2.GL_LUMINANCE12, GL2.GL_LUMINANCE12, GL2.GL_LUMINANCE16, GL2.GL_LUMINANCE16, GL2.GL_LUMINANCE16, GL2.GL_LUMINANCE16 };
56
57
 
57
58
    /**
58
59
     * Sets whether non power of two textures should be used.
102
103
     * @param gl
103
104
     *            Valid reference to the current gl object
104
105
     */
105
 
    public static void initHelper(GL gl) {
 
106
    public static void initHelper(GL2 gl) {
106
107
        Log.debug(">> GLTextureHelper.initHelper(GL) > Initialize helper functions");
107
108
 
108
109
        if (textureImplementation == null) {
115
116
        }
116
117
 
117
118
        int tmp[] = new int[1];
118
 
        gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, tmp, 0);
 
119
        gl.glGetIntegerv(GL2.GL_MAX_TEXTURE_SIZE, tmp, 0);
119
120
        maxTextureSize = tmp[0];
120
121
        Log.debug(">> GLTextureHelper.initHelper(GL) > max texture size: " + maxTextureSize);
121
122
 
156
157
     *            texture id to bind
157
158
     * @see #bindTexture(GL, int, int)
158
159
     */
159
 
    public synchronized void bindTexture(GL gl, int texture) {
 
160
    public synchronized void bindTexture(GL2 gl, int texture) {
160
161
        textureImplementation.bindTexture(gl, texture);
161
162
    }
162
163
 
177
178
     *            texture id to bind
178
179
     * @see #bindTexture(GL, int, int)
179
180
     */
180
 
    public synchronized void bindTexture(GL gl, int target, int texture) {
 
181
    public synchronized void bindTexture(GL2 gl, int target, int texture) {
181
182
        textureImplementation.bindTexture(gl, target, texture);
182
183
    }
183
184
 
251
252
     *            Valid reference to the current gl object
252
253
     * @return texture the frame buffer was copied to
253
254
     */
254
 
    public int copyFrameBufferToTexture(GL gl) {
 
255
    public int copyFrameBufferToTexture(GL2 gl) {
255
256
        int texture = genTextureID(gl);
256
257
        return copyFrameBufferToTexture(gl, texture);
257
258
    }
268
269
     *            target texture
269
270
     * @return texture the frame buffer was copied to
270
271
     */
271
 
    public int copyFrameBufferToTexture(GL gl, int texture) {
 
272
    public int copyFrameBufferToTexture(GL2 gl, int texture) {
272
273
        int viewport[] = new int[4];
273
 
        gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
 
274
        gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport, 0);
274
275
        return copyFrameBufferToTexture(gl, texture, new Rectangle(viewport[0], viewport[1], viewport[2], viewport[3]));
275
276
    }
276
277
 
287
288
     *            area of the frame buffer to copy
288
289
     * @return texture the frame buffer was copied to
289
290
     */
290
 
    public int copyFrameBufferToTexture(GL gl, Rectangle rect) {
 
291
    public int copyFrameBufferToTexture(GL2 gl, Rectangle rect) {
291
292
        int texture = genTextureID(gl);
292
293
        return copyFrameBufferToTexture(gl, texture, rect);
293
294
    }
307
308
     *            area of the frame buffer to copy
308
309
     * @return texture the frame buffer was copied to
309
310
     */
310
 
    public int copyFrameBufferToTexture(GL gl, int texture, Rectangle rect) {
311
 
 
312
 
        gl.glActiveTexture(GL.GL_TEXTURE0);
313
 
 
314
 
        textureImplementation.genTexture2D(gl, texture, GL.GL_RGBA, rect.width, rect.height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, null);
 
311
    public int copyFrameBufferToTexture(GL2 gl, int texture, Rectangle rect) {
 
312
 
 
313
        gl.glActiveTexture(GL2.GL_TEXTURE0);
 
314
 
 
315
        textureImplementation.genTexture2D(gl, texture, GL2.GL_RGBA, rect.width, rect.height, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, null);
315
316
        textureImplementation.copyFrameBufferToTexture(gl, texture, rect);
316
317
 
317
318
        return texture;
333
334
     * @param region
334
335
     *            Position and size to draw the texture
335
336
     */
336
 
    public void renderTextureToScreen(GL gl, Region region) {
 
337
    public void renderTextureToScreen(GL2 gl, Region region) {
337
338
 
338
339
        Vector2dDouble lowerleftCorner = region.getLowerLeftCorner();
339
340
        Vector2dDouble size = region.getSize();
340
341
 
 
342
        if (size.getX() <= 0 || size.getY() <= 0) {
 
343
            return;
 
344
        }
 
345
 
341
346
        float x0 = (float) lowerleftCorner.getX();
342
347
        float y0 = (float) lowerleftCorner.getY();
343
348
        float x1 = x0 + (float) size.getX();
360
365
     * @param x0
361
366
     *            , y0 , x1 , y1 - Position and size to draw the texture
362
367
     */
363
 
    public void renderTextureToScreen(GL gl, float x0, float y0, float x1, float y1) {
364
 
 
365
 
        gl.glBegin(GL.GL_QUADS);
 
368
    public void renderTextureToScreen(GL2 gl, float x0, float y0, float x1, float y1) {
 
369
        gl.glBegin(GL2.GL_QUADS);
366
370
 
367
371
        mainTexCoord.setValue(gl, 0.0f, 1.0f);
368
372
        gl.glVertex2f(x0, y0);
394
398
     * @param source
395
399
     *            Image data to draw to the screen
396
400
     */
397
 
    public void renderImageDataToScreen(GL gl, Region region, ImageData source) {
 
401
    public void renderImageDataToScreen(GL2 gl, Region region, ImageData source) {
398
402
 
399
 
        gl.glActiveTexture(GL.GL_TEXTURE0);
 
403
        gl.glActiveTexture(GL2.GL_TEXTURE0);
400
404
 
401
405
        if (source == null)
402
406
            return;
442
446
     * @param target
443
447
     *            Valid texture id
444
448
     */
445
 
    public void moveImageDataToGLTexture(GL gl, ImageData source, int target) {
 
449
    public void moveImageDataToGLTexture(GL2 gl, ImageData source, int target) {
446
450
        moveImageDataToGLTexture(gl, source, 0, 0, source.getWidth(), source.getHeight(), target);
447
451
    }
448
452
 
467
471
     * @param target
468
472
     *            Valid texture id
469
473
     */
470
 
    public void moveImageDataToGLTexture(GL gl, ImageData source, int x, int y, int width, int height, int target) {
 
474
    public void moveImageDataToGLTexture(GL2 gl, ImageData source, int x, int y, int width, int height, int target) {
471
475
 
472
476
        if (source == null)
473
477
            return;
489
493
            buffer = null;
490
494
        }
491
495
 
492
 
        gl.glPixelStorei(GL.GL_UNPACK_SKIP_PIXELS, x);
493
 
        gl.glPixelStorei(GL.GL_UNPACK_SKIP_ROWS, y);
494
 
        gl.glPixelStorei(GL.GL_UNPACK_ROW_LENGTH, source.getWidth());
495
 
        gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, bitsPerPixel >> 3);
 
496
        gl.glPixelStorei(GL2.GL_UNPACK_SKIP_PIXELS, x);
 
497
        gl.glPixelStorei(GL2.GL_UNPACK_SKIP_ROWS, y);
 
498
        gl.glPixelStorei(GL2.GL_UNPACK_ROW_LENGTH, source.getWidth());
 
499
        gl.glPixelStorei(GL2.GL_UNPACK_ALIGNMENT, bitsPerPixel >> 3);
496
500
 
497
501
        ImageFormat imageFormat = source.getImageFormat();
498
502
 
518
522
     *            Valid texture id
519
523
     * @see #moveImageDataToGLTexture(GL, ImageData, int)
520
524
     */
521
 
    public void moveBufferedImageToGLTexture(GL gl, BufferedImage source, int target) {
 
525
    public void moveBufferedImageToGLTexture(GL2 gl, BufferedImage source, int target) {
522
526
 
523
527
        if (source == null)
524
528
            return;
543
547
            buffer = null;
544
548
        }
545
549
 
546
 
        gl.glPixelStorei(GL.GL_UNPACK_SKIP_PIXELS, 0);
547
 
        gl.glPixelStorei(GL.GL_UNPACK_SKIP_ROWS, 0);
548
 
        gl.glPixelStorei(GL.GL_UNPACK_ROW_LENGTH, 0);
549
 
        gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, mapDataBufferTypeToGLAlign(rawBuffer.getDataType()));
 
550
        gl.glPixelStorei(GL2.GL_UNPACK_SKIP_PIXELS, 0);
 
551
        gl.glPixelStorei(GL2.GL_UNPACK_SKIP_ROWS, 0);
 
552
        gl.glPixelStorei(GL2.GL_UNPACK_ROW_LENGTH, 0);
 
553
        gl.glPixelStorei(GL2.GL_UNPACK_ALIGNMENT, mapDataBufferTypeToGLAlign(rawBuffer.getDataType()));
550
554
 
551
555
        if (source.getHeight() == 1) {
552
556
            textureImplementation.genTexture1D(gl, target, mapTypeToInternalGLFormat(source.getType()), source.getWidth(), mapTypeToInputGLFormat(source.getType()), mapDataBufferTypeToGLType(rawBuffer.getDataType()), buffer);
568
572
        if (imageFormat instanceof SingleChannelImageFormat)
569
573
            return formatMap[((SingleChannelImageFormat) imageFormat).getBitDepth() - 1];
570
574
        else if (imageFormat instanceof ARGB32ImageFormat || imageFormat instanceof RGB24ImageFormat)
571
 
            return GL.GL_RGBA;
 
575
            return GL2.GL_RGBA;
572
576
        else
573
577
            throw new IllegalArgumentException("Format is not supported");
574
578
    }
584
588
    private int mapImageFormatToInputGLFormat(ImageFormat imageFormat) {
585
589
 
586
590
        if (imageFormat instanceof SingleChannelImageFormat)
587
 
            return GL.GL_LUMINANCE;
 
591
            return GL2.GL_LUMINANCE;
588
592
        else if (imageFormat instanceof ARGB32ImageFormat || imageFormat instanceof RGB24ImageFormat)
589
 
            return GL.GL_BGRA;
 
593
            return GL2.GL_BGRA;
590
594
        else
591
595
            throw new IllegalArgumentException("Format is not supported");
592
596
    }
601
605
     */
602
606
    private int mapTypeToInternalGLFormat(int type) {
603
607
        if (type == BufferedImage.TYPE_BYTE_GRAY || type == BufferedImage.TYPE_BYTE_INDEXED)
604
 
            return GL.GL_LUMINANCE;
 
608
            return GL2.GL_LUMINANCE;
605
609
        else
606
 
            return GL.GL_RGBA;
 
610
            return GL2.GL_RGBA;
607
611
    }
608
612
 
609
613
    /**
616
620
     */
617
621
    private int mapTypeToInputGLFormat(int type) {
618
622
        if (type == BufferedImage.TYPE_BYTE_GRAY || type == BufferedImage.TYPE_BYTE_INDEXED)
619
 
            return GL.GL_LUMINANCE;
 
623
            return GL2.GL_LUMINANCE;
620
624
        else if (type == BufferedImage.TYPE_4BYTE_ABGR || type == BufferedImage.TYPE_INT_BGR)
621
 
            return GL.GL_BGRA;
 
625
            return GL2.GL_BGRA;
622
626
        else
623
 
            return GL.GL_RGBA;
 
627
            return GL2.GL_RGBA;
624
628
    }
625
629
 
626
630
    /**
634
638
    private int mapBitsPerPixelToGLType(int bitsPerPixel) {
635
639
        switch (bitsPerPixel) {
636
640
        case 8:
637
 
            return GL.GL_UNSIGNED_BYTE;
 
641
            return GL2.GL_UNSIGNED_BYTE;
638
642
        case 16:
639
 
            return GL.GL_UNSIGNED_SHORT;
 
643
            return GL2.GL_UNSIGNED_SHORT;
640
644
        case 32:
641
 
            return GL.GL_UNSIGNED_INT_8_8_8_8_REV;
 
645
            return GL2.GL_UNSIGNED_INT_8_8_8_8_REV;
642
646
        default:
643
647
            return 0;
644
648
        }
655
659
    private int mapDataBufferTypeToGLType(int dataBufferType) {
656
660
        switch (dataBufferType) {
657
661
        case DataBuffer.TYPE_BYTE:
658
 
            return GL.GL_UNSIGNED_BYTE;
 
662
            return GL2.GL_UNSIGNED_BYTE;
659
663
        case DataBuffer.TYPE_SHORT:
660
 
            return GL.GL_SHORT;
 
664
            return GL2.GL_SHORT;
661
665
        case DataBuffer.TYPE_USHORT:
662
 
            return GL.GL_UNSIGNED_SHORT;
 
666
            return GL2.GL_UNSIGNED_SHORT;
663
667
        case DataBuffer.TYPE_INT:
664
 
            return GL.GL_UNSIGNED_INT_8_8_8_8_REV;
 
668
            return GL2.GL_UNSIGNED_INT_8_8_8_8_REV;
665
669
        default:
666
670
            return 0;
667
671
        }
722
726
         * @param buffer
723
727
         *            Source data
724
728
         */
725
 
        public void genTexture1D(GL gl, int texID, int internalFormat, int width, int inputFormat, int inputType, Buffer buffer);
 
729
        public void genTexture1D(GL2 gl, int texID, int internalFormat, int width, int inputFormat, int inputType, Buffer buffer);
726
730
 
727
731
        /**
728
732
         * Copies image data to a two-dimensional texture to the graphics
745
749
         * @param buffer
746
750
         *            Source data
747
751
         */
748
 
        public void genTexture2D(GL gl, int texID, int internalFormat, int width, int height, int inputFormat, int inputType, Buffer buffer);
 
752
        public void genTexture2D(GL2 gl, int texID, int internalFormat, int width, int height, int inputFormat, int inputType, Buffer buffer);
749
753
 
750
754
        /**
751
755
         * Binds a 2D texture.
756
760
         *            texture id to bind
757
761
         * @see #bindTexture(GL, int, int)
758
762
         */
759
 
        public void bindTexture(GL gl, int texture);
 
763
        public void bindTexture(GL2 gl, int texture);
760
764
 
761
765
        /**
762
766
         * Binds a texture.
769
773
         *            texture id to bind
770
774
         * @see #bindTexture(GL, int, int)
771
775
         */
772
 
        public void bindTexture(GL gl, int target, int texture);
 
776
        public void bindTexture(GL2 gl, int target, int texture);
773
777
 
774
778
        /**
775
779
         * Copies the current frame buffer to a texture.
781
785
         * @param rect
782
786
         *            area of the frame buffer to copy
783
787
         */
784
 
        public void copyFrameBufferToTexture(GL gl, int texture, Rectangle rect);
 
788
        public void copyFrameBufferToTexture(GL2 gl, int texture, Rectangle rect);
785
789
    }
786
790
 
787
791
    /**
792
796
        /**
793
797
         * {@inheritDoc}
794
798
         */
795
 
        public void genTexture1D(GL gl, int texID, int internalFormat, int width, int inputFormat, int inputType, Buffer buffer) {
796
 
 
797
 
            gl.glBindTexture(GL.GL_TEXTURE_1D, texID);
798
 
 
799
 
            gl.glTexImage1D(GL.GL_TEXTURE_1D, 0, internalFormat, width, 0, inputFormat, inputType, buffer);
800
 
 
801
 
            gl.glTexParameteri(GL.GL_TEXTURE_1D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
802
 
            gl.glTexParameteri(GL.GL_TEXTURE_1D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
803
 
            gl.glTexParameteri(GL.GL_TEXTURE_1D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP);
804
 
        }
805
 
 
806
 
        /**
807
 
         * {@inheritDoc}
808
 
         */
809
 
        public void genTexture2D(GL gl, int texID, int internalFormat, int width, int height, int inputFormat, int inputType, Buffer buffer) {
810
 
 
811
 
            gl.glBindTexture(GL.GL_TEXTURE_2D, texID);
812
 
 
813
 
            gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, internalFormat, width, height, 0, inputFormat, inputType, buffer);
814
 
 
815
 
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
816
 
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
817
 
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP);
818
 
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP);
819
 
        }
820
 
 
821
 
        /**
822
 
         * {@inheritDoc}
823
 
         */
824
 
        public void bindTexture(GL gl, int texture) {
825
 
            gl.glBindTexture(GL.GL_TEXTURE_2D, texture);
826
 
        }
827
 
 
828
 
        /**
829
 
         * {@inheritDoc}
830
 
         */
831
 
        public void bindTexture(GL gl, int target, int texture) {
 
799
        public void genTexture1D(GL2 gl, int texID, int internalFormat, int width, int inputFormat, int inputType, Buffer buffer) {
 
800
 
 
801
            gl.glBindTexture(GL2.GL_TEXTURE_1D, texID);
 
802
 
 
803
            gl.glTexImage1D(GL2.GL_TEXTURE_1D, 0, internalFormat, width, 0, inputFormat, inputType, buffer);
 
804
 
 
805
            gl.glTexParameteri(GL2.GL_TEXTURE_1D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR);
 
806
            gl.glTexParameteri(GL2.GL_TEXTURE_1D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
 
807
            gl.glTexParameteri(GL2.GL_TEXTURE_1D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP);
 
808
        }
 
809
 
 
810
        /**
 
811
         * {@inheritDoc}
 
812
         */
 
813
        public void genTexture2D(GL2 gl, int texID, int internalFormat, int width, int height, int inputFormat, int inputType, Buffer buffer) {
 
814
 
 
815
            gl.glBindTexture(GL2.GL_TEXTURE_2D, texID);
 
816
 
 
817
            gl.glTexImage2D(GL2.GL_TEXTURE_2D, 0, internalFormat, width, height, 0, inputFormat, inputType, buffer);
 
818
 
 
819
            gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR);
 
820
            gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
 
821
            gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP);
 
822
            gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP);
 
823
        }
 
824
 
 
825
        /**
 
826
         * {@inheritDoc}
 
827
         */
 
828
        public void bindTexture(GL2 gl, int texture) {
 
829
            gl.glBindTexture(GL2.GL_TEXTURE_2D, texture);
 
830
        }
 
831
 
 
832
        /**
 
833
         * {@inheritDoc}
 
834
         */
 
835
        public void bindTexture(GL2 gl, int target, int texture) {
832
836
            gl.glBindTexture(target, texture);
833
837
        }
834
838
 
835
839
        /**
836
840
         * {@inheritDoc}
837
841
         */
838
 
        public void copyFrameBufferToTexture(GL gl, int texture, Rectangle rect) {
839
 
            gl.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, rect.x, rect.y, rect.width, rect.height, 0);
 
842
        public void copyFrameBufferToTexture(GL2 gl, int texture, Rectangle rect) {
 
843
            gl.glCopyTexImage2D(GL2.GL_TEXTURE_2D, 0, GL2.GL_RGBA, rect.x, rect.y, rect.width, rect.height, 0);
840
844
        }
 
845
 
841
846
    }
842
847
 
843
848
    /**
852
857
        /**
853
858
         * {@inheritDoc}
854
859
         */
855
 
        public void genTexture1D(GL gl, int texID, int internalFormat, int width, int inputFormat, int inputType, Buffer buffer) {
 
860
        public void genTexture1D(GL2 gl, int texID, int internalFormat, int width, int inputFormat, int inputType, Buffer buffer) {
856
861
 
857
 
            gl.glBindTexture(GL.GL_TEXTURE_1D, texID);
 
862
            gl.glBindTexture(GL2.GL_TEXTURE_1D, texID);
858
863
 
859
864
            int width2 = nextPowerOfTwo(width);
860
865
 
861
 
            gl.glTexImage1D(GL.GL_TEXTURE_1D, 0, internalFormat, width2, 0, inputFormat, inputType, null);
 
866
            gl.glTexImage1D(GL2.GL_TEXTURE_1D, 0, internalFormat, width2, 0, inputFormat, inputType, null);
862
867
 
863
868
            if (buffer != null) {
864
 
                gl.glTexSubImage1D(GL.GL_TEXTURE_1D, 0, 0, width, inputFormat, inputType, buffer);
 
869
                gl.glTexSubImage1D(GL2.GL_TEXTURE_1D, 0, 0, width, inputFormat, inputType, buffer);
865
870
            }
866
871
 
867
 
            gl.glTexParameteri(GL.GL_TEXTURE_1D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
868
 
            gl.glTexParameteri(GL.GL_TEXTURE_1D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
869
 
            gl.glTexParameteri(GL.GL_TEXTURE_1D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP);
 
872
            gl.glTexParameteri(GL2.GL_TEXTURE_1D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR);
 
873
            gl.glTexParameteri(GL2.GL_TEXTURE_1D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
 
874
            gl.glTexParameteri(GL2.GL_TEXTURE_1D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP);
870
875
 
871
876
            float scaleX = (float) width / width2;
872
877
 
877
882
        /**
878
883
         * {@inheritDoc}
879
884
         */
880
 
        public void genTexture2D(GL gl, int texID, int internalFormat, int width, int height, int inputFormat, int inputType, Buffer buffer) {
 
885
        public void genTexture2D(GL2 gl, int texID, int internalFormat, int width, int height, int inputFormat, int inputType, Buffer buffer) {
881
886
 
882
 
            gl.glBindTexture(GL.GL_TEXTURE_2D, texID);
 
887
            gl.glBindTexture(GL2.GL_TEXTURE_2D, texID);
883
888
 
884
889
            int width2 = nextPowerOfTwo(width);
885
890
            int height2 = nextPowerOfTwo(height);
886
891
 
887
 
            gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, internalFormat, width2, height2, 0, inputFormat, inputType, null);
 
892
            gl.glTexImage2D(GL2.GL_TEXTURE_2D, 0, internalFormat, width2, height2, 0, inputFormat, inputType, null);
888
893
 
889
894
            if (buffer != null) {
890
 
                gl.glTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0, width, height, inputFormat, inputType, buffer);
 
895
                gl.glTexSubImage2D(GL2.GL_TEXTURE_2D, 0, 0, 0, width, height, inputFormat, inputType, buffer);
891
896
            }
892
897
 
893
 
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
894
 
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
895
 
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP);
896
 
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP);
 
898
            gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR);
 
899
            gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
 
900
            gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP);
 
901
            gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP);
897
902
 
898
903
            float scaleX = (float) width / width2;
899
904
            float scaleY = (float) height / height2;
909
914
         * texture coordinate GL_TEXTURE1, which will be used by
910
915
         * {@link org.helioviewer.viewmodel.view.opengl.shader.GLScalePowerOfTwoVertexShaderProgram}
911
916
         */
912
 
        public void bindTexture(GL gl, int texture) {
913
 
            bindTexture(gl, GL.GL_TEXTURE_2D, texture);
 
917
        public void bindTexture(GL2 gl, int texture) {
 
918
            bindTexture(gl, GL2.GL_TEXTURE_2D, texture);
914
919
        }
915
920
 
916
921
        /**
920
925
         * texture coordinate GL_TEXTURE1, which will be used by
921
926
         * {@link org.helioviewer.viewmodel.view.opengl.shader.GLScalePowerOfTwoVertexShaderProgram}
922
927
         */
923
 
        public void bindTexture(GL gl, int target, int texture) {
 
928
        public void bindTexture(GL2 gl, int target, int texture) {
924
929
            gl.glBindTexture(target, texture);
925
930
 
926
931
            Vector2dDouble scaleVector = allTextures.get(texture);
932
937
        /**
933
938
         * {@inheritDoc}
934
939
         */
935
 
        public void copyFrameBufferToTexture(GL gl, int texture, Rectangle rect) {
936
 
            gl.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, rect.x, rect.y, nextPowerOfTwo(rect.width), nextPowerOfTwo(rect.height), 0);
 
940
        public void copyFrameBufferToTexture(GL2 gl, int texture, Rectangle rect) {
 
941
            gl.glCopyTexImage2D(GL2.GL_TEXTURE_2D, 0, GL2.GL_RGBA, rect.x, rect.y, nextPowerOfTwo(rect.width), nextPowerOfTwo(rect.height), 0);
937
942
        }
938
943
 
939
944
        /**
953
958
            }
954
959
            return output;
955
960
        }
 
961
 
956
962
    }
957
963
 
958
964
    /**
966
972
         * Default constructor
967
973
         */
968
974
        public GLMainTextureCoordinate() {
969
 
            super(GL.GL_TEXTURE0, 0, 2, "texcoord0.xy");
 
975
            super(GL2.GL_TEXTURE0, 0, 2, "texcoord0.xy");
970
976
        }
971
977
    }
972
978
 
979
985
         * Default constructor
980
986
         */
981
987
        protected GLScaleTextureCoordinate() {
982
 
            super(GL.GL_TEXTURE0, 2, 2, "texcoord0.zw");
 
988
            super(GL2.GL_TEXTURE0, 2, 2, "texcoord0.zw");
983
989
        }
984
990
    }
985
991
}