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

项目:MC-Ray-Tracer    文件:WorldLoader.java   
private void initializeWorld(int renderDistance, int centerX, int centerY, int centerZ, Shader shader) {

    playerChunkX = centerX;
    playerChunkZ = centerZ;

    //initialize the world
    worldChunks = new int[(renderDistance*2-1)*16*(renderDistance*2-1)];
    worldMetadata = new int[(renderDistance*2-1)*16*(renderDistance*2-1)];
    chunkIdList = new ArrayDeque<Integer>();
    metadataIdList = new ArrayDeque<Integer>();
    for (int i = worldChunks.length; i > 0; i--) {
        chunkIdList.push(i);
    }
    for (int i = worldMetadata.length; i > 0; i--) {
        metadataIdList.push(i);
    }

    //update the buffer size
    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, shader.getChunkSsbo());
    GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, chunkSize*worldChunks.length*2*4, GL15.GL_DYNAMIC_DRAW);

    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, shader.getMetadataSsbo());
    GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, chunkSize*worldMetadata.length*4, GL15.GL_DYNAMIC_DRAW);
    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);

    //inform the shader of the new render distance
    int renderDistanceUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "renderDistance");
    GL20.glUniform1i(renderDistanceUniform, renderDistance-1);
}
项目:MC-Ray-Tracer    文件:WorldLoader.java   
private void loadChunk(int id, Shader shader, ExtendedBlockStorage storage) {
    ObjectIntIdentityMap<IBlockState> map = GameData.getBlockStateIDMap();
    int[] data = new int[chunkSize*2];
    for (int y = 0; y < 16; y++) {
        for (int z = 0; z < 16; z++) {
            for (int x = 0; x < 16; x++) {
                IBlockState state = storage.get(x, y, z);
                boolean fullBlock = state.isFullBlock();
                boolean cube = state.isFullCube();
                if (fullBlock != cube) {
                    Log.info(state.getBlock().getUnlocalizedName() + ": " + fullBlock);
                }
                if (fullBlock) {
                    stateSet.add(state);
                }
                int stateId = map.get(state); //TODO
                data[(y<<9) + (z<<5) + (x<<1)] = Block.getIdFromBlock(storage.get(x, y, z).getBlock());
            }
        }
    }

    for (int y = 0; y < 16; y++) {
        for (int z = 0; z < 16; z++) {
            for (int x = 0; x < 16; x++) {
                data[(y<<9) + (z<<5) + (x<<1) + 1] = storage.getBlocklightArray().get(x, y, z);
            }
        }
    }

    IntBuffer buffer = BufferUtils.createIntBuffer(chunkSize*2);
    buffer.put(data);
    buffer.flip();
    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, shader.getChunkSsbo());
    GL15.glBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, (id-1)*chunkSize*2*4, buffer);
    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
}
项目:MC-Ray-Tracer    文件:WorldLoader.java   
/**
 * 
 * @param id
 * @param shader
 * @param storage
 * @return true if the id was used, false if there was nothing to upload
 */
private boolean loadMetadata(int id, Shader shader, ExtendedBlockStorage storage) {
    int[] data = new int[chunkSize];
    boolean containsValues = false;
    for (int y = 0; y < 16; y++) {
        for (int z = 0; z < 16; z++) {
            for (int x = 0; x < 16; x++) {
                int metadata = storage.get(x, y, z).getBlock().getMetaFromState(storage.get(x, y, z));
                data[(y<<8) + (z<<4) + x] = metadata;
                if (metadata != 0) {
                    containsValues = true;
                }
            }
        }
    }

    if (containsValues) {
        IntBuffer buffer = BufferUtils.createIntBuffer(chunkSize);
        buffer.put(data);
        buffer.flip();
        GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, shader.getMetadataSsbo());
        GL15.glBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, (id-1)*chunkSize*4, buffer);
        GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
    }

    return containsValues;
}
项目: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");     
}
项目:warp    文件:Texture2D.java   
public void copy(Texture2D src) {
    this.type = src.type;
    this.format = src.format;
    this.internalformat = src.internalformat;
    this.height = src.height;
    this.width = src.width;
    this.mipmap = src.mipmap;
    bind();
    glTexImage2D(this.type, 0, this.getInternalformat(), this.getWidth(), this.getHeight(), 0, this.getFormat(), GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
    GL43.glCopyImageSubData(src.getTexture(), src.getType(), 0, 0, 0, 0, this.texture, this.type, 0, 0, 0, 0, src.getWidth(), src.getHeight(), 1);
    if (mipmap) genMipmap();
}
项目: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));
}
项目:MC-Ray-Tracer    文件:Shader.java   
public void createShaderProgram() {
    shaderProgram = GL20.glCreateProgram();
    vShader = createShader(vertexShader, GL20.GL_VERTEX_SHADER);
    fShader = createShader(fragmentShader, GL20.GL_FRAGMENT_SHADER);

    GL20.glAttachShader(shaderProgram, vShader);
    GL20.glAttachShader(shaderProgram, fShader);
    GL20.glBindAttribLocation(shaderProgram, 0, "vertex");
    GL30.glBindFragDataLocation(shaderProgram, 0, "color");
    GL20.glLinkProgram(shaderProgram);

    GL20.glDetachShader(shaderProgram, vShader);
    GL20.glDetachShader(shaderProgram, fShader);
    GL20.glDeleteShader(vShader);
    vShader = 0;
    GL20.glDeleteShader(fShader);
    fShader = 0;

    int linked = GL20.glGetProgrami(shaderProgram, GL20.GL_LINK_STATUS);
    String programLog = GL20.glGetProgramInfoLog(shaderProgram, GL20.glGetProgrami(shaderProgram, GL20.GL_INFO_LOG_LENGTH));
    if (programLog.trim().length() > 0) {
        System.err.println(programLog);
    }
    if (linked == 0) {
        throw new AssertionError("Could not link program");
    }

    //init vbo
    vbo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
    ByteBuffer bb = BufferUtils.createByteBuffer(2 * 6);
    bb.put((byte) -1).put((byte) -1);
    bb.put((byte) 1).put((byte) -1);
    bb.put((byte) 1).put((byte) 1);
    bb.put((byte) 1).put((byte) 1);
    bb.put((byte) -1).put((byte) 1);
    bb.put((byte) -1).put((byte) -1);
    bb.flip();
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, bb, GL15.GL_STATIC_DRAW);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

    worldChunkSsbo = GL15.glGenBuffers();
    chunkSsbo = GL15.glGenBuffers();
    worldMetadataSsbo = GL15.glGenBuffers();
    metadataSsbo = GL15.glGenBuffers();

    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, worldChunkSsbo);
    GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, 0, GL15.GL_DYNAMIC_DRAW);
    GL30.glBindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, 2, worldChunkSsbo);

    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, chunkSsbo);
    GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, 0, GL15.GL_DYNAMIC_DRAW);
    GL30.glBindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, 3, chunkSsbo);

    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, worldMetadataSsbo);
    GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, 0, GL15.GL_DYNAMIC_DRAW);
    GL30.glBindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, 4, worldMetadataSsbo);

    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, metadataSsbo);
    GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, 0, GL15.GL_DYNAMIC_DRAW);
    GL30.glBindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, 5, metadataSsbo);
    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
}
项目:gdx-backend-jglfw    文件:JglfwGL30.java   
@Override
public void glInvalidateFramebuffer (int target, int numAttachments, IntBuffer attachments) {
    GL43.glInvalidateFramebuffer(target, attachments);
}
项目:gdx-backend-jglfw    文件:JglfwGL30.java   
@Override
public void glInvalidateSubFramebuffer (int target, int numAttachments, IntBuffer attachments, int x, int y, int width,
                                        int height) {
    GL43.glInvalidateSubFramebuffer(target, attachments, x, y, width, height);
}
项目:libgdxcn    文件:LwjglGL30.java   
@Override
public void glInvalidateFramebuffer (int target, int numAttachments, IntBuffer attachments) {
    GL43.glInvalidateFramebuffer(target, attachments);
}
项目:libgdxcn    文件:LwjglGL30.java   
@Override
public void glInvalidateSubFramebuffer (int target, int numAttachments, IntBuffer attachments, int x, int y, int width,
    int height) {
    GL43.glInvalidateSubFramebuffer(target, attachments, x, y, width, height);
}