Package javax.media.opengl

Examples of javax.media.opengl.GLException


        else if (vbo.getBuffer() instanceof IntBuffer)
            gl.glVertexAttribIPointer(location, vbo.getComponents(), vbo.getComponentType(), vbo.getStride(), 0);
        else if (vbo.getBuffer() instanceof DoubleBuffer)
            gl.glVertexAttribPointer(location, vbo.getComponents(), vbo.getComponentType(), false, vbo.getStride(), 0);
        else
            throw new GLException("Unrecognized buffer type: " + vbo.getBuffer().getClass().getName());
    }
View Full Code Here


        this.ubo = tmp[0];
       
        this.blockName = blockName;
        final int blockIndex = gl.glGetUniformBlockIndex(shader.program(), blockName);
        if(blockIndex < 0)
            throw new GLException("Uniform block " + blockName + " not found in program " + shader.program());
        gl.glGetActiveUniformBlockiv(shader.program(), blockIndex, gl.GL_UNIFORM_BLOCK_DATA_SIZE, tmp, 0);
        final int blockSize = tmp[0];
       
        gl.glBindBuffer(gl.GL_UNIFORM_BUFFER, ubo);
        gl.glBufferData(gl.GL_UNIFORM_BUFFER, blockSize, null, gl.GL_DYNAMIC_DRAW);
View Full Code Here

        if (info == null) {
            int[] tmp = new int[1];
            gl.glGetUniformIndices(shader.program(), 1, new String[]{blockName + "." + uniformName}, tmp, 0);
            final int index = tmp[0];
            if (index < 0)
                throw new GLException("Uniform " + blockName + "." + uniformName + " not found");
           
            final int[] indices = new int[]{index};
            gl.glGetActiveUniformsiv(shader.program(), 1, indices, 0, gl.GL_UNIFORM_OFFSET, tmp, 0);
            final int offset = tmp[0];
            gl.glGetActiveUniformsiv(shader.program(), 1, indices, 0, gl.GL_UNIFORM_TYPE, tmp, 0);
View Full Code Here

   
    private Info verifySize(GL3 gl, String uniformName, int size) {
        final Info info = getInfo(gl, uniformName);
        final int requiredSize = info.size * BO.sizeOfGLType(info.type);
        if(requiredSize != size)
            throw new GLException("Trying to write " + size + " bytes into uniform " + uniformName + " which is of size " + requiredSize);
        return info;
    }
View Full Code Here

            case GL.GL_STATIC_DRAW:
            case GL.GL_DYNAMIC_DRAW:
            case GL2ES2.GL_STREAM_DRAW:
                break;
            default:
                throw new GLException("invalid vboUsage: " + vboUsage + ":\n\t" + this);
        }
        this.usage = vboUsage;

        switch (vboTarget) {
            case 0: // nop
            case GL.GL_ARRAY_BUFFER:
            case GL.GL_ELEMENT_ARRAY_BUFFER:
                break;
            default:
                throw new GLException("invalid vboTarget: " + vboTarget + ":\n\t" + this);
        }

        final int componentByteSize = GLBuffers.sizeOfGLType(componentType);
        if (componentByteSize < 0)
            throw new GLException("Given componentType not supported: " + componentType + ":\n\t" + this);
        this.componentType = componentType;

        if (components <= 0)
            throw new GLException("Invalid number of components: " + components);

        this.components = components;
        this.stride = components * componentByteSize;

        this.buffer = GLBuffers.newDirectGLBuffer(componentType, components * numElements);
 
View Full Code Here

        ShaderCode vertexShader = ShaderCode.create(gl, GL3.GL_VERTEX_SHADER, this.getClass(), "shader", null, "vertex", false);
        ShaderCode geometryShader = ShaderCode.create(gl, GL3.GL_GEOMETRY_SHADER, this.getClass(), "shader", null, "geometry", false);
        ShaderCode fragmentShader = ShaderCode.create(gl, GL3.GL_FRAGMENT_SHADER, this.getClass(), "shader", null, "fragment", false);

        if (!vertexShader.compile(gl, System.err))
            throw new GLException("Couldn't compile shader: " + vertexShader);
        if (!geometryShader.compile(gl, System.err))
            throw new GLException("Couldn't compile shader: " + geometryShader);
        if (!fragmentShader.compile(gl, System.err))
            throw new GLException("Couldn't compile shader: " + fragmentShader);

        shaderProgram = new ShaderProgram();
        shaderProgram.add(gl, vertexShader, System.err);
        shaderProgram.add(gl, geometryShader, System.err);
        shaderProgram.add(gl, fragmentShader, System.err);
        if (!shaderProgram.link(gl, System.err))
            throw new GLException("Couldn't link program: " + shaderProgram);

        this.shaderState = new ProgramState(gl, shaderProgram);
        shaderState.bind(gl);

        pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
View Full Code Here

   
    transparentsShader = new ShaderProgram();
    transparentsShader.add(tsVp);
    transparentsShader.add(tsFp);
        if(!transparentsShader.link(gl, System.err)) {
            throw new GLException("could not link program: " + transparentsShader);
        }
        gl.glBindAttribLocation(transparentsShader.program(), 0, "aVertexPosition");
        gl.glBindAttribLocation(transparentsShader.program(), 1, "aTextureCoord");
        tsUPMatrix = gl.glGetUniformLocation(transparentsShader.program(), "uPMatrix");
        tsUMVMatrix = gl.glGetUniformLocation(transparentsShader.program(), "uMVMatrix");
        tsTex = gl.glGetUniformLocation(transparentsShader.program(), "uSampler");

       
    ShaderCode ssVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(),
        "shaders", "shaders/bin", "solids", true);
    ShaderCode ssFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(),
        "shaders", "shaders/bin", "solids", true);
    ssVp.defaultShaderCustomization(gl, true, true);
    ssFp.defaultShaderCustomization(gl, true, true);
   
    solidsShader = new ShaderProgram();
    solidsShader.add(ssVp);
    solidsShader.add(ssFp);
        if(!solidsShader.link(gl, System.err)) {
            throw new GLException("could not link program: " + solidsShader);
        }
        gl.glBindAttribLocation(solidsShader.program(), 0, "aVertexPosition");
        gl.glBindAttribLocation(solidsShader.program(), 1, "aTextureCoord");
        gl.glBindAttribLocation(solidsShader.program(), 2, "aVertexColor");
        ssUPMatrix = gl.glGetUniformLocation(solidsShader.program(), "uPMatrix");
View Full Code Here

TOP

Related Classes of javax.media.opengl.GLException

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.