当前位置: 首页>>代码示例>>Java>>正文


Java GL4.glUniform1i方法代码示例

本文整理汇总了Java中com.jogamp.opengl.GL4.glUniform1i方法的典型用法代码示例。如果您正苦于以下问题:Java GL4.glUniform1i方法的具体用法?Java GL4.glUniform1i怎么用?Java GL4.glUniform1i使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jogamp.opengl.GL4的用法示例。


在下文中一共展示了GL4.glUniform1i方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderFramebuffer

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private void renderFramebuffer(GL4 gl4) {

        gl4.glEnable(GL_DEPTH_TEST);
        gl4.glDepthFunc(GL_LESS);

        gl4.glViewport(0, 0, windowSize.x, windowSize.y);

        gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
        gl4.glClearBufferfv(GL_DEPTH, 0, clearDepth);
        gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0).put(1, 0).put(2, 0).put(3, 1));

        gl4.glUseProgram(programName[Program.RENDER]);
        gl4.glUniform1i(uniformShadow, 0);
        gl4.glUniformBlockBinding(programName[Program.RENDER], uniformTransform[Program.RENDER],
                Semantic.Uniform.TRANSFORM0);

        gl4.glActiveTexture(GL_TEXTURE0);
        gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.SHADOWMAP));

        gl4.glBindVertexArray(vertexArrayName.get(Program.RENDER));
        gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0);

        gl4.glDisable(GL_DEPTH_TEST);

        checkError(gl4, "renderFramebuffer");
    }
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:27,代码来源:Gl_400_fbo_shadow.java

示例2: render

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 1000.0f);
    Mat4 model = new Mat4(1.0f);
    Mat4 mvp = projection.mul(viewMat4()).mul(model);

    gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y);
    gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, 0.5f).put(2, 0).put(3, 1));

    gl4.glUseProgram(programName);
    gl4.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0);
    gl4.glUniform1i(uniformDiffuse, 0);

    gl4.glActiveTexture(GL_TEXTURE0);
    gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(0));
    gl4.glBindSampler(0, samplerName.get(0));

    gl4.glBindVertexArray(vertexArrayName.get(0));
    gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
    gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0);

    return true;
}
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:27,代码来源:Gl_420_sampler_gather.java

示例3: Program

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
public Program(GL4 gl4) {

            super(gl4, Application.SHADERS_ROOT, SHADERS_SRC);

            gl4.glUseProgram(name);
            gl4.glUniform1i(
                    gl4.glGetUniformLocation(name, "myTexture"),
                    Semantic.Sampler.MY_TEXTURE);
            gl4.glUseProgram(0);
        }
 
开发者ID:java-opengl-labs,项目名称:jogl-hello-vr,代码行数:11,代码来源:Distortion.java

示例4: Program

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
public Program(GL4 gl4) {

            super(gl4, Application.SHADERS_ROOT, SHADERS_SRC);

            matrixUL = gl4.glGetUniformLocation(name, "matrix");

            gl4.glUseProgram(name);
            gl4.glUniform1i(
                    gl4.glGetUniformLocation(name, "myTexture"),
                    Semantic.Sampler.MY_TEXTURE);
            gl4.glUseProgram(0);
        }
 
开发者ID:java-opengl-labs,项目名称:jogl-hello-vr,代码行数:13,代码来源:Scene.java

示例5: Program

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
public Program(GL4 gl4) {

            super(gl4, Application.SHADERS_ROOT, SHADERS_SRC);

            matrixUL = gl4.glGetUniformLocation(name, "matrix");

            gl4.glUseProgram(name);
            gl4.glUniform1i(
                    gl4.glGetUniformLocation(name, "diffuse"),
                    Semantic.Sampler.DIFFUSE);
            gl4.glUseProgram(0);
        }
 
开发者ID:java-opengl-labs,项目名称:jogl-hello-vr,代码行数:13,代码来源:ModelsRender.java

示例6: render

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
    gl4.glClearBufferfv(GL_COLOR, 0, new float[]{1.0f, 0.5f, 0.0f, 1.0f}, 0);

    gl4.glUseProgram(programName);
    gl4.glUniform1i(uniformDiffuse, 0);

    // Pass 1, render the scene in a multisampled framebuffer
    gl4.glEnable(GL_MULTISAMPLE);
    gl4.glEnable(GL_SAMPLE_SHADING);
    gl4.glMinSampleShading(4 / 2.0f);

    float[] min = {0};
    gl4.glGetFloatv(GL_MIN_SAMPLE_SHADING_VALUE, min, 0);
    //glEnable(GL_SAMPLE_MASK);
    //glSampleMaski(0, 0xFF);
    renderFBO(gl4, framebufferName.get(Framebuffer.RENDER));
    gl4.glDisable(GL_MULTISAMPLE);

    // Resolved multisampling
    gl4.glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER));
    gl4.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferName.get(Framebuffer.RESOLVE));
    gl4.glBlitFramebuffer(
            0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y,
            0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y,
            GL_COLOR_BUFFER_BIT, GL_NEAREST);
    gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);

    // Pass 2, render the colorbuffer from the multisampled framebuffer
    gl4.glViewport(0, 0, windowSize.x, windowSize.y);
    renderFB(gl4, textureName.get(Texture.COLOR));

    return true;
}
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:39,代码来源:Gl_400_fbo_multisample.java

示例7: render

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f);
    Mat4 model = new Mat4(1.0f);
    Mat4 mvp = projection.mul(viewMat4()).mul(model);

    gl4.glViewport(0, 0, windowSize.x, windowSize.y);

    gl4.glClearBufferfv(GL_DEPTH, 0, clearDepth.put(0, 1));
    gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0).put(1, 0).put(2, 0).put(3, 0));

    gl4.glActiveTexture(GL_TEXTURE0);
    gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.RGB8));

    gl4.glActiveTexture(GL_TEXTURE1);
    gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DXT1));

    gl4.glUseProgram(programName);
    gl4.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0);
    gl4.glUniform1i(uniformRGB8, 0);
    gl4.glUniform1i(uniformDXT1, 1);

    gl4.glBindVertexArray(vertexArrayName.get(0));
    gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));

    gl4.glUniform1f(uniformDisplacement, 1.1f);
    subroutineId.position(Subroutine.DXT1);
    gl4.glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, 1, subroutineId);
    gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0, 1, 0);

    gl4.glUniform1f(uniformDisplacement, -1.1f);
    subroutineId.position(Subroutine.DXT1);
    gl4.glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, 1, subroutineId);
    gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0, 1, 0);

    return true;
}
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:41,代码来源:Gl_400_program_subroutine.java

示例8: render

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    Vec2i framebufferSize = new Vec2i(windowSize.x / FRAMEBUFFER_SIZE, windowSize.y / FRAMEBUFFER_SIZE);

    // Pass 1
    gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
    gl4.glViewport(0, 0, framebufferSize.x, framebufferSize.y);
    gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, 0).put(2, 0).put(3, 1));
    gl4.glClearBufferfv(GL_COLOR, 1, clearColor.put(0, 0).put(1, 1).put(2, 0).put(3, 1));
    gl4.glClearBufferfv(GL_COLOR, 2, clearColor.put(0, 0).put(1, 0).put(2, 1).put(3, 1));
    gl4.glClearBufferfv(GL_COLOR, 3, clearColor.put(0, 1).put(1, 1).put(2, 0).put(3, 1));

    // Pass 2
    gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
    gl4.glViewport(0, 0, windowSize.x, windowSize.y);
    gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, .5f).put(2, 0).put(3, 1));

    gl4.glUseProgram(programName);
    gl4.glUniform1i(uniformDiffuse, 0);

    gl4.glActiveTexture(GL_TEXTURE0);
    gl4.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(0));
    gl4.glBindVertexArray(vertexArrayName.get(0));

    for (int i = 0; i < Texture.MAX; ++i) {
        gl4.glViewport((int) viewport[i].x, (int) viewport[i].y, (int) viewport[i].z, (int) viewport[i].w);
        gl4.glUniform1i(uniformLayer, i);

        gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1);
    }

    return true;
}
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:37,代码来源:Gl_400_fbo_rtt_texture_array.java

示例9: render

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f);
    Mat4 model = new Mat4(1.0f);
    Mat4 mvp = projection.mul(viewMat4()).mul(model);

    gl4.glViewport(0, 0, windowSize.x, windowSize.y);

    gl4.glClearBufferfv(GL_DEPTH, 0, clearDepth.put(0, 1));
    gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, 1).put(2, 1).put(3, 1));

    gl4.glUseProgram(programName);
    gl4.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0);
    gl4.glUniform1i(uniformDisplacement, 0);
    gl4.glUniform1i(uniformDiffuse, 1);

    gl4.glActiveTexture(GL_TEXTURE0);
    gl4.glBindTexture(GL_TEXTURE_BUFFER, textureName.get(Texture.DISPLACEMENT));

    gl4.glActiveTexture(GL_TEXTURE1);
    gl4.glBindTexture(GL_TEXTURE_BUFFER, textureName.get(Texture.DIFFUSE));

    gl4.glBindVertexArray(vertexArrayName.get(0));
    gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 5, 0);

    return true;
}
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:31,代码来源:Gl_400_texture_buffer_rgb.java

示例10: render

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 1000.0f);
    Mat4 model = new Mat4(1.0f);
    Mat4 mvp = projection.mul(viewMat4()).mul(model);

    gl4.glViewport(0, 0, windowSize.x, windowSize.y);
    gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, 0.5f).put(2, 0).put(3, 1));

    gl4.glUseProgram(programName);
    gl4.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0);
    gl4.glUniform1i(uniformDiffuseRGB, 0);
    gl4.glUniform1i(uniformDiffuseBGR, 1);

    gl4.glActiveTexture(GL_TEXTURE0);
    gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.RGB));
    gl4.glBindSampler(0, samplerName.get(0));

    gl4.glActiveTexture(GL_TEXTURE1);
    gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.BGR));
    gl4.glBindSampler(1, samplerName.get(0));

    gl4.glBindVertexArray(vertexArrayName.get(0));
    gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0, 1, 0);

    return true;
}
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:31,代码来源:Gl_400_sampler_array_nv.java

示例11: render

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    {
        gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
        ByteBuffer pointer = gl4.glMapBufferRange(
                GL_UNIFORM_BUFFER, 0, Mat4.SIZE,
                GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);

        Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f);
        Mat4 model = new Mat4(1.0f);

        pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_());

        // Make sure the uniform buffer is uploaded
        gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
    }

    gl4.glViewport(0, 0, windowSize.x, windowSize.y);
    gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, 1).put(2, 1).put(3, 1));

    gl4.glUseProgram(programName);
    gl4.glUniform1i(uniformDiffuse, 0);
    gl4.glUniformBlockBinding(programName, uniformTransform, Semantic.Uniform.TRANSFORM0);

    gl4.glActiveTexture(GL_TEXTURE0);
    gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(0));
    gl4.glBindVertexArray(vertexArrayName.get(0));
    gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));

    gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0);

    return true;
}
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:37,代码来源:Gl_410_glsl_block.java

示例12: render

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    Vec2i framebufferSize = new Vec2i(windowSize.x / FRAMEBUFFER_SIZE, windowSize.y / FRAMEBUFFER_SIZE);

    // Update of the uniform buffer
    {
        gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
        ByteBuffer pointer = gl4.glMapBufferRange(
                GL_UNIFORM_BUFFER, 0, Mat4.SIZE,
                GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);

        Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f);
        Mat4 model = new Mat4(1.0f);

        pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_());

        // Make sure the uniform buffer is uploaded
        gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
    }

    gl4.glEnable(GL_DEPTH_TEST);
    gl4.glDepthFunc(GL_LESS);

    gl4.glViewport(0, 0, framebufferSize.x, framebufferSize.y);
    gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
    
    gl4.glClearBufferfv(GL_DEPTH, 0, clearDepth.put(0,1));
    gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0).put(1, 0).put(2, 0).put(3, 1));

    gl4.glUseProgram(programName[Program.TEXTURE]);
    gl4.glUniform1i(uniformDiffuse[Program.TEXTURE], 0);
    gl4.glUniformBlockBinding(programName[Program.TEXTURE], uniformTransform,
            Semantic.Uniform.TRANSFORM0);

    gl4.glActiveTexture(GL_TEXTURE0);
    gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE));
    gl4.glBindVertexArray(vertexArrayName.get(Program.TEXTURE));
    gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));

    gl4.glEnable(GL_SCISSOR_TEST);
    {
        gl4.glScissor(0, 0, framebufferSize.x / 2, framebufferSize.y);
        gl4.glUniform1i(uniformUseGrad, 1);
        gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 2, 0);

        gl4.glScissor(framebufferSize.x / 2, 0, framebufferSize.x / 2, framebufferSize.y);
        gl4.glUniform1i(uniformUseGrad, 0);
        gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 2, 0);
    }
    gl4.glDisable(GL_SCISSOR_TEST);

    gl4.glDisable(GL_DEPTH_TEST);
    gl4.glViewport(0, 0, windowSize.x, windowSize.y);
    gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
    gl4.glUseProgram(programName[Program.SPLASH]);
    gl4.glUniform1i(uniformDiffuse[Program.SPLASH], 0);
    gl4.glUniform1f(uniformFramebufferSize, FRAMEBUFFER_SIZE);

    gl4.glActiveTexture(GL_TEXTURE0);
    gl4.glBindVertexArray(vertexArrayName.get(Program.SPLASH));
    gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER));

    gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, 3, 1);

    return true;
}
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:70,代码来源:Gl_400_texture_derivative.java

示例13: render

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    // Pass 1: Compute the MVP (Model View Projection matrix)
    Mat4 projection = glm.ortho_(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);
    Mat4 viewTranslate = new Mat4(1.0f).translate(new Vec3(0.0f, 0.0f, 0.0f));
    Mat4 view = viewTranslate;
    Mat4 model = new Mat4(1.0f);
    Mat4 mvp = projection.mul(view).mul(model);

    gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
    gl4.glViewport(0, 0, windowSize.x, windowSize.y);

    gl4.glUseProgram(programName[Program.COLORBUFFERS]);
    gl4.glUniformMatrix4fv(uniformMvpMultiple, 1, false, mvp.toFa_(), 0);

    gl4.glBindVertexArray(vertexArrayName.get(0));
    gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0);

    // Pass 2
    gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
    gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, .5f).put(1, .5f).put(2, .5f).put(3, .5f));

    gl4.glUseProgram(programName[Program.BLIT]);
    gl4.glUniform1i(uniformDiffuseSingle, 0);

    {
        projection.ortho(-1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f);
        view.identity();
        model.identity();
        mvp = projection.mul(view).mul(model);
        gl4.glUniformMatrix4fv(uniformMvpSingle, 1, false, mvp.toFa_(), 0);
    }

    for (int i = 0; i < Texture.MAX; ++i) {

        gl4.glViewport(viewport[i].x, viewport[i].y, viewport[i].z, viewport[i].w);

        gl4.glActiveTexture(GL_TEXTURE0);
        gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(i));

        gl4.glBindVertexArray(vertexArrayName.get(0));
        gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0);
    }

    return true;
}
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:50,代码来源:Gl_400_blend_rtt.java

示例14: render

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    Mat4 projection = glm.ortho_(-1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f);
    Mat4 view = new Mat4(1.0f);
    Mat4 model = new Mat4(1.0f);
    Mat4 mvp = projection.mul(view).mul(model);

    gl4.glViewport(0, 0, windowSize.x, windowSize.y);
    gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0).put(1, 0).put(2, 0).put(3, 0));

    // Pass 1
    {
        gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
        gl4.glViewport(0, 0, windowSize.x / FRAMEBUFFER_SIZE, windowSize.y / FRAMEBUFFER_SIZE);

        gl4.glUseProgram(programName[Program.LAYERING]);
        gl4.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0);

        gl4.glBindVertexArray(vertexArrayName.get(Program.LAYERING));
        gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0);
    }

    // Pass 2
    {
        gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);

        gl4.glUseProgram(programName[Program.IMAGE_2D]);
        gl4.glUniform1i(uniformDiffuse, 0);

        gl4.glActiveTexture(GL_TEXTURE0);
        gl4.glBindTexture(GL_TEXTURE_2D_ARRAY, textureColorbufferName.get(0));
        gl4.glBindSampler(0, samplerName.get(0));

        gl4.glBindVertexArray(vertexArrayName.get(Program.IMAGE_2D));

        for (int i = 0; i < 4; ++i) {
            gl4.glUniform1i(uniformLayer, i);
            gl4.glViewport(viewport[i].x, viewport[i].y, viewport[i].z, viewport[i].w);
            gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0);
        }
    }

    return true;
}
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:48,代码来源:Gl_400_fbo_layered.java

示例15: initProgram

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initProgram(GL4 gl4) {

        boolean validated = true;

        // Create program
        if (validated) {

            ShaderProgram shaderProgram = new ShaderProgram();

            ShaderCode vertexShaderCode = ShaderCode.create(gl4, GL_VERTEX_SHADER, this.getClass(), SHADERS_ROOT,
                    null, SHADERS_SOURCE, "vert", null, true);
            ShaderCode fragmentShaderCode = ShaderCode.create(gl4, GL_FRAGMENT_SHADER, this.getClass(), SHADERS_ROOT,
                    null, SHADERS_SOURCE, "frag", null, true);

            shaderProgram.init(gl4);

            shaderProgram.add(vertexShaderCode);
            shaderProgram.add(fragmentShaderCode);

            programName = shaderProgram.program();

            shaderProgram.link(gl4, System.out);

        }

        // Get variables locations
        if (validated) {

            gl4.glUniformBlockBinding(programName, gl4.glGetUniformBlockIndex(programName, "Transform"),
                    Semantic.Uniform.TRANSFORM0);

            gl4.glUseProgram(programName);
            gl4.glUniform1i(gl4.glGetUniformLocation(programName, "diffuse"), 0);
            gl4.glUseProgram(0);
        }

        return validated & checkError(gl4, "initProgram");
    }
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:39,代码来源:Gl_400_sampler_fetch.java


注:本文中的com.jogamp.opengl.GL4.glUniform1i方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。