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


Java GLAllocation.createDirectByteBuffer方法代码示例

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


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

示例1: BufferBuilderObject

import net.minecraft.client.renderer.GLAllocation; //导入方法依赖的package包/类
/**
 * Constructs a new interleaved BufferBuilderObject.
 *
 * @param isStatic    whether the vertex data is static.
 * @param numVertices the maximum number of vertices
 * @param attributes  the {@link VertexAttributes}.
 */
public BufferBuilderObject(boolean isStatic, int numVertices, VertexAttributes attributes)
{
    this.isStatic = isStatic;
    this.attributes = attributes;

    byteBuffer = GLAllocation.createDirectByteBuffer(this.attributes.vertexSize * numVertices);
    buffer = byteBuffer.asFloatBuffer();
    buffer.flip();
    byteBuffer.flip();
    bufferHandle = createBufferObject();
    usage = isStatic ? GL15.GL_STATIC_DRAW : GL15.GL_DYNAMIC_DRAW;
}
 
开发者ID:Ivorforce,项目名称:IvToolkit,代码行数:20,代码来源:BufferBuilderObject.java

示例2: VertexArray

import net.minecraft.client.renderer.GLAllocation; //导入方法依赖的package包/类
/** Constructs a new interleaved VertexArray
 * 
 * @param numVertices the maximum number of vertices
 * @param attributes the {@link VertexAttributes} */
public VertexArray (int numVertices, VertexAttributes attributes) {
	this.attributes = attributes;
	byteBuffer = GLAllocation.createDirectByteBuffer(this.attributes.vertexSize * numVertices);
	buffer = byteBuffer.asFloatBuffer();
	buffer.flip();
	byteBuffer.flip();
}
 
开发者ID:Ivorforce,项目名称:IvToolkit,代码行数:12,代码来源:VertexArray.java

示例3: IndexBufferObject

import net.minecraft.client.renderer.GLAllocation; //导入方法依赖的package包/类
/**
 * Creates a new IndexBufferObject.
 *
 * @param isStatic   whether the index buffer is static
 * @param maxIndices the maximum number of indices this buffer can hold
 */
public IndexBufferObject(boolean isStatic, int maxIndices)
{
    byteBuffer = GLAllocation.createDirectByteBuffer(maxIndices * 2);
    isDirect = true;

    buffer = byteBuffer.asShortBuffer();
    buffer.flip();
    byteBuffer.flip();
    bufferHandle = createBufferObject();
    usage = isStatic ? GL15.GL_STATIC_DRAW : GL15.GL_DYNAMIC_DRAW;
}
 
开发者ID:Ivorforce,项目名称:IvToolkit,代码行数:18,代码来源:IndexBufferObject.java

示例4: updateTexture

import net.minecraft.client.renderer.GLAllocation; //导入方法依赖的package包/类
public boolean updateTexture()
{
    if (this.dstTextId < 0)
    {
        ITextureObject itextureobject = TextureUtils.getTexture(this.dstTexLoc);

        if (itextureobject == null)
        {
            return false;
        }

        this.dstTextId = itextureobject.getGlTextureId();
    }

    if (this.imageData == null)
    {
        this.imageData = GLAllocation.createDirectByteBuffer(this.srcData.length);
        this.imageData.put(this.srcData);
        this.srcData = null;
    }

    if (!this.nextFrame())
    {
        return false;
    }
    else
    {
        int k = this.frameWidth * this.frameHeight * 4;
        int i = this.getActiveFrameIndex();
        int j = k * i;

        if (j + k > this.imageData.capacity())
        {
            return false;
        }
        else
        {
            this.imageData.position(j);
            GlStateManager.bindTexture(this.dstTextId);
            GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, this.dstX, this.dstY, this.frameWidth, this.frameHeight, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)this.imageData);
            return true;
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:45,代码来源:TextureAnimation.java

示例5: ModelFast3D

import net.minecraft.client.renderer.GLAllocation; //导入方法依赖的package包/类
public ModelFast3D(/*File rr3dfile, File pngtexfile*/)
{
     ByteBuffer byteBuffer = GLAllocation.createDirectByteBuffer(3 * 5 * 8);
     FloatBuffer floatBuffer = byteBuffer.asFloatBuffer();
     floatBuffer.put(0f);
     floatBuffer.put(0f);
     floatBuffer.put(0f);
     floatBuffer.put(0f);
     floatBuffer.put(0f);
     
     floatBuffer.put(0f);
     floatBuffer.put(1f);
     floatBuffer.put(0f);
     floatBuffer.put(0f);
     floatBuffer.put(0f);
     
     floatBuffer.put(0f);
     floatBuffer.put(0f);
     floatBuffer.put(1f);
     floatBuffer.put(0f);
     floatBuffer.put(0f);
     floatBuffer.flip();
     
     byte[] indices = {0, 1, 2};
     indicesCount = indices.length;
     ByteBuffer indicesBuffer = GLAllocation.createDirectByteBuffer(indicesCount);
     indicesBuffer.put(indices);
     indicesBuffer.flip();
     
     //vboId = ARBVertexBufferObject.glGenBuffersARB(floatBuffer);
     GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId);
     GL15.glBufferData(GL15.GL_ARRAY_BUFFER, floatBuffer, GL15.GL_STATIC_DRAW);
     GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 8, 0);
     GL20.glVertexAttribPointer(2, 2, GL11.GL_FLOAT, false, 8, 6);
     GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
     GL30.glBindVertexArray(0);
     
     vboiId = GL15.glGenBuffers();
     GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId);
     GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL15.GL_STATIC_DRAW);
     GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
     
     int vsId = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);
     int fsId = GL20.glCreateShader(GL20.GL_FRAGMENT_SHADER);
     GL20.glShaderSource(vsId, "void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; }");
     GL20.glShaderSource(fsId, "void main() { gl_FragColor = vec4(0.4,0.4,0.8,1.0); }");
     GL20.glCompileShader(vsId);
     GL20.glCompileShader(fsId);
      
     pId = GL20.glCreateProgram();
     GL20.glAttachShader(pId, vsId);
     GL20.glAttachShader(pId, fsId);
     
     GL20.glBindAttribLocation(pId, 0, "in_Position");
     GL20.glBindAttribLocation(pId, 1, "in_Normal");
     GL20.glBindAttribLocation(pId, 2, "in_UV");
      
     GL20.glLinkProgram(pId);
     GL20.glValidateProgram(pId);
}
 
开发者ID:rodolphito,项目名称:Rival-Rebels-Mod,代码行数:61,代码来源:ModelFast3D.java

示例6: TextureAnimation

import net.minecraft.client.renderer.GLAllocation; //导入方法依赖的package包/类
public TextureAnimation(String texFrom, byte[] srcData, String texTo, int dstTexId, int dstX, int dstY, int frameWidth, int frameHeight, Properties props, int durDef)
{
    this.srcTex = texFrom;
    this.dstTex = texTo;
    this.dstTextId = dstTexId;
    this.dstX = dstX;
    this.dstY = dstY;
    this.frameWidth = frameWidth;
    this.frameHeight = frameHeight;
    int frameLen = frameWidth * frameHeight * 4;

    if (srcData.length % frameLen != 0)
    {
        Config.warn("Invalid animated texture length: " + srcData.length + ", frameWidth: " + frameHeight + ", frameHeight: " + frameHeight);
    }

    this.imageData = GLAllocation.createDirectByteBuffer(srcData.length);
    this.imageData.put(srcData);
    int numFrames = srcData.length / frameLen;

    if (props.get("tile.0") != null)
    {
        for (int durationDefStr = 0; props.get("tile." + durationDefStr) != null; ++durationDefStr)
        {
            numFrames = durationDefStr + 1;
        }
    }

    String var21 = (String)props.get("duration");
    int durationDef = Config.parseInt(var21, durDef);
    this.frames = new CustomAnimationFrame[numFrames];

    for (int i = 0; i < this.frames.length; ++i)
    {
        String indexStr = (String)props.get("tile." + i);
        int index = Config.parseInt(indexStr, i);
        String durationStr = (String)props.get("duration." + i);
        int duration = Config.parseInt(durationStr, durationDef);
        CustomAnimationFrame frm = new CustomAnimationFrame(index, duration);
        this.frames[i] = frm;
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:43,代码来源:TextureAnimation.java

示例7: getBufferedTexture

import net.minecraft.client.renderer.GLAllocation; //导入方法依赖的package包/类
public static ByteBuffer getBufferedTexture(int[] imageData)
{
    ByteBuffer result = GLAllocation.createDirectByteBuffer(imageData.length * 4);
    copyToBufferPos(imageData, result, 0, imageData.length);
    return result;
}
 
开发者ID:grondag,项目名称:Hard-Science,代码行数:7,代码来源:TextureHelper.java

示例8: directByteBuffer

import net.minecraft.client.renderer.GLAllocation; //导入方法依赖的package包/类
/**
 * Asks for a new directly backed ByteBuffer
 *
 * @param size
 *            the number of buffer elements (bytes)
 * @return a new direct byte buffer
 */
public static ByteBuffer directByteBuffer(int size) {
	return GLAllocation.createDirectByteBuffer(size);
}
 
开发者ID:WorldSEnder,项目名称:MCAnm,代码行数:11,代码来源:Utils.java


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