Java Code Examples for com.jogamp.opengl.GL4#glCreateShaderProgramv()

The following examples show how to use com.jogamp.opengl.GL4#glCreateShaderProgramv() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Gl_420_image_load.java    From jogl-samples with MIT License 5 votes vote down vote up
private boolean initProgram(GL4 gl4) {

        boolean validated = true;

        try {

            if (validated) {

                String[] vertexSourceContent = new String[]{new Scanner(new File(SHADERS_ROOT + "/" + SHADERS_SOURCE
                    + ".vert")).useDelimiter("\\A").next()};
                programName[Program.VERT] = gl4.glCreateShaderProgramv(GL_VERTEX_SHADER, 1, vertexSourceContent);
            }

            if (validated) {

                String[] fragmentSourceContent = new String[]{new Scanner(new File(SHADERS_ROOT + "/" + SHADERS_SOURCE
                    + ".frag")).useDelimiter("\\A").next()};
                programName[Program.FRAG] = gl4.glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, fragmentSourceContent);
            }

            if (validated) {

                validated = validated && framework.Compiler.checkProgram(gl4, programName[Program.VERT]);
                validated = validated && framework.Compiler.checkProgram(gl4, programName[Program.FRAG]);
            }

            if (validated) {

                gl4.glGenProgramPipelines(1, pipelineName);
                gl4.glBindProgramPipeline(pipelineName.get(0));
                gl4.glUseProgramStages(pipelineName.get(0), GL_VERTEX_SHADER_BIT, programName[Program.VERT]);
                gl4.glUseProgramStages(pipelineName.get(0), GL_FRAGMENT_SHADER_BIT, programName[Program.FRAG]);
            }

        } catch (FileNotFoundException ex) {
            Logger.getLogger(Gl_420_image_load.class.getName()).log(Level.SEVERE, null, ex);
        }

        return validated && checkError(gl4, "initProgram");
    }
 
Example 2
Source File: Gl_420_image_unpack.java    From jogl-samples with MIT License 5 votes vote down vote up
private boolean initProgram(GL4 gl4) {

        boolean validated = true;

        try {

            if (validated) {

                String[] vertexSourceContent = new String[]{new Scanner(new File(SHADERS_ROOT + "/" + SHADERS_SOURCE
                    + ".vert")).useDelimiter("\\A").next()};
                String[] fragmentSourceContent = new String[]{new Scanner(new File(SHADERS_ROOT + "/" + SHADERS_SOURCE
                    + ".frag")).useDelimiter("\\A").next()};

                programName[Program.VERT] = gl4.glCreateShaderProgramv(GL_VERTEX_SHADER, 1, vertexSourceContent);
                programName[Program.FRAG] = gl4.glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, fragmentSourceContent);
            }

            if (validated) {

                validated = validated && framework.Compiler.checkProgram(gl4, programName[Program.VERT]);
                validated = validated && framework.Compiler.checkProgram(gl4, programName[Program.FRAG]);
            }

            if (validated) {

                gl4.glGenProgramPipelines(1, pipelineName);
                gl4.glBindProgramPipeline(pipelineName.get(0));
                gl4.glUseProgramStages(pipelineName.get(0), GL_VERTEX_SHADER_BIT, programName[Program.VERT]);
                gl4.glUseProgramStages(pipelineName.get(0), GL_FRAGMENT_SHADER_BIT, programName[Program.FRAG]);
            }

        } catch (FileNotFoundException ex) {
            Logger.getLogger(Gl_420_image_unpack.class.getName()).log(Level.SEVERE, null, ex);
        }

        return validated && checkError(gl4, "initProgram");
    }
 
Example 3
Source File: Gl_410_program_64.java    From jogl-samples with MIT License 4 votes vote down vote up
private boolean initProgram(GL4 gl4) {

        boolean validated = true;

        try {

            if (validated) {

                String[] vertexSourceContent = new String[]{new Scanner(new File(SHADERS_ROOT + "/" + SHADERS_SOURCE
                    + ".vert")).useDelimiter("\\A").next()};
                programName[Program.VERT] = gl4.glCreateShaderProgramv(GL_VERTEX_SHADER, 1, vertexSourceContent);
            }

            if (validated) {

                String[] fragmentSourceContent = new String[]{new Scanner(new File(SHADERS_ROOT + "/" + SHADERS_SOURCE
                    + ".frag")).useDelimiter("\\A").next()};
                programName[Program.FRAG] = gl4.glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, fragmentSourceContent);
            }

            if (validated) {

                validated = validated && framework.Compiler.checkProgram(gl4, programName[Program.VERT]);
                validated = validated && framework.Compiler.checkProgram(gl4, programName[Program.FRAG]);
            }

            if (validated) {

                uniformMvp = gl4.glGetUniformLocation(programName[Program.VERT], "mvp");
                uniformDiffuse = gl4.glGetUniformLocation(programName[Program.FRAG], "diffuse");
            }

            if (validated) {

                gl4.glGenProgramPipelines(1, pipelineName);
                gl4.glBindProgramPipeline(pipelineName.get(0));
                gl4.glUseProgramStages(pipelineName.get(0), GL_VERTEX_SHADER_BIT, programName[Program.VERT]);
                gl4.glUseProgramStages(pipelineName.get(0), GL_FRAGMENT_SHADER_BIT, programName[Program.FRAG]);
            }

        } catch (FileNotFoundException ex) {
            Logger.getLogger(Gl_410_program_64.class.getName()).log(Level.SEVERE, null, ex);
        }

        return validated && checkError(gl4, "initProgram");
    }
 
Example 4
Source File: Gl_410_program_separate.java    From jogl-samples with MIT License 4 votes vote down vote up
private boolean initSeparateProgram(GL4 gl4) {

        boolean validated = true;

        try {

            if (validated) {

                String[] vertexSourceContent = new String[]{new Scanner(new File(SHADERS_ROOT + "/" + SHADERS_SOURCE
                    + ".vert")).useDelimiter("\\A").next()};
                separateProgramName[Program.VERTEX] = gl4.glCreateShaderProgramv(GL_VERTEX_SHADER, 1, vertexSourceContent);
            }

            if (validated) {

                String[] fragmentSourceContent = new String[]{new Scanner(new File(SHADERS_ROOT + "/" + SHADERS_SOURCE
                    + ".frag")).useDelimiter("\\A").next()};
                separateProgramName[Program.FRAGMENT] = gl4.glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, fragmentSourceContent);
            }

            if (validated) {

                validated = validated
                        && framework.Compiler.checkProgram(gl4, separateProgramName[Program.VERTEX]);
                validated = validated
                        && framework.Compiler.checkProgram(gl4, separateProgramName[Program.FRAGMENT]);
            }
            if (validated) {

                gl4.glGenProgramPipelines(1, pipelineName);
                gl4.glUseProgramStages(pipelineName.get(0), GL_VERTEX_SHADER_BIT, separateProgramName[Program.VERTEX]);
                gl4.glUseProgramStages(pipelineName.get(0), GL_FRAGMENT_SHADER_BIT, separateProgramName[Program.FRAGMENT]);
            }
            if (validated) {

                separateUniformMvp = gl4.glGetUniformLocation(separateProgramName[Program.VERTEX], "mvp");
                separateUniformDiffuse = gl4.glGetUniformLocation(separateProgramName[Program.FRAGMENT], "diffuse");
            }

        } catch (FileNotFoundException ex) {
            Logger.getLogger(Gl_410_program_64.class.getName()).log(Level.SEVERE, null, ex);
        }

        return validated && checkError(gl4, "initProgram");
    }