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


Java IntBuffer.clear方法代码示例

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


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

示例1: makeMipmapBuffers

import java.nio.IntBuffer; //导入方法依赖的package包/类
public static IntBuffer[] makeMipmapBuffers(Dimension[] p_makeMipmapBuffers_0_, int[][] p_makeMipmapBuffers_1_)
{
    if (p_makeMipmapBuffers_0_ == null)
    {
        return null;
    }
    else
    {
        IntBuffer[] aintbuffer = new IntBuffer[p_makeMipmapBuffers_0_.length];

        for (int i = 0; i < p_makeMipmapBuffers_0_.length; ++i)
        {
            Dimension dimension = p_makeMipmapBuffers_0_[i];
            int j = dimension.width * dimension.height;
            IntBuffer intbuffer = GLAllocation.createDirectIntBuffer(j);
            int[] aint = p_makeMipmapBuffers_1_[i];
            intbuffer.clear();
            intbuffer.put(aint);
            intbuffer.clear();
            aintbuffer[i] = intbuffer;
        }

        return aintbuffer;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:26,代码来源:Mipmaps.java

示例2: updateDynTexSubImage1

import java.nio.IntBuffer; //导入方法依赖的package包/类
public static void updateDynTexSubImage1(int[] src, int width, int height, int posX, int posY, int page)
{
    int i = width * height;
    IntBuffer intbuffer = getIntBuffer(i);
    intbuffer.clear();
    int j = page * i;

    if (src.length >= j + i)
    {
        intbuffer.put(src, j, i).position(0).limit(i);
        GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, posX, posY, width, height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)intbuffer);
        intbuffer.clear();
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:15,代码来源:ShadersTex.java

示例3: uploadTexSub1

import java.nio.IntBuffer; //导入方法依赖的package包/类
public static void uploadTexSub1(int[][] src, int width, int height, int posX, int posY, int page)
{
    int i = width * height;
    IntBuffer intbuffer = getIntBuffer(i);
    int j = src.length;
    int k = 0;
    int l = width;
    int i1 = height;
    int j1 = posX;

    for (int k1 = posY; l > 0 && i1 > 0 && k < j; ++k)
    {
        int l1 = l * i1;
        int[] aint = src[k];
        intbuffer.clear();

        if (aint.length >= l1 * (page + 1))
        {
            intbuffer.put(aint, l1 * page, l1).position(0).limit(l1);
            GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, k, j1, k1, l, i1, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)intbuffer);
        }

        l >>= 1;
        i1 >>= 1;
        j1 >>= 1;
        k1 >>= 1;
    }

    intbuffer.clear();
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:31,代码来源:ShadersTex.java

示例4: setupTexture

import java.nio.IntBuffer; //导入方法依赖的package包/类
public static void setupTexture(MultiTexID multiTex, int[] src, int width, int height, boolean linear, boolean clamp)
{
    int i = linear ? 9729 : 9728;
    int j = clamp ? 10496 : 10497;
    int k = width * height;
    IntBuffer intbuffer = getIntBuffer(k);
    intbuffer.clear();
    intbuffer.put(src, 0, k).position(0).limit(k);
    GlStateManager.bindTexture(multiTex.base);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)intbuffer);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, i);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, i);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, j);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, j);
    intbuffer.put(src, k, k).position(0).limit(k);
    GlStateManager.bindTexture(multiTex.norm);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)intbuffer);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, i);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, i);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, j);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, j);
    intbuffer.put(src, k * 2, k).position(0).limit(k);
    GlStateManager.bindTexture(multiTex.spec);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)intbuffer);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, i);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, i);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, j);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, j);
    GlStateManager.bindTexture(multiTex.base);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:31,代码来源:ShadersTex.java

示例5: printShaderLog

import java.nio.IntBuffer; //导入方法依赖的package包/类
private void printShaderLog(GL2 gl) {
    IntBuffer b = IntBuffer.allocate(8);
    gl.glGetProgramiv(shaderprogram, GL2ES2.GL_INFO_LOG_LENGTH, b);
    int logLength = b.get(0);
    ByteBuffer bb = ByteBuffer.allocate(logLength);
    b.clear();
    gl.glGetProgramInfoLog(shaderprogram, logLength, b, bb);
    String v = new String(bb.array(), java.nio.charset.StandardCharsets.UTF_8);
    log.info(v);

}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:12,代码来源:SpaceTimeRollingEventDisplayMethod.java

示例6: createIntBuffer

import java.nio.IntBuffer; //导入方法依赖的package包/类
/**
 * Generate a new IntBuffer using the given array of ints. The IntBuffer
 * will be data.length long and contain the int data as data[0], data[1]...
 * etc.
 * 
 * @param data
 *            array of ints to place into a new IntBuffer
 */
public static IntBuffer createIntBuffer(int... data) {
    if (data == null) {
        return null;
    }
    IntBuffer buff = createIntBuffer(data.length);
    buff.clear();
    buff.put(data);
    buff.flip();
    return buff;
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:19,代码来源:BufferUtils.java

示例7: getIntArray

import java.nio.IntBuffer; //导入方法依赖的package包/类
/**
 * Create a new int[] array and populate it with the given IntBuffer's
 * contents.
 * 
 * @param buff
 *            the IntBuffer to read from
 * @return a new int array populated from the IntBuffer
 */
public static int[] getIntArray(IntBuffer buff) {
    if (buff == null) {
        return null;
    }
    buff.clear();
    int[] inds = new int[buff.limit()];
    for (int x = 0; x < inds.length; x++) {
        inds[x] = buff.get();
    }
    return inds;
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:20,代码来源:BufferUtils.java

示例8: Texture

import java.nio.IntBuffer; //导入方法依赖的package包/类
public Texture(String resourceName){
    try{
        if (idMap.containsKey(resourceName)) return;

        this.path = resourceName;

        IntBuffer ib = BufferUtils.createIntBuffer(1);
        ib.clear();
        glGenTextures(ib);
        int id = ib.get(0);
        idMap.put(resourceName, Integer.valueOf(id));

        glBindTexture(3553, id);

        glTexParameteri(3553, 10241, GL_NEAREST);
        glTexParameteri(3553, 10240, GL_NEAREST);

        BufferedImage img = ImageIO.read(Texture.class.getResourceAsStream(resourceName));

        int w = img.getWidth();
        int h = img.getHeight();

        ByteBuffer pixels = BufferUtils.createByteBuffer(w * h * 4);
        int[] rawPixels = new int[w * h];

        img.getRGB(0, 0, w, h, rawPixels, 0, w);

        for (int i = 0; i < rawPixels.length; i++){
            int a = rawPixels[i] >> 24 & 0xFF;
            int r = rawPixels[i] >> 16 & 0xFF;
            int g = rawPixels[i] >> 8 & 0xFF;
            int b = rawPixels[i] & 0xFF;

            rawPixels[i] = (a << 24 | b << 16 | g << 8 | r);
        }

        pixels.asIntBuffer().put(rawPixels);
        GLU.gluBuild2DMipmaps(3553, 6408, w, h, 6408, 5121, pixels);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
    }catch (IOException e){
        throw new RuntimeException("!!");
    }
}
 
开发者ID:Vinetos,项目名称:FreeWorld,代码行数:44,代码来源:Texture.java

示例9: updateSubImage

import java.nio.IntBuffer; //导入方法依赖的package包/类
public static void updateSubImage(MultiTexID multiTex, int[] src, int width, int height, int posX, int posY, boolean linear, boolean clamp)
{
    int i = width * height;
    IntBuffer intbuffer = getIntBuffer(i);
    intbuffer.clear();
    intbuffer.put(src, 0, i);
    intbuffer.position(0).limit(i);
    GlStateManager.bindTexture(multiTex.base);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
    GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, posX, posY, width, height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)intbuffer);

    if (src.length == i * 3)
    {
        intbuffer.clear();
        intbuffer.put(src, i, i).position(0);
        intbuffer.position(0).limit(i);
    }

    GlStateManager.bindTexture(multiTex.norm);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
    GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, posX, posY, width, height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)intbuffer);

    if (src.length == i * 3)
    {
        intbuffer.clear();
        intbuffer.put(src, i * 2, i);
        intbuffer.position(0).limit(i);
    }

    GlStateManager.bindTexture(multiTex.spec);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
    GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, posX, posY, width, height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)intbuffer);
    GlStateManager.setActiveTexture(33984);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:44,代码来源:ShadersTex.java

示例10: installShaders

import java.nio.IntBuffer; //导入方法依赖的package包/类
private void installShaders(GL2 gl) throws IOException {
        if (shadersInstalled) {
            return;
        }
        gl.glEnable(GL3.GL_PROGRAM_POINT_SIZE);
        checkEventVertexBufferAllocation(BUF_INITIAL_SIZE_EVENTS);

        shadersInstalled = true;
        IntBuffer b = IntBuffer.allocate(8); // buffer to hold return values
        shaderprogram = gl.glCreateProgram();
        vertexShader = gl.glCreateShader(GL2ES2.GL_VERTEX_SHADER);
        fragmentShader = gl.glCreateShader(GL2ES2.GL_FRAGMENT_SHADER);
        checkGLError(gl, "creating shaders and shader program");

        String vsrc = readFromStream(SpaceTimeRollingEventDisplayMethod.class
                .getResourceAsStream("SpaceTimeRollingEventDisplayMethod_Vertex.glsl"));
        gl.glShaderSource(vertexShader, 1, new String[]{vsrc}, (int[]) null, 0);
        gl.glCompileShader(vertexShader);
        b.clear();
        gl.glGetShaderiv(vertexShader, GL2ES2.GL_COMPILE_STATUS, b);
        if (b.get(0) != GL.GL_TRUE) {
            log.warning("error compiling vertex shader");
            printShaderLog(gl);
        }
        checkGLError(gl, "compiling vertex shader");

        String fsrc = readFromStream(SpaceTimeRollingEventDisplayMethod.class
                .getResourceAsStream("SpaceTimeRollingEventDisplayMethod_Fragment.glsl"));
        gl.glShaderSource(fragmentShader, 1, new String[]{fsrc}, (int[]) null, 0);
        gl.glCompileShader(fragmentShader);
        b.clear();
        gl.glGetShaderiv(fragmentShader, GL2ES2.GL_COMPILE_STATUS, b);
        if (b.get(0) != GL.GL_TRUE) {
            log.warning("error compiling fragment shader");
            printShaderLog(gl);
        }
        checkGLError(gl, "compiling fragment shader");

        gl.glAttachShader(shaderprogram, vertexShader);
        gl.glAttachShader(shaderprogram, fragmentShader);

        gl.glLinkProgram(shaderprogram);
        b.clear();
//        gl.glGetShaderiv(shaderprogram, GL2ES2.GL_COMPILE_STATUS, b);
//        if (b.get(0) != GL.GL_TRUE) {
//            log.warning("error linking shader program");
//            printShaderLog(gl);
//        }

        checkGLError(gl, "linking shader program");
        b.clear();
        gl.glGenVertexArrays(1, b);
        vao = b.get(0);
        gl.glBindVertexArray(vao);
        b.clear();
        gl.glGenBuffers(1, b);
        vbo = b.get(0);
        checkGLError(gl, "setting up vertex array and vertex buffer");

        gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo);
//        gl.glBindAttribLocation(shaderprogram, polarity_vert, "polarity"); // symbolic names in vertex and fragment shaders
        gl.glBindAttribLocation(shaderprogram, v_vert, "v");
//        gl.glBindAttribLocation(shaderprogram, polarity_frag, "frag_polarity");
        checkGLError(gl, "binding shader attributes");

        gl.glVertexAttribPointer(v_vert, 3, GL.GL_FLOAT, false, EVENT_SIZE_BYTES, 0);
//        gl.glVertexAttribPointer(polarity_vert, 1, GL.GL_FLOAT, false, EVENT_SIZE_BYTES, 3);
        checkGLError(gl, "setting vertex attribute pointers");
        idMv = gl.glGetUniformLocation(shaderprogram, "mv");
        idProj = gl.glGetUniformLocation(shaderprogram, "proj");
        idt0 = gl.glGetUniformLocation(shaderprogram, "t0");
        idt1 = gl.glGetUniformLocation(shaderprogram, "t1");
        idPointSize = gl.glGetUniformLocation(shaderprogram, "pointSize");
        if ((idMv < 0) || (idProj < 0) || (idt0 < 0) || (idt1 < 0) || (idPointSize < 0)) {
            throw new RuntimeException("cannot locate uniform variable idMv, idProj, idt0, idt1, or idPointSize in shader program");
        }
        checkGLError(gl, "getting IDs for uniform modelview and projection matrices in shaders");
    }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:79,代码来源:SpaceTimeRollingEventDisplayMethod.java

示例11: getTextureBuffer

import java.nio.IntBuffer; //导入方法依赖的package包/类
public static TextureBuffer getTextureBuffer(String path){
	IntBuffer w = BufferUtils.createIntBuffer(1);
	IntBuffer h = BufferUtils.createIntBuffer(1);
	IntBuffer c = BufferUtils.createIntBuffer(1);
	
	ByteBuffer data = ResourceLoader.getBytes(path);
	
	if(stbi_info_from_memory(data, w, h, c) != 1)
		Application.error("Unable to load:" + path);
	
	ByteBuffer formatted = stbi_load_from_memory(data, w, h, c, 0);
	
	if(formatted == null)
		Application.error("Unable to format file: " + path);
	
	int width = w.get(0);
	int height = h.get(0);
	int comp   = c.get(0);
	
	System.out.println("CAP");
	
	System.out.println(formatted.capacity());
	
	byte[] buf = new byte [formatted.remaining()];
	
	formatted.get(buf);
	
	data.clear();
	
	w.clear();
	h.clear();
	c.clear();
	
	return new TextureBuffer(path, buf, width, height, comp);
}
 
开发者ID:tek256,项目名称:LD38,代码行数:36,代码来源:Util.java

示例12: Texture

import java.nio.IntBuffer; //导入方法依赖的package包/类
public Texture(String path){
	this.path = path;
	
	IntBuffer w = BufferUtils.createIntBuffer(1);
	IntBuffer h = BufferUtils.createIntBuffer(1);
	IntBuffer c = BufferUtils.createIntBuffer(1);
	
	ByteBuffer data = ResourceLoader.getBytes(path);
	
	if(stbi_info_from_memory(data, w, h, c) != 1)
		Application.error("Unable to load:" + path);
	
	ByteBuffer formatted = stbi_load_from_memory(data, w, h, c, 0);
	
	if(formatted == null)
		Application.error("Unable to format file: " + path);
	
	width = w.get(0);
	height = h.get(0);
	comp   = c.get(0);
	
	size = new Vector2f(width, height);
	
	//load texture
	id = glGenTextures();

	glBindTexture(GL_TEXTURE_2D, id);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, formatted);
	
	GL30.glGenerateMipmap(GL_TEXTURE_2D);
	
	stbi_image_free(formatted);
	
	formatted.clear();
	data.clear();
	
	w.clear();
	h.clear();
	c.clear();
	
	textures.add(this);
}
 
开发者ID:tek256,项目名称:LD38,代码行数:46,代码来源:Texture.java


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