Java 类org.lwjgl.opengl.GL31 实例源码

项目:ether    文件:FloatUniformBuffer.java   
public void load(BiConsumer<Integer, FloatBuffer> consumer) {
    int stride = stride();

    if (ubo == null)
        ubo = new GLObject(Type.BUFFER);

    if (buffer == null)
        buffer = BufferUtils.createFloatBuffer(size(stride));

    buffer.rewind();
    for (int i = 0; i < blockCount; ++i) {
        buffer.position(i * stride);
        consumer.accept(i, buffer);
    }
    buffer.rewind();
    GL15.glBindBuffer(GL31.GL_UNIFORM_BUFFER, ubo.getId());
    GL15.glBufferData(GL31.GL_UNIFORM_BUFFER, buffer, GL15.GL_STREAM_DRAW);
    GL15.glBindBuffer(GL31.GL_UNIFORM_BUFFER, 0);
}
项目:ether    文件:FloatUniformBuffer.java   
public void load(int blockIndex, Consumer<FloatBuffer> consumer) {
    int stride = stride();

    if (ubo == null) {
        ubo = new GLObject(Type.BUFFER);
        GL15.glBindBuffer(GL31.GL_UNIFORM_BUFFER, ubo.getId());
        GL15.glBufferData(GL31.GL_UNIFORM_BUFFER, size(stride) * 4, GL15.GL_STREAM_DRAW);
        GL15.glBindBuffer(GL31.GL_UNIFORM_BUFFER, 0);
    }

    if (block == null)
        block = BufferUtils.createFloatBuffer(blockSize);

    block.rewind();
    consumer.accept(block);
    block.rewind();
    GL15.glBindBuffer(GL31.GL_UNIFORM_BUFFER, ubo.getId());
    GL15.glBufferSubData(GL31.GL_UNIFORM_BUFFER, blockIndex * stride * 4, block);
    GL15.glBindBuffer(GL31.GL_UNIFORM_BUFFER, 0);
}
项目:Mystic-Bastion    文件:ParticleRenderer.java   
protected void render(Map<ParticleTexture, List<Particle>> particles, Camera camera) {
    Matrix4f viewMatrix = Maths.createViewMatrix(camera);
    prepare();
    for (ParticleTexture texture : particles.keySet()) {
        bindTexture(texture);
        List<Particle> particleList = particles.get(texture);
        pointer = 0;
        float[] vboData = new float[particleList.size() * INSTANCE_DATA_LENGHT];
        for (Particle particle : particleList) {
            updateModelViewMatrix(particle.getPosition(), particle.getRotation(), particle.getScale(), viewMatrix,
                    vboData);
            updateTexCoordInfo(particle, vboData);
        }
        loader.updateVbo(vbo, vboData, buffer);
        GL31.glDrawArraysInstanced(GL11.GL_TRIANGLE_STRIP, 0, quad.getVertexCount(), particleList.size());
    }
    finishRendering();
}
项目:RoboWarsInvasion    文件:CubeRenderer.java   
public void fillColor(int color){
    int r= (color&0xFF000000)>>>24;
    int g= (color&0x00FF0000)>>>16;
    int b= (color&0x0000FF00)>>>8;
    int a= (color&0x000000FF)>>>0;
    buf.clear();
    for(int i=0; i!=maxcubes; i++){
        buf.put((byte)r);
        buf.put((byte)g);
        buf.put((byte)b);
        buf.put((byte)a);
    }
    buf.flip();
    GL15.glBindBuffer(GL31.GL_TEXTURE_BUFFER, colorbuf);
    GL15.glBufferSubData(GL31.GL_TEXTURE_BUFFER, 0, buf);
}
项目:Lwjgl3-Game-Engine-Programming-Series    文件:CoreEngine.java   
private void getDeviceProperties(){
    System.out.println("OpenGL version: " + GL11.glGetString(GL11.GL_VERSION) + " bytes");
    System.out.println("Max Geometry Uniform Blocks: " + GL31.GL_MAX_GEOMETRY_UNIFORM_BLOCKS+ " bytes");
    System.out.println("Max Geometry Shader Invocations: " + GL40.GL_MAX_GEOMETRY_SHADER_INVOCATIONS + " bytes");
    System.out.println("Max Uniform Buffer Bindings: " + GL31.GL_MAX_UNIFORM_BUFFER_BINDINGS + " bytes");
    System.out.println("Max Uniform Block Size: " + GL31.GL_MAX_UNIFORM_BLOCK_SIZE + " bytes");
    System.out.println("Max SSBO Block Size: " + GL43.GL_MAX_SHADER_STORAGE_BLOCK_SIZE + " bytes");     
}
项目:Visage    文件:Errors.java   
private static void buildMapping() {
    if (mapping != null) return;
    Multimap<Integer, String> map = HashMultimap.create();
    List<Class<?>> classes = ImmutableList.of(
            GL11.class, GL12.class, GL13.class, GL14.class, GL15.class,
            GL20.class, GL21.class, GL30.class, GL31.class, GL32.class,
            GL33.class, GL40.class, GL41.class, GL42.class, GL43.class,
            GL44.class, GL45.class, GLFW.class
            );
    for (Class<?> clazz : classes) {
        for (Field f : clazz.getDeclaredFields()) {
            if (f.getName().toUpperCase(Locale.ROOT).equals(f.getName()) &&
                    f.getType() == int.class && Modifier.isPublic(f.getModifiers()) && Modifier.isStatic(f.getModifiers())) {
                List<String> li = Splitter.on('_').splitToList(f.getName());
                li = li.subList(1, li.size());
                String clean =
                    Joiner.on(' ').join(
                        li.stream()
                            .map(Errors::toTitleCase)
                            .iterator());
                try {
                    map.put(f.getInt(null), clean);
                } catch (Throwable t) {
                    t.printStackTrace();
                }
            }
        }
    }
    mapping = map;
}
项目:oreon-engine    文件:GLRenderEngine.java   
private void getDeviceProperties(){
    System.out.println("OpenGL version: " + GL11.glGetString(GL11.GL_VERSION) + " bytes");
    System.out.println("Max Geometry Uniform Blocks: " + GL11.glGetInteger(GL31.GL_MAX_GEOMETRY_UNIFORM_BLOCKS));
    System.out.println("Max Geometry Shader Invocations: " + GL11.glGetInteger(GL40.GL_MAX_GEOMETRY_SHADER_INVOCATIONS));
    System.out.println("Max Uniform Buffer Bindings: " + GL11.glGetInteger(GL31.GL_MAX_UNIFORM_BUFFER_BINDINGS));
    System.out.println("Max Uniform Block Size: " + GL11.glGetInteger(GL31.GL_MAX_UNIFORM_BLOCK_SIZE) + " bytes");
    System.out.println("Max SSBO Block Size: " + GL11.glGetInteger(GL43.GL_MAX_SHADER_STORAGE_BLOCK_SIZE) + " bytes");  
    System.out.println("Max Image Bindings: " + GL11.glGetInteger(GL42.GL_MAX_IMAGE_UNITS));
}
项目:LWJGL-OpenGL-Utils    文件:RenderUtils.java   
public static void glDrawArraysInstanced(int mode, int first, int count, int primcount) {
    if(GL_VERSION >= 31) {
        GL31.glDrawArraysInstanced(mode, first, count, primcount);
    }
    else if(GLContext.getCapabilities().GL_ARB_draw_instanced) {
        ARBDrawInstanced.glDrawArraysInstancedARB(mode, first, count, primcount);
    }
    else {
        throw new UnsupportedOperationException("GL_ARB_draw_instanced not supported on this system.");
    }
}
项目:LWJGL-OpenGL-Utils    文件:RenderUtils.java   
public static void glDrawElementsInstanced(int mode, int indices_count, int type, long indices_buffer_offset, int primcount) {
    if(GL_VERSION >= 31) {
        GL31.glDrawElementsInstanced(mode, indices_count, type, indices_buffer_offset, primcount);
    }
    else if(GLContext.getCapabilities().GL_ARB_draw_instanced) {
        ARBDrawInstanced.glDrawElementsInstancedARB(mode, indices_count, type, indices_buffer_offset, primcount);
    }
    else {
        throw new UnsupportedOperationException("GL_ARB_draw_instanced not supported on this system.");
    }
}
项目:RoboWarsInvasion    文件:CubeRenderer.java   
/**Must only be constructed from render thread*/
public CubeRenderer(int maxcubes){
    this.maxcubes= maxcubes;
    if(buf.capacity()<maxcubes*POS_SIZE){
        buf= BufferUtils.createByteBuffer(maxcubes*POS_SIZE);
    }

    //buffer texture buffer allocation
    posbuf= GL15.glGenBuffers();
    GL15.glBindBuffer(GL31.GL_TEXTURE_BUFFER, posbuf);
    GL15.glBufferData(GL31.GL_TEXTURE_BUFFER, maxcubes*POS_SIZE, GL15.GL_DYNAMIC_DRAW);

    colorbuf= GL15.glGenBuffers();
    GL15.glBindBuffer(GL31.GL_TEXTURE_BUFFER, colorbuf);
    GL15.glBufferData(GL31.GL_TEXTURE_BUFFER, maxcubes*4, GL15.GL_DYNAMIC_DRAW);

    GL15.glBindBuffer(GL31.GL_TEXTURE_BUFFER, 0);

    //buffer texture setup
    GL11.glPushAttrib(GL11.GL_TEXTURE_BIT);

    postex= GL11.glGenTextures();
    GL11.glBindTexture(GL31.GL_TEXTURE_BUFFER, postex);
    GL31.glTexBuffer(GL31.GL_TEXTURE_BUFFER, GL30.GL_R32F, posbuf);

    colortex= GL11.glGenTextures();
    GL11.glBindTexture(GL31.GL_TEXTURE_BUFFER, colortex);
    GL31.glTexBuffer(GL31.GL_TEXTURE_BUFFER, GL11.GL_RGBA8, colorbuf);

    GL11.glBindTexture(GL31.GL_TEXTURE_BUFFER, 0);




    GL11.glPopAttrib();
}
项目:RoboWarsInvasion    文件:CubeRenderer.java   
public void render(float[] particles, byte[] colors){       
    if(particles.length/POS_SIZE>maxcubes){
        return;
    }

    GL11.glPushAttrib(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glPushAttrib(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL20.glUseProgram(program);

    ShaderUtil.useLegacyMVP(ulocmvp);
    GL20.glUniform1f(ulocscale, scale/2);

    pushPositions(particles);
    if(colors!=null)
        pushColors(colors);

    GL11.glPushAttrib(GL11.GL_TEXTURE);
    GL13.glActiveTexture(GL13.GL_TEXTURE1);
    GL11.glBindTexture(GL31.GL_TEXTURE_BUFFER, colortex);
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL31.GL_TEXTURE_BUFFER, postex);

    GL30.glBindVertexArray(VAO);
    GL31.glDrawElementsInstanced(GL11.GL_TRIANGLES, INDICIES.length, GL11.GL_UNSIGNED_BYTE, 0, particles.length/3);
    GL30.glBindVertexArray(0);

    GL20.glUseProgram(0);

    GL11.glPopAttrib();
    GL11.glPopAttrib();
    GL11.glPopAttrib();
}
项目:RoboWarsInvasion    文件:CubeRenderer.java   
public void pushPositions(float[] positions){
    buf.clear();
    FloatBuffer fbuf= buf.asFloatBuffer();
    fbuf.put(positions);
    fbuf.flip();
    GL15.glBindBuffer(GL31.GL_TEXTURE_BUFFER, posbuf);
    GL15.glBufferSubData(GL31.GL_TEXTURE_BUFFER, 0, fbuf);
}
项目:RoboWarsInvasion    文件:CubeRenderer.java   
public void pushColors(byte[] colors){
    buf.clear();
    buf.put(colors);
    buf.flip();
    GL15.glBindBuffer(GL31.GL_TEXTURE_BUFFER, colorbuf);
    GL15.glBufferSubData(GL31.GL_TEXTURE_BUFFER, 0, buf);   
}
项目:JCaelum    文件:GL3.java   
public static String glGetActiveUniformBlockName(int program, int uniformBlockIndex, int bufSize) throws GLException
{
    String ret = GL31.glGetActiveUniformBlockName(program, uniformBlockIndex, bufSize);

    RenderHelper.checkForGLError();

    return ret;
}
项目:JCaelum    文件:GL3.java   
public static String glGetActiveUniformName(int program, int uniformIndex, int bufSize) throws GLException
{
    String ret = GL31.glGetActiveUniformName(program, uniformIndex, bufSize);

    RenderHelper.checkForGLError();

    return ret;
}
项目:JCaelum    文件:GL3.java   
public static int glGetActiveUniformsi(int program, int uniformIndex, int pname) throws GLException
{
    int ret = GL31.glGetActiveUniformsi(program, uniformIndex, pname);

    RenderHelper.checkForGLError();

    return ret;
}
项目:JCaelum    文件:GL3.java   
public static int glGetUniformBlockIndex(int program, String uniformBlockName) throws GLException
{
    int ret = GL31.glGetUniformBlockIndex(program, uniformBlockName);

    RenderHelper.checkForGLError();

    return ret;
}
项目:LoneLib    文件:ColorCubeMesh.java   
@Override
public void render() {
    // render the mesh
    // Assumes that the proper shaderProgram is already active and that the model positions has already been uploaded to the shader
    vao.assign();
    indexBuffer.assign();
    GL11.glEnable(GL31.GL_PRIMITIVE_RESTART);
    GL31.glPrimitiveRestartIndex(RESET_INDEX);
    GL11.glDrawElements(GL11.GL_TRIANGLE_STRIP, numIndices, GL11.GL_UNSIGNED_INT, 0);
}
项目:gl3DGE    文件:NodeBasedShader.java   
public static void updateUBO(Scene scene){
    ArrayList<Float> array = new ArrayList<Float>();
    for (String k : ubo.getUniforms().keySet()){
        if (k.equals(ShaderNodeValue.UNIFORM_LIGHT_UBO_STRUCT)){
            ArraySNV a = (ArraySNV) ubo.getUniforms().get(k);
            std140Pad(array, a);

            int lightStructLength = 0;
            for (int i = 0; i < a.getLength(); i++){
                if (i < scene.getLights().size()){
                    Light l = scene.getLights().get(i);
                    StructureSNV struct = (StructureSNV) a.getValue();
                    std140Pad(array, struct);
                    lightStructLength = array.size();
                    for (String key : struct.getStruct().getValues().keySet()){
                        ShaderNodeValue snv = struct.getStruct().getValues().get(key);
                        std140Pad(array, snv);

                        if (key.equals(ShaderNodeValue.UNIFORM_LIGHT_UBO_POSITION)){
                            array.add(l.getPos().x);
                            array.add(l.getPos().y);
                            array.add(l.getPos().z);
                        }
                        else if (key.equals(ShaderNodeValue.UNIFORM_LIGHT_UBO_COLOR)){
                            array.add(l.getColor().x);
                            array.add(l.getColor().y);
                            array.add(l.getColor().z);
                        }
                        else if (key.equals(ShaderNodeValue.UNIFORM_LIGHT_UBO_POWER)){
                            array.add(l.getPower());
                        }
                    }
                    lightStructLength = array.size() - lightStructLength;
                }
                else {
                    for (int n = 0; n < lightStructLength; n++)
                        array.add((float) 0);
                }
            }
        }
        else if (k.equals(ShaderNodeValue.UNIFORM_LIGHT_UBO_NUMBER)){
            array.add((float) scene.getLights().size());
        }
    }
    FloatBuffer fb = BufferUtils.createFloatBuffer(array.size());
    for (float f : array)
        fb.put(f);
    fb.flip();
    ubo.getUBO().bind();
    //GL15.glBufferSubData(GL31.GL_UNIFORM_BUFFER, 0, fb);
    GL15.glBufferData(GL31.GL_UNIFORM_BUFFER, fb, GL15.GL_DYNAMIC_DRAW);
    ubo.getUBO().unbind();
}
项目:gl3DGE    文件:UniformBufferObject.java   
public void bindBufferBase(int binding){
    this.binding = binding;
    glBindBufferBase(GL31.GL_UNIFORM_BUFFER, binding, id);
}
项目:ether    文件:Program.java   
public int getUniformBlockIndex(String name) {
    return GL31.glGetUniformBlockIndex(programObject.getId(), name);
}
项目:ether    文件:Program.java   
public void bindUniformBlock(int index, int bindingPoint) {
    GL31.glUniformBlockBinding(programObject.getId(), index, bindingPoint);
}
项目:ether    文件:FloatUniformBuffer.java   
public void bind() {
    GL30.glBindBufferBase(GL31.GL_UNIFORM_BUFFER, bindingPoint, ubo.getId());
}
项目:ether    文件:FloatUniformBuffer.java   
public void bind(int blockIndex) {
    GL30.glBindBufferRange(GL31.GL_UNIFORM_BUFFER, bindingPoint, ubo.getId(), blockIndex * stride() * 4, blockSize * 4);
}
项目:gdx-backend-jglfw    文件:JglfwGL30.java   
@Override
public void glCopyBufferSubData (int readTarget, int writeTarget, int readOffset, int writeOffset, int size) {
    GL31.glCopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
}
项目:gdx-backend-jglfw    文件:JglfwGL30.java   
@Override
public void glGetUniformIndices (int program, String[] uniformNames, IntBuffer uniformIndices) {
    GL31.glGetUniformIndices(program, uniformNames, uniformIndices);
}
项目:gdx-backend-jglfw    文件:JglfwGL30.java   
@Override
public void glGetActiveUniformsiv (int program, int uniformCount, IntBuffer uniformIndices, int pname, IntBuffer params) {
    GL31.glGetActiveUniformsiv(program, uniformIndices, pname, params);
}
项目:gdx-backend-jglfw    文件:JglfwGL30.java   
@Override
public int glGetUniformBlockIndex (int program, String uniformBlockName) {
    return GL31.glGetUniformBlockIndex(program, uniformBlockName);
}
项目:gdx-backend-jglfw    文件:JglfwGL30.java   
@Override
public void glGetActiveUniformBlockiv (int program, int uniformBlockIndex, int pname, IntBuffer params) {
    params.put(GL31.glGetActiveUniformBlocki(program, uniformBlockIndex, pname));
}
项目:gdx-backend-jglfw    文件:JglfwGL30.java   
@Override
public void glGetActiveUniformBlockName (int program, int uniformBlockIndex, Buffer length, Buffer uniformBlockName) {
    GL31.glGetActiveUniformBlockName(program, uniformBlockIndex, (IntBuffer)length, (ByteBuffer)uniformBlockName);
}
项目:gdx-backend-jglfw    文件:JglfwGL30.java   
@Override
public String glGetActiveUniformBlockName (int program, int uniformBlockIndex) {
    return GL31.glGetActiveUniformBlockName(program, uniformBlockIndex, 1024);
}
项目:gdx-backend-jglfw    文件:JglfwGL30.java   
@Override
public void glUniformBlockBinding (int program, int uniformBlockIndex, int uniformBlockBinding) {
    GL31.glUniformBlockBinding(program, uniformBlockIndex, uniformBlockBinding);
}
项目:gdx-backend-jglfw    文件:JglfwGL30.java   
@Override
public void glDrawArraysInstanced (int mode, int first, int count, int instanceCount) {
    GL31.glDrawArraysInstanced(mode, first, count, instanceCount);
}
项目:gdx-backend-jglfw    文件:JglfwGL30.java   
@Override
public void glDrawElementsInstanced (int mode, int count, int type, int indicesOffset, int instanceCount) {
    GL31.glDrawElementsInstanced(mode, count, type, indicesOffset, instanceCount);

}
项目:gl3DGE    文件:NodeBasedShader.java   
public static void updateUBO(Scene scene){
    ArrayList<Float> array = new ArrayList<Float>();
    for (String k : ubo.getUniforms().keySet()){
        if (k.equals(ShaderNodeValue.UNIFORM_LIGHT_UBO_STRUCT)){
            ArraySNV a = (ArraySNV) ubo.getUniforms().get(k);
            std140Pad(array, a);

            int lightStructLength = 0;
            for (int i = 0; i < a.getLength(); i++){
                if (i < scene.getLights().size()){
                    Light l = scene.getLights().get(i);
                    StructureSNV struct = (StructureSNV) a.getValue();
                    std140Pad(array, struct);
                    lightStructLength = array.size();
                    for (String key : struct.getStruct().getValues().keySet()){
                        ShaderNodeValue snv = struct.getStruct().getValues().get(key);
                        std140Pad(array, snv);

                        if (key.equals(ShaderNodeValue.UNIFORM_LIGHT_UBO_POSITION)){
                            array.add(l.getPos().x);
                            array.add(l.getPos().y);
                            array.add(l.getPos().z);
                        }
                        else if (key.equals(ShaderNodeValue.UNIFORM_LIGHT_UBO_COLOR)){
                            array.add(l.getColor().x);
                            array.add(l.getColor().y);
                            array.add(l.getColor().z);
                        }
                        else if (key.equals(ShaderNodeValue.UNIFORM_LIGHT_UBO_POWER)){
                            array.add(l.getPower());
                        }
                    }
                    lightStructLength = array.size() - lightStructLength;
                }
                else {
                    for (int n = 0; n < lightStructLength; n++)
                        array.add((float) 0);
                }
            }
        }
        else if (k.equals(ShaderNodeValue.UNIFORM_LIGHT_UBO_NUMBER)){
            array.add((float) scene.getLights().size());
        }
    }
    FloatBuffer fb = BufferUtils.createFloatBuffer(array.size());
    for (float f : array)
        fb.put(f);
    fb.flip();
    ubo.getUBO().bind();
    //GL15.glBufferSubData(GL31.GL_UNIFORM_BUFFER, 0, fb);
    GL15.glBufferData(GL31.GL_UNIFORM_BUFFER, fb, GL15.GL_DYNAMIC_DRAW);
    ubo.getUBO().unbind();
}
项目:gl3DGE    文件:UniformBufferObject.java   
public void bindBufferBase(int binding){
    this.binding = binding;
    glBindBufferBase(GL31.GL_UNIFORM_BUFFER, binding, id);
}
项目:CubeEngine    文件:GLH.java   
public static void glhDrawArraysInstanced(int mode, int first, int count, int primcount) {
    GL31.glDrawArraysInstanced(mode, first, count, primcount);
    theContext.incrementDrawCalls();
    theContext.increaseVerticesDrawn(3 * count);
}
项目:libgdxcn    文件:LwjglGL30.java   
@Override
public void glCopyBufferSubData (int readTarget, int writeTarget, int readOffset, int writeOffset, int size) {
    GL31.glCopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
}
项目:libgdxcn    文件:LwjglGL30.java   
@Override
public void glGetUniformIndices (int program, String[] uniformNames, IntBuffer uniformIndices) {
    GL31.glGetUniformIndices(program, uniformNames, uniformIndices);
}
项目:libgdxcn    文件:LwjglGL30.java   
@Override
public void glGetActiveUniformsiv (int program, int uniformCount, IntBuffer uniformIndices, int pname, IntBuffer params) {
    GL31.glGetActiveUniforms(program, uniformIndices, pname, params);
}