Package javax.media.opengl

Examples of javax.media.opengl.GL


    public void clearBuffers(final int buffers) {
        clearBuffers(buffers, false);
    }

    public void clearBuffers(final int buffers, final boolean strict) {
        final GL gl = GLContext.getCurrentGL();

        int clear = 0;

        if ((buffers & Renderer.BUFFER_COLOR) != 0) {
            clear |= GL.GL_COLOR_BUFFER_BIT;
        }

        if ((buffers & Renderer.BUFFER_DEPTH) != 0) {
            clear |= GL.GL_DEPTH_BUFFER_BIT;

            // make sure no funny business is going on in the z before clearing.
            if (defaultStateList.containsKey(RenderState.StateType.ZBuffer)) {
                defaultStateList.get(RenderState.StateType.ZBuffer).setNeedsRefresh(true);
                doApplyState(defaultStateList.get(RenderState.StateType.ZBuffer));
            }
        }

        if ((buffers & Renderer.BUFFER_STENCIL) != 0) {
            clear |= GL.GL_STENCIL_BUFFER_BIT;

            gl.glClearStencil(_stencilClearValue);
            gl.glStencilMask(~0);
            gl.glClear(GL.GL_STENCIL_BUFFER_BIT);
        }

        if ((buffers & Renderer.BUFFER_ACCUMULATION) != 0) {
            clear |= GL2.GL_ACCUM_BUFFER_BIT;
        }

        final RenderContext context = ContextManager.getCurrentContext();
        final RendererRecord record = context.getRendererRecord();

        if (strict) {
            // grab our camera to get width and height info.
            final Camera cam = Camera.getCurrentCamera();

            gl.glEnable(GL.GL_SCISSOR_TEST);
            gl.glScissor(0, 0, cam.getWidth(), cam.getHeight());
            record.setClippingTestEnabled(true);
        }

        gl.glClear(clear);

        if (strict) {
            // put us back.
            JoglRendererUtil.applyScissors(record);
        }
View Full Code Here


            JoglRendererUtil.applyScissors(record);
        }
    }

    public void flushFrame(final boolean doSwap) {
        final GL gl = GLContext.getCurrentGL();

        renderBuckets();

        gl.glFlush();
        if (doSwap) {

            doApplyState(defaultStateList.get(RenderState.StateType.ColorMask));

            if (Constants.stats) {
View Full Code Here

    }

    @Override
    public void grabScreenContents(final ByteBuffer store, final ImageDataFormat format, final PixelDataType type,
            final int x, final int y, final int w, final int h) {
        final GL gl = GLContext.getCurrentGL();

        final int pixFormat = JoglTextureUtil.getGLPixelFormat(format);
        final int pixDataType = JoglTextureUtil.getGLPixelDataType(type);
        // N.B: it expects depth = 1 & pack = true
        gl.glReadPixels(x, y, w, h, pixFormat, pixDataType, store);
    }
View Full Code Here

    }

    @Override
    public int getExpectedBufferSizeToGrabScreenContents(final ImageDataFormat format, final PixelDataType type,
            final int w, final int h) {
        final GL gl = GLContext.getCurrentGL();
        final int pixFormat = JoglTextureUtil.getGLPixelFormat(format);
        final int pixDataType = JoglTextureUtil.getGLPixelDataType(type);
        final int[] tmp = new int[1];
        return GLBuffers.sizeof(gl, tmp, pixFormat, pixDataType, w, h, 1, true);
    }
View Full Code Here

    protected void postdrawGeometry(final Mesh g) {
        // Nothing to do here yet
    }

    public void flushGraphics() {
        final GL gl = GLContext.getCurrentGL();

        gl.glFlush();
    }
View Full Code Here

        gl.glFlush();
    }

    public void finishGraphics() {
        final GL gl = GLContext.getCurrentGL();

        gl.glFinish();
    }
View Full Code Here

        gl.glFinish();
    }

    public void applyNormalsMode(final NormalsMode normalsMode, final ReadOnlyTransform worldTransform) {
        final GL gl = GLContext.getCurrentGL();
        final RenderContext context = ContextManager.getCurrentContext();
        final RendererRecord rendRecord = context.getRendererRecord();
        if (normalsMode != NormalsMode.Off) {
            final ContextCapabilities caps = context.getCapabilities();
            switch (normalsMode) {
                case NormalizeIfScaled:
                    if (worldTransform.isRotationMatrix()) {
                        final ReadOnlyVector3 scale = worldTransform.getScale();
                        if (!(scale.getX() == 1.0 && scale.getY() == 1.0 && scale.getZ() == 1.0)) {
                            if (scale.getX() == scale.getY() && scale.getY() == scale.getZ()
                                    && caps.isOpenGL1_2Supported()
                                    && rendRecord.getNormalMode() != GL2ES1.GL_RESCALE_NORMAL) {
                                if (rendRecord.getNormalMode() == GLLightingFunc.GL_NORMALIZE) {
                                    gl.glDisable(GLLightingFunc.GL_NORMALIZE);
                                }
                                gl.glEnable(GL2ES1.GL_RESCALE_NORMAL);
                                rendRecord.setNormalMode(GL2ES1.GL_RESCALE_NORMAL);
                            } else if (rendRecord.getNormalMode() != GLLightingFunc.GL_NORMALIZE) {
                                if (rendRecord.getNormalMode() == GL2ES1.GL_RESCALE_NORMAL) {
                                    gl.glDisable(GL2ES1.GL_RESCALE_NORMAL);
                                }
                                gl.glEnable(GLLightingFunc.GL_NORMALIZE);
                                rendRecord.setNormalMode(GLLightingFunc.GL_NORMALIZE);
                            }
                        } else {
                            if (rendRecord.getNormalMode() == GL2ES1.GL_RESCALE_NORMAL) {
                                gl.glDisable(GL2ES1.GL_RESCALE_NORMAL);
                            } else if (rendRecord.getNormalMode() == GLLightingFunc.GL_NORMALIZE) {
                                gl.glDisable(GLLightingFunc.GL_NORMALIZE);
                            }
                            rendRecord.setNormalMode(GL.GL_ZERO);
                        }
                    } else {
                        if (!worldTransform.getMatrix().isIdentity()) {
                            // *might* be scaled...
                            if (rendRecord.getNormalMode() != GLLightingFunc.GL_NORMALIZE) {
                                if (rendRecord.getNormalMode() == GL2ES1.GL_RESCALE_NORMAL) {
                                    gl.glDisable(GL2ES1.GL_RESCALE_NORMAL);
                                }
                                gl.glEnable(GLLightingFunc.GL_NORMALIZE);
                                rendRecord.setNormalMode(GLLightingFunc.GL_NORMALIZE);
                            }
                        } else {
                            // not scaled
                            if (rendRecord.getNormalMode() == GL2ES1.GL_RESCALE_NORMAL) {
                                gl.glDisable(GL2ES1.GL_RESCALE_NORMAL);
                            } else if (rendRecord.getNormalMode() == GLLightingFunc.GL_NORMALIZE) {
                                gl.glDisable(GLLightingFunc.GL_NORMALIZE);
                            }
                            rendRecord.setNormalMode(GL.GL_ZERO);
                        }
                    }
                    break;
                case AlwaysNormalize:
                    if (rendRecord.getNormalMode() != GLLightingFunc.GL_NORMALIZE) {
                        if (rendRecord.getNormalMode() == GL2ES1.GL_RESCALE_NORMAL) {
                            gl.glDisable(GL2ES1.GL_RESCALE_NORMAL);
                        }
                        gl.glEnable(GLLightingFunc.GL_NORMALIZE);
                        rendRecord.setNormalMode(GLLightingFunc.GL_NORMALIZE);
                    }
                    break;
                case UseProvided:
                default:
                    if (rendRecord.getNormalMode() == GL2ES1.GL_RESCALE_NORMAL) {
                        gl.glDisable(GL2ES1.GL_RESCALE_NORMAL);
                    } else if (rendRecord.getNormalMode() == GLLightingFunc.GL_NORMALIZE) {
                        gl.glDisable(GLLightingFunc.GL_NORMALIZE);
                    }
                    rendRecord.setNormalMode(GL.GL_ZERO);
                    break;
            }
        } else {
            if (rendRecord.getNormalMode() == GL2ES1.GL_RESCALE_NORMAL) {
                gl.glDisable(GL2ES1.GL_RESCALE_NORMAL);
            } else if (rendRecord.getNormalMode() == GLLightingFunc.GL_NORMALIZE) {
                gl.glDisable(GLLightingFunc.GL_NORMALIZE);
            }
            rendRecord.setNormalMode(GL.GL_ZERO);
        }
    }
View Full Code Here

            rendRecord.setNormalMode(GL.GL_ZERO);
        }
    }

    public void applyDefaultColor(final ReadOnlyColorRGBA defaultColor) {
        final GL gl = GLContext.getCurrentGL();
        if (defaultColor != null) {
            gl.getGL2ES1().glColor4f(defaultColor.getRed(), defaultColor.getGreen(), defaultColor.getBlue(),
                    defaultColor.getAlpha());
        } else {
            gl.getGL2ES1().glColor4f(1, 1, 1, 1);
        }
    }
View Full Code Here

            gl.getGL2ES1().glColor4f(1, 1, 1, 1);
        }
    }

    public void deleteVBOs(final Collection<Integer> ids) {
        final GL gl = GLContext.getCurrentGL();
        final IntBuffer idBuffer = BufferUtils.createIntBuffer(ids.size());
        idBuffer.clear();
        for (final Integer i : ids) {
            if (i != null && i != 0) {
                idBuffer.put(i);
            }
        }
        idBuffer.flip();
        if (idBuffer.remaining() > 0) {
            gl.glDeleteBuffers(idBuffer.remaining(), idBuffer);
        }
    }
View Full Code Here

            gl.glDeleteBuffers(idBuffer.remaining(), idBuffer);
        }
    }

    public void deleteDisplayLists(final Collection<Integer> ids) {
        final GL gl = GLContext.getCurrentGL();
        for (final Integer i : ids) {
            if (i != null && i != 0) {
                gl.getGL2().glDeleteLists(i, 1);
            }
        }
    }
View Full Code Here

TOP

Related Classes of javax.media.opengl.GL

Copyright © 2018 www.massapicom. 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.