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


Java GL15.glBindBuffer方法代码示例

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


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

示例1: add

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public void add(float[] vertices, float[] texCoords, int[] indices) {
	indicesSize = indices.length;

	GL30.glBindVertexArray(vao);

	GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
	GL15.glBufferData(GL15.GL_ARRAY_BUFFER, Util.flip(vertices), GL15.GL_STATIC_DRAW);
	GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);
	GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

	GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboTexture);
	GL15.glBufferData(GL15.GL_ARRAY_BUFFER, Util.flip(texCoords), GL15.GL_STATIC_DRAW);
	GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 0, 0);
	GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

	GL30.glBindVertexArray(0);

	GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboi);
	GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, Util.flip(indices), GL15.GL_STATIC_DRAW);
	GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
}
 
开发者ID:ComunityEngine,项目名称:CommunityEngine-Java,代码行数:22,代码来源:Mesh.java

示例2: updateData

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public VBO updateData(IntBuffer buffer, long offset)
{
	if (this.type != GL11.GL_UNSIGNED_INT)
	{
		throw new IllegalArgumentException("Cannot store mismatching type in buffer!");
	}

	if (offset + buffer.limit() > this.length)
	{
		int usage = GL15.glGetBufferParameteri(this.target, GL15.GL_BUFFER_USAGE);
		this.putData(buffer, this.normalized, usage);
	}

	GL15.glBindBuffer(this.target, this.handle);
	GL15.glBufferSubData(this.target, offset, buffer);

	return this;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:19,代码来源:VBO.java

示例3: createShaderProgram

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public void createShaderProgram(RenderMethod renderMethod) {
	shaderProgram = GL20.glCreateProgram();
	vshader = createShader(vertexShader, GL20.GL_VERTEX_SHADER);
	fshader = createShader(renderMethod.getFragmentShader(), 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);
	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);
}
 
开发者ID:shaunlebron,项目名称:flex-fov,代码行数:33,代码来源:Shader.java

示例4: storeDataInAttributeList

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
private void storeDataInAttributeList(int attributeNumber, int coordinateSize, float[] data) {
	int vboID = GL15.glGenBuffers();
	vbos.add(vboID);
	GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
	FloatBuffer buffer = storeDataInFloatBuffer(data);
	GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
	GL20.glVertexAttribPointer(attributeNumber, coordinateSize, GL11.GL_FLOAT, false, 0, 0);
	GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
 
开发者ID:marcioz98,项目名称:MRCEngine,代码行数:10,代码来源:Loader.java

示例5: loadChunk

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
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);
}
 
开发者ID:18107,项目名称:MC-Ray-Tracer,代码行数:37,代码来源:WorldLoader.java

示例6: loadMetadata

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
/**
 * 
 * @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;
}
 
开发者ID:18107,项目名称:MC-Ray-Tracer,代码行数:34,代码来源:WorldLoader.java

示例7: renderFBO

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public void renderFBO(){

        glBindFramebuffer(GL_FRAMEBUFFER, 0);
        glViewport(0,0,Main.WIDTH,Main.HEIGHT);

        Shaders.MAIN_FBO.bind();
        Shaders.MAIN_FBO.uniform("projection", (new Matrix4f()).Ortho2D(0,1,0,1,-1,1).mul(new Matrix4f().translate(.5f,.5f,0)));
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, fboTexID);
        GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
        GL11.glDrawArrays(GL11.GL_QUADS, 0, size);
        GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
        glBindTexture(GL_TEXTURE_2D, 0);
        Shaders.MAIN_SHADERS.unbind();
    }
 
开发者ID:mrdev023,项目名称:Global-Gam-Jam-2017,代码行数:16,代码来源:FrameBufferObject.java

示例8: bindIndicesBuffer

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
private void bindIndicesBuffer(int[] indices) {
	int vboID = GL15.glGenBuffers();
	vbos.add(vboID);
	GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboID);
	IntBuffer buffer = storeDataInIntBuffer(indices);
	GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
}
 
开发者ID:DevipriyaSarkar,项目名称:Terrain,代码行数:8,代码来源:Loader.java

示例9: glBindBuffer

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public static void glBindBuffer(int target, int buffer)
{
    if (arbVbo)
    {
        ARBVertexBufferObject.glBindBufferARB(target, buffer);
    }
    else
    {
        GL15.glBindBuffer(target, buffer);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:OpenGlHelper.java

示例10: unbind

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public void unbind()
{
	GL15.glBindBuffer(this.target, 0);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:5,代码来源:VBO.java

示例11: runShader

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public static void runShader() {
	Minecraft mc = Minecraft.getMinecraft();
	
	//TODO remove
	if (Keyboard.isKeyDown(Keyboard.KEY_NUMPAD5)) {
		destroyShader();
		createShader();
	}
	
	//Use shader program
	GL20.glUseProgram(shader.getShaderProgram());
	
	//TODO third person view
	Entity entity = mc.getRenderViewEntity();
	float partialTicks = mc.getRenderPartialTicks();
	double entityPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
       double entityPosY = entity.lastTickPosY + entity.getEyeHeight() + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
       double entityPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks;
       float fov = (float) Math.toRadians(mc.entityRenderer.getFOVModifier(partialTicks, true));
	
	//Set uniform values
	int texUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "tex");
	GL20.glUniform1i(texUniform, 0);
	int cameraPosUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "cameraPos");
	GL20.glUniform3f(cameraPosUniform, (float)entityPosX%16, (float)entityPosY%16, (float)entityPosZ%16);
	int cameraDirUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "cameraDir");
	GL20.glUniform3f(cameraDirUniform, -(float)Math.toRadians(entity.rotationPitch), (float)Math.toRadians(180+entity.rotationYaw), 0);
	int fovyUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "fovy");
	GL20.glUniform1f(fovyUniform, fov);
	int fovxUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "fovx");
	GL20.glUniform1f(fovxUniform, fov*Display.getWidth()/(float)Display.getHeight());
	int sphericalUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "spherical");
	GL20.glUniform1i(sphericalUniform, RayTracerSettings.spherical ? 1 : 0);
	int stereoscopicUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "stereoscopic3d");
	GL20.glUniform1i(stereoscopicUniform, RayTracerSettings.stereoscopic ? 1 : 0);
	int eyeWidthUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "eyeWidth");
	GL20.glUniform1f(eyeWidthUniform, 0.063f); //TODO input eyeWidth option
	
	if (!pauseRendering) {
		if (worldLoader == null) {
			worldLoader = new WorldLoader();
		}
		if (worldLoader.dimension != mc.world.provider.getDimension()) {
			worldLoader.dimension = mc.world.provider.getDimension();
		}
		worldLoader.updateWorld(entityPosX, entityPosY, entityPosZ, shader);

		//Setup view
		GL11.glMatrixMode(GL11.GL_PROJECTION);
		GL11.glPushMatrix();
		GL11.glLoadIdentity();
		GL11.glOrtho(-1, 1, -1, 1, -1, 1);
		GL11.glMatrixMode(GL11.GL_MODELVIEW);
		GL11.glPushMatrix();
		GL11.glLoadIdentity();

		//Bind vbo and texture
		GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, shader.getVbo());
		GL20.glEnableVertexAttribArray(0);
		GL20.glVertexAttribPointer(0, 2, GL11.GL_BYTE, false, 0, 0L);
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, 8);

		//Render
		GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 6);

		//Reset vbo and texture
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
		GL20.glDisableVertexAttribArray(0);
		GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

		//Reset view
		GL11.glMatrixMode(GL11.GL_PROJECTION);
		GL11.glPopMatrix();
		GL11.glMatrixMode(GL11.GL_MODELVIEW);
		GL11.glPopMatrix();
	}
	
	//Stop using shader program
	GL20.glUseProgram(0);
}
 
开发者ID:18107,项目名称:MC-Ray-Tracer,代码行数:81,代码来源:RenderUtil.java

示例12: bind

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public void bind() {
    GL15.glBindBuffer(type, vboId);
}
 
开发者ID:GryPLOfficial,项目名称:EcoSystem-Official,代码行数:4,代码来源:Vbo.java

示例13: bind

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public void bind(){
	GL15.glBindBuffer(type, vboId);
}
 
开发者ID:TheThinMatrix,项目名称:LowPolyTerrain,代码行数:4,代码来源:Vbo.java

示例14: unbind

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public void unbind(){
	GL15.glBindBuffer(type, 0);
}
 
开发者ID:TheThinMatrix,项目名称:OcclusionQueries,代码行数:4,代码来源:Vbo.java

示例15: FrameBufferObject

import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public FrameBufferObject(){
    int width = Main.WIDTH;
    int height = Main.HEIGHT;
    this.fbo = glGenFramebuffers();
    glBindFramebuffer(GL_FRAMEBUFFER, fbo);

    //Creation de la texture qui va contenir la sortie RGB du shader
    int renderedTexture = glGenTextures();
    glBindTexture(GL_TEXTURE_2D, renderedTexture);
    glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, width, height, 0,GL_RGB, GL_UNSIGNED_BYTE, 0);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

    //Creation du tampon de profondeur
    int depthrenderbuffer = glGenRenderbuffers();
    glBindRenderbuffer(GL_RENDERBUFFER, depthrenderbuffer);
    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthrenderbuffer);

    //Definir le render Texture
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D, renderedTexture, 0);
    if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
        throw new IllegalStateException("FBO not loaded !");
    fboTexID = renderedTexture;
    renderID = depthrenderbuffer;


    this.vbo = GL15.glGenBuffers();
    float[] a = new float[]{
            0,0,        0.0f,0.0f,
            1,0,         1.0f,0.0f,
            1,1,          1.0f,1.0f,
            0,1,         0.0f,1.0f
    };
    FloatBuffer buffer = BufferUtils.createFloatBuffer(a.length);
    buffer.put(a).flip();
    size = a.length/(2+2);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);

    GL20.glEnableVertexAttribArray(Shaders.MAIN_SHADERS.getAttribLocation("vert"));
    GL20.glVertexAttribPointer(Shaders.MAIN_SHADERS.getAttribLocation("vert"), 2, GL11.GL_FLOAT, false, (2+2)*4, 0);

    GL20.glEnableVertexAttribArray(Shaders.MAIN_SHADERS.getAttribLocation("vertTexCoord"));
    GL20.glVertexAttribPointer(Shaders.MAIN_SHADERS.getAttribLocation("vertTexCoord"), 2, GL11.GL_FLOAT, true, (2+2)*4, 2*4);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
 
开发者ID:mrdev023,项目名称:Global-Gam-Jam-2017,代码行数:50,代码来源:FrameBufferObject.java


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