Example usage for org.lwjgl.opengl GL15 glGetBufferParameteriv

List of usage examples for org.lwjgl.opengl GL15 glGetBufferParameteriv

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL15 glGetBufferParameteriv.

Prototype

public static void glGetBufferParameteriv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname,
        @NativeType("GLint *") int[] params) 

Source Link

Document

Array version of: #glGetBufferParameteriv GetBufferParameteriv

Usage

From source file:bug1167.lwjgl.java

private void loop() {
    // This line is critical for LWJGL's interoperation with GLFW's
    // OpenGL context, or any context that is managed externally.
    // LWJGL detects the context that is current in the current thread,
    // creates the GLCapabilities instance and makes the OpenGL
    // bindings available for use.
    GL.createCapabilities();//  w  ww  .java  2  s  .c  o m

    for (int i = 0; i < SQRT_BUILDING_COUNT; i++) {

        for (int k = 0; k < SQRT_BUILDING_COUNT; k++) {

            int index = (i * SQRT_BUILDING_COUNT + k) * Integer.BYTES;

            vertexBuffer.position(index);
            GL45.glCreateBuffers(1, vertexBuffer);

            indexBuffer.position(index);
            GL45.glCreateBuffers(1, indexBuffer);

            // Stick the data for the vertices and indices in their respective buffers
            ByteBuffer verticesBuffer = BufferUtils.createByteBuffer(512 * Byte.BYTES);
            GL45.glNamedBufferData(vertexBuffer.getInt(index), verticesBuffer.capacity() * Byte.BYTES,
                    verticesBuffer, GL_STATIC_DRAW);

            ByteBuffer indicesBuffer = BufferUtils.createByteBuffer(6 * Short.BYTES);
            GL45.glNamedBufferData(indexBuffer.getInt(index), indicesBuffer.capacity() * Byte.BYTES,
                    indicesBuffer, GL_STATIC_DRAW);

            // *** INTERESTING ***
            // get the GPU pointer for the vertex buffer and make the vertex buffer resident on the GPU
            GL15.glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.getInt(index));
            NVShaderBufferLoad.glGetBufferParameterui64vNV(GL_ARRAY_BUFFER, GL_BUFFER_GPU_ADDRESS_NV,
                    vertexBufferGPUPtr);
            GL15.glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, vertexBufferSize);
            NVShaderBufferLoad.glMakeBufferResidentNV(GL_ARRAY_BUFFER, GL_READ_ONLY);
            GL15.glBindBuffer(GL_ARRAY_BUFFER, 0);
            // *** INTERESTING ***
            // get the GPU pointer for the index buffer and make the index buffer resident on the GPU
            GL15.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer.getInt(index));
            NVShaderBufferLoad.glGetBufferParameterui64vNV(GL_ELEMENT_ARRAY_BUFFER, GL_BUFFER_GPU_ADDRESS_NV,
                    indexBufferGPUPtr);
            GL15.glGetBufferParameteriv(GL_ELEMENT_ARRAY_BUFFER, GL_BUFFER_SIZE, indexBufferSize);
            NVShaderBufferLoad.glMakeBufferResidentNV(GL_ELEMENT_ARRAY_BUFFER, GL_READ_ONLY);
            GL15.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
        }
    }

    //        for (int i = 0; i < SQRT_BUILDING_COUNT*SQRT_BUILDING_COUNT; i++) {
    //            System.out.println(""+vertexBuffer.getInt(i*Integer.BYTES));
    //        }
    clearColor.rewind();

    // Run the rendering loop until the user has attempted to close
    // the window or has pressed the ESCAPE key.
    while (glfwWindowShouldClose(window) == GLFW_FALSE) {

        glClearColor(1.0f, 0.5f, 0.0f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer

        GL30.glClearBufferfv(GL_COLOR, 0, clearColor);

        glfwSwapBuffers(window); // swap the color buffers

        // Poll for window events. The key callback above will only be
        // invoked during this call.
        glfwPollEvents();

        updateFPS();
    }
}

From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java

License:Apache License

public void glGetBufferParameteriv(int target, int pname, IntBuffer params) {
    GL15.glGetBufferParameteriv(target, pname, params);
}