本文整理匯總了Java中org.lwjgl.opengl.GL20.glVertexAttribPointer方法的典型用法代碼示例。如果您正苦於以下問題:Java GL20.glVertexAttribPointer方法的具體用法?Java GL20.glVertexAttribPointer怎麽用?Java GL20.glVertexAttribPointer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.lwjgl.opengl.GL20
的用法示例。
在下文中一共展示了GL20.glVertexAttribPointer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: add
import org.lwjgl.opengl.GL20; //導入方法依賴的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);
}
示例2: storeDataInAttributeList
import org.lwjgl.opengl.GL20; //導入方法依賴的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);
}
示例3: store
import org.lwjgl.opengl.GL20; //導入方法依賴的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();
}
示例4: storeDataInAttributeList
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
private void storeDataInAttributeList(final int attributeNumber, final int coordinateSize, final float[] data) {
int vboId = GL15.glGenBuffers();
vbos.add(vboId);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, storeDataInFloatBuffer(data), GL15.GL_STATIC_DRAW);
GL20.glVertexAttribPointer(attributeNumber, coordinateSize, GL11.GL_FLOAT, false, 0, 0);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
示例5: VertexArrayObject
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
/**
* Builds renderable geometry from a list of vertices and indices.
* Each triplet of indices references three distinct vertices to form a triangle.
*
* @param vertices ordered list of vertices
* @param indices ordered list of indices references vertices used for determining render order
*/
public VertexArrayObject(Vertex[] vertices, byte[] indices){
indicesCount = indices.length;
// Create a new Vertex Array Object in memory and select it (bind)
vaoId = GL30.glGenVertexArrays();
GL30.glBindVertexArray(vaoId);
// Create a new Vertex Buffer Object in memory and select it (bind)
vboId = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, bufferFromVertices(vertices), GL15.GL_STREAM_DRAW);
// Put the position coordinates in attribute list 0
GL20.glVertexAttribPointer(0, Vertex.positionElementCount, GL11.GL_FLOAT,
false, Vertex.stride, Vertex.positionByteOffset);
// Put the color components in attribute list 1
GL20.glVertexAttribPointer(1, Vertex.colorElementCount, GL11.GL_FLOAT,
false, Vertex.stride, Vertex.colorByteOffset);
// Put the texture coordinates in attribute list 2
GL20.glVertexAttribPointer(2, Vertex.textureElementCount, GL11.GL_FLOAT,
false, Vertex.stride, Vertex.textureByteOffset);
// Deselect
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
GL30.glBindVertexArray(0);
// Create a new VBO for the indices and select it (bind) - INDICES
indicesId = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesId);
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, Buffers.createByteBuffer(indices), GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
}
示例6: drawArrays
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public static void drawArrays(int drawMode, int first, int count, WorldRenderer wrr)
{
if (count != 0)
{
VertexFormat vertexformat = wrr.getVertexFormat();
int i = vertexformat.getNextOffset();
if (i == 56)
{
ByteBuffer bytebuffer = wrr.getByteBuffer();
bytebuffer.position(32);
GL20.glVertexAttribPointer(Shaders.midTexCoordAttrib, 2, GL11.GL_FLOAT, false, i, bytebuffer);
bytebuffer.position(40);
GL20.glVertexAttribPointer(Shaders.tangentAttrib, 4, GL11.GL_SHORT, false, i, bytebuffer);
bytebuffer.position(48);
GL20.glVertexAttribPointer(Shaders.entityAttrib, 3, GL11.GL_SHORT, false, i, bytebuffer);
bytebuffer.position(0);
GL20.glEnableVertexAttribArray(Shaders.midTexCoordAttrib);
GL20.glEnableVertexAttribArray(Shaders.tangentAttrib);
GL20.glEnableVertexAttribArray(Shaders.entityAttrib);
GL11.glDrawArrays(drawMode, first, count);
GL20.glDisableVertexAttribArray(Shaders.midTexCoordAttrib);
GL20.glDisableVertexAttribArray(Shaders.tangentAttrib);
GL20.glDisableVertexAttribArray(Shaders.entityAttrib);
}
else
{
GL11.glDrawArrays(drawMode, first, count);
}
}
}
示例7: setupArrayPointersVbo
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public static void setupArrayPointersVbo()
{
int i = 14;
GL11.glVertexPointer(3, GL11.GL_FLOAT, 56, 0L);
GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 56, 12L);
GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 56, 16L);
OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);
GL11.glTexCoordPointer(2, GL11.GL_SHORT, 56, 24L);
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
GL11.glNormalPointer(GL11.GL_BYTE, 56, 28L);
GL20.glVertexAttribPointer(Shaders.midTexCoordAttrib, 2, GL11.GL_FLOAT, false, 56, 32L);
GL20.glVertexAttribPointer(Shaders.tangentAttrib, 4, GL11.GL_SHORT, false, 56, 40L);
GL20.glVertexAttribPointer(Shaders.entityAttrib, 3, GL11.GL_SHORT, false, 56, 48L);
}
示例8: setVertexArrayBuffer
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public Mesh setVertexArrayBuffer(int location, int size, int stride, VBO buffer)
{
GL30.glBindVertexArray(this.handle);
buffer.bind();
GL20.glVertexAttribPointer(location, size, buffer.getType(), buffer.isNormalized(), stride, 0);
if (this.vertexBuffers.length <= location)
{
this.vertexBuffers = Arrays.copyOf(this.vertexBuffers, location + 1);
}
VBO vbo = this.vertexBuffers[location];
if (vbo != null)
{
try
{
vbo.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
this.vertexBuffers[location] = buffer;
buffer.unbind();
GL30.glBindVertexArray(0);
return this;
}
示例9: storeDataInAttributeList
import org.lwjgl.opengl.GL20; //導入方法依賴的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); // store data in the buffer - static data after it is stored in VBO
GL20.glVertexAttribPointer(attributeNumber, coordinateSize, GL11.GL_FLOAT, false, 0, 0); // store into the VAO
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); // un-bind VBO
}
示例10: drawArrays
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public static void drawArrays(int drawMode, int first, int count, VertexBuffer wrr)
{
if (count != 0)
{
VertexFormat vertexformat = wrr.getVertexFormat();
int i = vertexformat.getNextOffset();
if (i == 56)
{
ByteBuffer bytebuffer = wrr.getByteBuffer();
bytebuffer.position(32);
GL20.glVertexAttribPointer(Shaders.midTexCoordAttrib, 2, GL11.GL_FLOAT, false, i, bytebuffer);
bytebuffer.position(40);
GL20.glVertexAttribPointer(Shaders.tangentAttrib, 4, GL11.GL_SHORT, false, i, bytebuffer);
bytebuffer.position(48);
GL20.glVertexAttribPointer(Shaders.entityAttrib, 3, GL11.GL_SHORT, false, i, bytebuffer);
bytebuffer.position(0);
GL20.glEnableVertexAttribArray(Shaders.midTexCoordAttrib);
GL20.glEnableVertexAttribArray(Shaders.tangentAttrib);
GL20.glEnableVertexAttribArray(Shaders.entityAttrib);
GL11.glDrawArrays(drawMode, first, count);
GL20.glDisableVertexAttribArray(Shaders.midTexCoordAttrib);
GL20.glDisableVertexAttribArray(Shaders.tangentAttrib);
GL20.glDisableVertexAttribArray(Shaders.entityAttrib);
}
else
{
GL11.glDrawArrays(drawMode, first, count);
}
}
}
示例11: createAttribute
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public void createAttribute(int attribute, float[] data, int attrSize){
Vbo dataVbo = Vbo.create(GL15.GL_ARRAY_BUFFER);
dataVbo.bind();
dataVbo.storeData(data);
GL20.glVertexAttribPointer(attribute, attrSize, GL11.GL_FLOAT, false, attrSize * BYTES_PER_FLOAT, 0);
dataVbo.unbind();
dataVbos.add(dataVbo);
}
示例12: linkVboDataToAttributes
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
private void linkVboDataToAttributes(int[] lengths, int bytesPerVertex){
int total = 0;
for (int i = 0; i < lengths.length; i++) {
GL20.glVertexAttribPointer(i, lengths[i], GL11.GL_FLOAT, false, bytesPerVertex, BYTES_PER_FLOAT * total);
total += lengths[i];
}
}
示例13: runShader
import org.lwjgl.opengl.GL20; //導入方法依賴的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);
}
示例14: link
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
protected void link(int offset, int stride) {
GL20.glVertexAttribPointer(attributeNumber, componentCount, dataType, normalized, stride, offset);
}
示例15: Quad
import org.lwjgl.opengl.GL20; //導入方法依賴的package包/類
public Quad(float width, float height){
this.width = width;
this.height = height;
vao = GL30.glGenVertexArrays();
GL30.glBindVertexArray(vao);
vbo = GL15.glGenBuffers();
vto = GL15.glGenBuffers();
vboi = GL15.glGenBuffers();
float hw = width * 0.5f,
hh = height * 0.5f;
float[] verts = new float[]{
-hw, -hh, 0, //bottom left
-hw, hh, 0, //top left
hw, hh, 0, //top right
hw, -hh, 0, //bottom right
};
float[] texcoords = new float[]{
0,1,
0,0,
1,0,
1,1
};
int[] indices = new int[]{
0,1,2,
2,3,0
};
FloatBuffer vertBuffer = BufferUtils.createFloatBuffer(12);
vertBuffer.put(verts).flip();
FloatBuffer texBuffer = BufferUtils.createFloatBuffer(8);
texBuffer.put(texcoords).flip();
IntBuffer indBuffer = BufferUtils.createIntBuffer(6);
indBuffer.put(indices).flip();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertBuffer, GL15.GL_STATIC_DRAW);
GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vto);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, texBuffer, GL15.GL_STATIC_DRAW);
GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 0, 0);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboi);
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indBuffer, GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
GL30.glBindVertexArray(0);
}