Examples of GL2


Examples of javax.media.opengl.GL2

            boolean useBilinearFilter)  {

        if (VERBOSE) System.err.println("JoglPipeline.textureFillRaster()");

        GLContext context = context(ctx);
    GL2 gl = context.getGL().getGL2();

        // Temporarily disable fragment and most 3D operations
        gl.glPushAttrib(GL2.GL_ENABLE_BIT | GL2.GL_TEXTURE_BIT | GL2.GL_POLYGON_BIT |
                GL2.GL_CURRENT_BIT );

        disableAttribForRaster(gl);

        /* Setup filter mode if needed */
        if(useBilinearFilter) {
            // System.err.println("JoglPipeline - Raster  : use bilinear filter\n");
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
        }

        gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
        gl.glColor4f(1.0f, 1.0f, 1.0f, alpha);

        // reset the polygon mode
        gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2.GL_FILL);

        gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);

        // load identity modelview and projection matrix
        gl.glMatrixMode(GL2.GL_MODELVIEW);
        gl.glPushMatrix();
        gl.glLoadIdentity();
        gl.glMatrixMode(GL2.GL_PROJECTION);
        gl.glPushMatrix();
        gl.glLoadIdentity();
        gl.glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0);

        gl.glBegin(GL2.GL_QUADS);
        gl.glTexCoord2f(texMinU, texMinV); gl.glVertex3f(mapMinX,mapMinY, mapZ);
        gl.glTexCoord2f(texMaxU, texMinV); gl.glVertex3f(mapMaxX,mapMinY, mapZ);
        gl.glTexCoord2f(texMaxU, texMaxV); gl.glVertex3f(mapMaxX,mapMaxY, mapZ);
        gl.glTexCoord2f(texMinU, texMaxV); gl.glVertex3f(mapMinX,mapMaxY, mapZ);
        gl.glEnd();

        // Restore matrices
        gl.glPopMatrix();
        gl.glMatrixMode(GL2.GL_MODELVIEW);
        gl.glPopMatrix();
        // Restore attributes
        gl.glPopAttrib();

    }
View Full Code Here

Examples of javax.media.opengl.GL2

        GLContext glContext = glDrawable.createContext(null);
            glContext.makeCurrent();

            JoglContext ctx = new JoglContext(glContext);

            GL2 gl = glContext.getGL().getGL2();

            // get current context properties
            getPropertiesFromCurrentContext(ctx, gl);
            // Set up fields in Canvas3D
            setupCanvasProperties(cv, ctx, gl);
View Full Code Here

Examples of javax.media.opengl.GL2

      GLDrawable         glDrawable  = ((JoglDrawable)cv.drawable).getGLDrawable();
        GLCapabilitiesImmutable chosenCaps  = glDrawable.getChosenGLCapabilities();
        GLFBODrawable       fboDrawable = null;

    GL2 gl = context(ctx).getGL().getGL2();

        // If FBO
        if (chosenCaps.isFBO()) {

          fboDrawable = (GLFBODrawable)glDrawable;

          if (chosenCaps.getDoubleBuffered()) {
            // swap = resolve multisampling or flip back/front FBO
            fboDrawable.swapBuffers();
            // unbind texture render target, we read from FBO
            gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
          }

          // bind FBO for reading pixel data
          // GL_FRONT = SamplingSinkFBO if double buffered and multisampled
          // GL_FRONT if double buffered ( = GL_BAck before swap was called)
          // GL_FRONT = GL_BACK if single buffered (single FBO)

          fboDrawable.getFBObject( GL.GL_FRONT ).bind(gl);
        }
        // else pbuffer

        gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, width);
        gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1);

        int type = 0;

        if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) ||
                (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER)) {

            switch (format) {
                // GL_BGR
                case ImageComponentRetained.TYPE_BYTE_BGR:
                    type = GL2.GL_BGR;
                    break;
                case ImageComponentRetained.TYPE_BYTE_RGB:
                    type = GL.GL_RGB;
                    break;
                    // GL_ABGR_EXT
                case ImageComponentRetained.TYPE_BYTE_ABGR:
                    if (gl.isExtensionAvailable("GL_EXT_abgr")) { // If false, should never come here!
                        type = GL2.GL_ABGR_EXT;
                    } else {
                        assert false;
                        return;
                    }
                    break;
                case ImageComponentRetained.TYPE_BYTE_RGBA:
                    type = GL.GL_RGBA;
                    break;

                    /* This method only supports 3 and 4 components formats and BYTE types. */
                case ImageComponentRetained.TYPE_BYTE_LA:
                case ImageComponentRetained.TYPE_BYTE_GRAY:
                case ImageComponentRetained.TYPE_USHORT_GRAY:
                case ImageComponentRetained.TYPE_INT_BGR:
                case ImageComponentRetained.TYPE_INT_RGB:
                case ImageComponentRetained.TYPE_INT_ARGB:
                default:
                    throw new AssertionError("illegal format " + format);
            }

            gl.glReadPixels(0, 0, width, height, type, GL.GL_UNSIGNED_BYTE, ByteBuffer.wrap((byte[]) data));

        }
        else if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) ||
                (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) {

            int intType = GL2.GL_UNSIGNED_INT_8_8_8_8;
            boolean forceAlphaToOne = false;

            switch (format) {
                /* GL_BGR */
                case ImageComponentRetained.TYPE_INT_BGR: /* Assume XBGR format */
                    type = GL.GL_RGBA;
                    intType = GL2.GL_UNSIGNED_INT_8_8_8_8_REV;
                    forceAlphaToOne = true;
                    break;
                case ImageComponentRetained.TYPE_INT_RGB: /* Assume XRGB format */
                    forceAlphaToOne = true;
                    /* Fall through to next case */
                case ImageComponentRetained.TYPE_INT_ARGB:
                    type = GL2.GL_BGRA;
                    intType = GL2.GL_UNSIGNED_INT_8_8_8_8_REV;
                    break;
                    /* This method only supports 3 and 4 components formats and BYTE types. */
                case ImageComponentRetained.TYPE_BYTE_LA:
                case ImageComponentRetained.TYPE_BYTE_GRAY:
                case ImageComponentRetained.TYPE_USHORT_GRAY:
                case ImageComponentRetained.TYPE_BYTE_BGR:
                case ImageComponentRetained.TYPE_BYTE_RGB:
                case ImageComponentRetained.TYPE_BYTE_RGBA:
                case ImageComponentRetained.TYPE_BYTE_ABGR:
                default:
                    throw new AssertionError("illegal format " + format);
            }

            /* Force Alpha to 1.0 if needed */
            if(forceAlphaToOne) {
                gl.glPixelTransferf(GL2.GL_ALPHA_SCALE, 0.0f);
                gl.glPixelTransferf(GL2.GL_ALPHA_BIAS, 1.0f);
            }

            gl.glReadPixels(0, 0, width, height, type, intType, IntBuffer.wrap((int[]) data));

      /* Restore Alpha scale and bias */
      if(forceAlphaToOne) {
    gl.glPixelTransferf(GL2.GL_ALPHA_SCALE, 1.0f);
    gl.glPixelTransferf(GL2.GL_ALPHA_BIAS, 0.0f);
      }
        }
        else {
            throw new AssertionError("illegal image data type " + dataType);
        }
View Full Code Here

Examples of javax.media.opengl.GL2

    // native method for setting Material when no material is present
    @Override
    void updateMaterialColor(Context ctx, float r, float g, float b, float a) {
        if (VERBOSE) System.err.println("JoglPipeline.updateMaterialColor()");

    GL2 gl = context(ctx).getGL().getGL2();
        gl.glColor4f(r, g, b, a);
        gl.glDisable(GL2.GL_LIGHTING);
    }
View Full Code Here

Examples of javax.media.opengl.GL2

    // This is the native method for doing accumulation.
    @Override
    void accum(Context ctx, float value) {
        if (VERBOSE) System.err.println("JoglPipeline.accum()");

    GL2 gl = context(ctx).getGL().getGL2();
        gl.glReadBuffer(GL.GL_BACK);
        gl.glAccum(GL2.GL_ACCUM, value);
        gl.glReadBuffer(GL.GL_FRONT);
    }
View Full Code Here

Examples of javax.media.opengl.GL2

    // This is the native method for doing accumulation return.
    @Override
    void accumReturn(Context ctx) {
        if (VERBOSE) System.err.println("JoglPipeline.accumReturn()");

    GL2 gl = context(ctx).getGL().getGL2();
        gl.glAccum(GL2.GL_RETURN, 1.0f);
    }
View Full Code Here

Examples of javax.media.opengl.GL2

    // Native method for eye lighting
    @Override
    void ctxUpdateEyeLightingEnable(Context ctx, boolean localEyeLightingEnable) {
        if (VERBOSE) System.err.println("JoglPipeline.ctxUpdateEyeLightingEnable()");

    GL2 gl = context(ctx).getGL().getGL2();

        if (localEyeLightingEnable) {
            gl.glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL.GL_TRUE);
        } else {
            gl.glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL.GL_FALSE);
        }
    }
View Full Code Here

Examples of javax.media.opengl.GL2

    @Override
    void setBlendColor(Context ctx, float red, float green,
            float blue, float alpha) {
        if (VERBOSE) System.err.println("JoglPipeline.setBlendColor()");

    GL2 gl = context(ctx).getGL().getGL2();
        if (gl.isExtensionAvailable("GL_ARB_imaging")) {
            gl.glBlendColor(red, green, blue, alpha);
        }
    }
View Full Code Here

Examples of javax.media.opengl.GL2

    // Native method to update separate specular color control
    @Override
    void updateSeparateSpecularColorEnable(Context ctx, boolean enable) {
        if (VERBOSE) System.err.println("JoglPipeline.updateSeparateSpecularColorEnable()");

    GL2 gl = context(ctx).getGL().getGL2();

        if (enable) {
            gl.glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2.GL_SEPARATE_SPECULAR_COLOR);
        } else {
            gl.glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2.GL_SINGLE_COLOR);
        }
    }
View Full Code Here

Examples of javax.media.opengl.GL2

    // native method for setting scene ambient
    @Override
    void setSceneAmbient(Context ctx, float red, float green, float blue) {
        if (VERBOSE) System.err.println("JoglPipeline.setSceneAmbient()");

    GL2 gl = context(ctx).getGL().getGL2();

        float[] color = new float[4];
        color[0] = red;
        color[1] = green;
        color[2] = blue;
        color[3] = 1.0f;
        gl.glLightModelfv(GL2.GL_LIGHT_MODEL_AMBIENT, color, 0);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.