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


Java GL15类代码示例

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


GL15类属于org.lwjgl.opengl包,在下文中一共展示了GL15类的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: createQuad

import org.lwjgl.opengl.GL15; //导入依赖的package包/类
public Mesh createQuad()
{
	Mesh mesh = new Mesh();
	mesh.bind();
	{
		VBO vbo = new VBO();
		vbo.bind();
		{
			final float[] verts = {-0.5F, 0.5F, -0.5F, -0.5F, 0.5F, -0.5F, 05.F, 05.F};
			vbo.putData(FloatBuffer.wrap(verts), false, GL15.GL_STATIC_DRAW);
		}
		vbo.unbind();
		mesh.setVertexArrayBuffer(0, 2, 0, vbo);
	}
	mesh.unbind();
	return mesh;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:18,代码来源:MeshBuilder2D.java

示例3: createCircle

import org.lwjgl.opengl.GL15; //导入依赖的package包/类
public Mesh createCircle(int segments)
{
	Mesh mesh = new Mesh();
	mesh.bind();
	{
		VBO vbo = new VBO();
		vbo.bind();
		{
			final float[] verts = new float[segments * 2];
			for (int i = 0; i < segments; ++i)
			{
				verts[i * 2] = (float) Math.cos(i * Transform.PI2 / segments);
				verts[i * 2 + 1] = (float) Math.sin(i * Transform.PI2 / segments);
			}
			vbo.putData(FloatBuffer.wrap(verts), false, GL15.GL_STATIC_DRAW);
		}
		vbo.unbind();
		mesh.setVertexArrayBuffer(0, 2, 0, vbo);
	}
	mesh.unbind();
	return mesh;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:23,代码来源:MeshBuilder2D.java

示例4: 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

示例5: cleanUp

import org.lwjgl.opengl.GL15; //导入依赖的package包/类
public void cleanUp() {
	for(int vao : vaos) {
		GL30.glDeleteVertexArrays(vao);
	}
	
	for(int vbo : vbos) {
		GL15.glDeleteBuffers(vbo);
	}
	
	for(int texture : textures) {
		GL11.glDeleteTextures(texture);
	}
}
 
开发者ID:marcioz98,项目名称:MRCEngine,代码行数:14,代码来源:Loader.java

示例6: 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:marcioz98,项目名称:MRCEngine,代码行数:8,代码来源:Loader.java

示例7: 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

示例8: compile

import org.lwjgl.opengl.GL15; //导入依赖的package包/类
/**
 * Compiles a FloatBuffer and binds it to OpenGL for rendering.
 *
 * @param buffer a FloatBuffer populated with VBO vertices
 * @return The original VBO
 */
public VBO compile(FloatBuffer buffer) {
	this.size = buffer.capacity();
	FEATHER.bindBuffer(this.id);
	GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
	FEATHER.bindBuffer(0);
	return this;
}
 
开发者ID:ImpactDevelopment,项目名称:ClientAPI,代码行数:14,代码来源:VBO.java

示例9: initializeWorld

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

示例10: 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

示例11: 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

示例12: deleteShaderProgram

import org.lwjgl.opengl.GL15; //导入依赖的package包/类
public void deleteShaderProgram() {
	GL15.glDeleteBuffers(vbo);
	vbo = 0;
	GL15.glDeleteBuffers(worldChunkSsbo);
	worldChunkSsbo = 0;
	GL15.glDeleteBuffers(chunkSsbo);
	chunkSsbo = 0;
	GL20.glDeleteProgram(shaderProgram);
	shaderProgram = 0;
}
 
开发者ID:18107,项目名称:MC-Ray-Tracer,代码行数:11,代码来源:Shader.java

示例13: glDeleteBuffers

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

示例14: store

import org.lwjgl.opengl.GL15; //导入依赖的package包/类
/**
    * Stores the specified data into the VAO with a VBO
    * @param data
    * @param dimensions
    */
   private void store(FloatBuffer data, int[] dimensions) {
bind();

// Generate a VBO to hold the data
int vboid = GL15.glGenBuffers();
// Bind the VBO
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboid);
// Store the data in the VBO
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, data, GL15.GL_STATIC_DRAW);

// Get the stride of the data in bytes
int stride = 0;
if(dimensions.length > 1)
    for(int i = 0; i < dimensions.length; i++) {
	stride += dimensions[i] * 4;
    }

// Determine the number of vertices assuming attribute 0 is position
vertexCount = data.capacity() / dimensions[0];

// Setup data in VBO
int offset = 0;
for(int i = 0; i < dimensions.length; i++) {
    GL20.glVertexAttribPointer(i, dimensions[i], GL11.GL_FLOAT, false, stride, offset);
    offset += dimensions[i] * 4;
}

// Add the vbo to the list of buffer objects for memory management
addBufferObject(vboid);

unbind();
   }
 
开发者ID:camilne,项目名称:open-world,代码行数:38,代码来源:VAO.java

示例15: finalize

import org.lwjgl.opengl.GL15; //导入依赖的package包/类
/**
    * Cleans up the VRAM of this VAO
    */
   @Override
   public void finalize() {
GL30.glDeleteVertexArrays(vaoid);
for(int vbo : bufferObjects)
    GL15.glDeleteBuffers(vbo);
   }
 
开发者ID:camilne,项目名称:open-world,代码行数:10,代码来源:VAO.java


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