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


Java GLBuffers.newDirectFloatBuffer方法代码示例

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


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

示例1: initBuffer

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

        gl4.glGenBuffers(Buffer.MAX, bufferName);

        gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
        ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
        gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
        BufferUtils.destroyDirectBuffer(elementBuffer);
        gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

        gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
        FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
        gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
        BufferUtils.destroyDirectBuffer(vertexBuffer);
        gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);

        gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
        gl4.glBufferData(GL_UNIFORM_BUFFER, Mat4.SIZE, null, GL_DYNAMIC_DRAW);
        gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);

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

示例2: initSampler

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

        FloatBuffer borderColor = GLBuffers.newDirectFloatBuffer(new float[]{0.0f, 0.0f, 0.0f, 0.0f});

        gl4.glGenSamplers(1, samplerName);

        gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
        gl4.glSamplerParameterfv(samplerName.get(0), GL_TEXTURE_BORDER_COLOR, borderColor);
        gl4.glSamplerParameterf(samplerName.get(0), GL_TEXTURE_MIN_LOD, -1000.f);
        gl4.glSamplerParameterf(samplerName.get(0), GL_TEXTURE_MAX_LOD, 1000.f);
        gl4.glSamplerParameterf(samplerName.get(0), GL_TEXTURE_LOD_BIAS, 0.0f);
        gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_COMPARE_MODE, GL_NONE);
        gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);

        BufferUtils.destroyDirectBuffer(borderColor);

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

示例3: initBuffer

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

        gl4.glGenBuffers(Buffer.MAX, bufferName);

        gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
        ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
        gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
        BufferUtils.destroyDirectBuffer(elementBuffer);
        gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

        gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
        FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
        gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
        BufferUtils.destroyDirectBuffer(vertexBuffer);
        gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);

        int[] uniformBufferOffset = {0};
        gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset, 0);
        int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset[0]);

        gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
        gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
        gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);

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

示例4: initVertexBuffer

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

        ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
        FloatBuffer positionBuffer = GLBuffers.newDirectFloatBuffer(positionData);

        // Generate a buffer object
        gl4.glGenBuffers(Buffer.MAX, bufferName);

        gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
        gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
        gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

        gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.F32));
        gl4.glBufferData(GL_ARRAY_BUFFER, positionSize, positionBuffer, GL_STATIC_DRAW);
        gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);

        BufferUtils.destroyDirectBuffer(elementBuffer);
        BufferUtils.destroyDirectBuffer(positionBuffer);

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

示例5: initBuffer

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

        ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
        FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);

        gl4.glGenBuffers(Buffer.MAX, bufferName);

        gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
        gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
        gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

        gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
        gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
        gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);

        gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
        gl4.glBufferData(GL_UNIFORM_BUFFER, Mat4.SIZE, null, GL_DYNAMIC_DRAW);
        gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);

        BufferUtils.destroyDirectBuffer(elementBuffer);
        BufferUtils.destroyDirectBuffer(vertexBuffer);

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

示例6: getVertexBuffer

import com.jogamp.opengl.util.GLBuffers; //导入方法依赖的package包/类
private FloatBuffer getVertexBuffer(float radius, short rings, short sectors) {

        float R = 1f / (float) (rings - 1);
        float S = 1f / (float) (sectors - 1);
        short r, s;
        float x, y, z;

        FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(rings * sectors * (3 + 2));

        for (r = 0; r < rings; r++) {

            for (s = 0; s < sectors; s++) {

                x = glm.cos(2 * (float) glm.pi * s * S) * glm.sin((float) glm.pi * r * R);
                y = glm.sin(-(float) glm.pi / 2 + (float) glm.pi * r * R);
                z = glm.sin(2 * (float) glm.pi * s * S) * glm.sin((float) glm.pi * r * R);
                // positions
                vertexBuffer.put(x * radius);
                vertexBuffer.put(y * radius);
                vertexBuffer.put(z * radius);
                // texture coordinates
                vertexBuffer.put(1 - s * S);
                vertexBuffer.put(r * R);
            }
        }
        vertexBuffer.position(0);

        return vertexBuffer;
    }
 
开发者ID:java-opengl-labs,项目名称:hello-triangle,代码行数:30,代码来源:HelloGlobe.java

示例7: initTextureMaps

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

        try {
            BufferedImage bufferedImage = ImageIO.read(new File(TEXTURE_PATH));
            byte[] dataBytes = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData();
            ByteBuffer bufferedImageBuffer = GLBuffers.newDirectByteBuffer(dataBytes);

            gl4.glGenTextures(1, textureName);
            gl4.glActiveTexture(GL_TEXTURE0);
            gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(0));

            gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, bufferedImage.getWidth(), bufferedImage.getHeight(), 0,
                    GL_RGB, GL_UNSIGNED_BYTE, bufferedImageBuffer);

            gl4.glGenerateMipmap(GL_TEXTURE_2D);

            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

            FloatBuffer maxAnis = GLBuffers.newDirectFloatBuffer(1);
            gl4.glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, maxAnis);
            gl4.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnis.get(0));

            gl4.glBindTexture(GL_TEXTURE_2D, 0);

            BufferUtils.destroyDirectBuffer(maxAnis);
            BufferUtils.destroyDirectBuffer(bufferedImageBuffer);

        } catch (IOException ex) {
            Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);
        }
        return true;
    }
 
开发者ID:java-opengl-labs,项目名称:jogl-hello-vr,代码行数:36,代码来源:Scene.java

示例8: initTexture

import com.jogamp.opengl.util.GLBuffers; //导入方法依赖的package包/类
private void initTexture(GL4 gl4, RenderModel_TextureMap_t diffuseTexture) {

        // create and populate the texture
        gl4.glGenTextures(1, textureName);
        gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(0));

        ByteBuffer buffer = GLBuffers.newDirectByteBuffer(diffuseTexture.dataSize());
        byte[] data = diffuseTexture.rubTextureMapData.getByteArray(0, diffuseTexture.dataSize());

        IntStreamEx.range(diffuseTexture.dataSize()).forEach(i -> buffer.put(i, data[i]));

        gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, diffuseTexture.unWidth, diffuseTexture.unHeight,
                0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

        // If this renders black ask McJohn what's wrong.
        gl4.glGenerateMipmap(GL_TEXTURE_2D);

        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

        FloatBuffer largest = GLBuffers.newDirectFloatBuffer(1);
        gl4.glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, largest);
        gl4.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest.get(0));

        gl4.glBindTexture(GL_TEXTURE_2D, 0);

        BufferUtils.destroyDirectBuffer(buffer);
        BufferUtils.destroyDirectBuffer(largest);
    }
 
开发者ID:java-opengl-labs,项目名称:jogl-hello-vr,代码行数:32,代码来源:Model.java

示例9: begin

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

    GL4 gl4 = (GL4) gl;

    boolean validated = true;

    FloatBuffer data = GLBuffers.newDirectFloatBuffer(1);
    gl4.glGetFloatv(GL_MIN_FRAGMENT_INTERPOLATION_OFFSET, data);
    System.out.println("GL_MIN_FRAGMENT_INTERPOLATION_OFFSET: " + data.get(0));
    gl4.glGetFloatv(GL_MAX_FRAGMENT_INTERPOLATION_OFFSET, data);
    System.out.println("GL_MAX_FRAGMENT_INTERPOLATION_OFFSET: " + data.get(0));
    gl4.glGetFloatv(GL_FRAGMENT_INTERPOLATION_OFFSET_BITS, data);
    System.out.println("GL_FRAGMENT_INTERPOLATION_OFFSET_BITS: " + data.get(0));
    BufferUtils.destroyDirectBuffer(data);

    if (validated) {
        validated = initProgram(gl4);
    }
    if (validated) {
        validated = initBuffer(gl4);
    }
    if (validated) {
        validated = initVertexArray(gl4);
    }
    if (validated) {
        validated = initTexture(gl4);
    }
    if (validated) {
        validated = initFramebuffer(gl4);
    }

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

示例10: initBuffer

import com.jogamp.opengl.util.GLBuffers; //导入方法依赖的package包/类
private boolean initBuffer(GL3 gl3) {

        ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
        FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
        IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);

        gl3.glGenBuffers(Buffer.MAX, bufferName);

        gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
        gl3.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
        gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

        gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
        gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
        gl3.glBindBuffer(GL_ARRAY_BUFFER, 0);

        gl3.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
        int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));

        gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
        gl3.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
        gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0);

        BufferUtils.destroyDirectBuffer(elementBuffer);
        BufferUtils.destroyDirectBuffer(vertexBuffer);

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

示例11: initSampler

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

        gl4.glGenSamplers(Pipeline.MAX, samplerName, 0);
        FloatBuffer borderColorBuffer=GLBuffers.newDirectFloatBuffer(new float[]{0.0f, 0.0f, 0.0f, 0.0f});

        gl4.glSamplerParameteri(samplerName[Pipeline.RENDER], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
        gl4.glSamplerParameteri(samplerName[Pipeline.RENDER], GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        gl4.glSamplerParameteri(samplerName[Pipeline.RENDER], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        gl4.glSamplerParameteri(samplerName[Pipeline.RENDER], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        gl4.glSamplerParameteri(samplerName[Pipeline.RENDER], GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
        gl4.glSamplerParameterfv(samplerName[Pipeline.RENDER], GL_TEXTURE_BORDER_COLOR, borderColorBuffer);
        gl4.glSamplerParameterf(samplerName[Pipeline.RENDER], GL_TEXTURE_MIN_LOD, -1000.f);
        gl4.glSamplerParameterf(samplerName[Pipeline.RENDER], GL_TEXTURE_MAX_LOD, 1000.f);
        gl4.glSamplerParameterf(samplerName[Pipeline.RENDER], GL_TEXTURE_LOD_BIAS, 0.0f);
        gl4.glSamplerParameteri(samplerName[Pipeline.RENDER], GL_TEXTURE_COMPARE_MODE, GL_NONE);
        gl4.glSamplerParameteri(samplerName[Pipeline.RENDER], GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);

        gl4.glSamplerParameteri(samplerName[Pipeline.SPLASH], GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        gl4.glSamplerParameteri(samplerName[Pipeline.SPLASH], GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        gl4.glSamplerParameteri(samplerName[Pipeline.SPLASH], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        gl4.glSamplerParameteri(samplerName[Pipeline.SPLASH], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        gl4.glSamplerParameteri(samplerName[Pipeline.SPLASH], GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
        gl4.glSamplerParameterfv(samplerName[Pipeline.SPLASH], GL_TEXTURE_BORDER_COLOR, borderColorBuffer);
        gl4.glSamplerParameterf(samplerName[Pipeline.SPLASH], GL_TEXTURE_MIN_LOD, -1000.f);
        gl4.glSamplerParameterf(samplerName[Pipeline.SPLASH], GL_TEXTURE_MAX_LOD, 1000.f);
        gl4.glSamplerParameterf(samplerName[Pipeline.SPLASH], GL_TEXTURE_LOD_BIAS, 0.0f);
        gl4.glSamplerParameteri(samplerName[Pipeline.SPLASH], GL_TEXTURE_COMPARE_MODE, GL_NONE);
        gl4.glSamplerParameteri(samplerName[Pipeline.SPLASH], GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
        
        BufferUtils.destroyDirectBuffer(borderColorBuffer);

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

示例12: initBuffer

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

        boolean validated = true;

        ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
        FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);

        gl4.glGenBuffers(Buffer.MAX, bufferName);

        gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
        gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
        gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

        gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
        gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
        gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);

        IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);
        gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
        int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));

        gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
        gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
        gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);

        BufferUtils.destroyDirectBuffer(elementBuffer);
        BufferUtils.destroyDirectBuffer(vertexBuffer);
        BufferUtils.destroyDirectBuffer(uniformBufferOffset);

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

示例13: initBuffer

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

        ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
        FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
        IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);

        gl4.glGenBuffers(Buffer.MAX, bufferName);

        gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
        gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
        gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

        gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
        gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
        gl4.glBindBuffer(GL_ARRAY_BUFFER, 0);

        gl4.glGetIntegerv(
                GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
                uniformBufferOffset);

        int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));

        gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
        gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
        gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);

        BufferUtils.destroyDirectBuffer(elementBuffer);
        BufferUtils.destroyDirectBuffer(vertexBuffer);
        BufferUtils.destroyDirectBuffer(uniformBufferOffset);

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

示例14: initBuffer

import com.jogamp.opengl.util.GLBuffers; //导入方法依赖的package包/类
private boolean initBuffer(GL3 gl3) {

        ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
        FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(VertexData);
        IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);

        gl3.glGenBuffers(Buffer.MAX, bufferName);

        gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
        gl3.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
        gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

        gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
        gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
        gl3.glBindBuffer(GL_ARRAY_BUFFER, 0);

        gl3.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
        int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));

        gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
        gl3.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
        gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0);

        BufferUtils.destroyDirectBuffer(elementBuffer);
        BufferUtils.destroyDirectBuffer(vertexBuffer);
        BufferUtils.destroyDirectBuffer(uniformBufferOffset);

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

示例15: initBuffer

import com.jogamp.opengl.util.GLBuffers; //导入方法依赖的package包/类
private boolean initBuffer(GL3 gl3) {

        ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData);
        FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
        IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1);

        gl3.glGenBuffers(Buffer.MAX, bufferName);

        gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
        gl3.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW);
        gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

        gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
        gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW);
        gl3.glBindBuffer(GL_ARRAY_BUFFER, 0);

        gl3.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset);
        int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0));

        gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
        gl3.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW);
        gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0);

        BufferUtils.destroyDirectBuffer(elementBuffer);
        BufferUtils.destroyDirectBuffer(vertexBuffer);
        BufferUtils.destroyDirectBuffer(uniformBufferOffset);

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


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