Java Code Examples for java.nio.IntBuffer

The following are top voted examples for showing how to use java.nio.IntBuffer. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Backmemed   File: Shaders.java   Source Code and License 6 votes vote down vote up
private static boolean printShaderLogInfo(int shader, String name, List<String> listFiles)
{
    IntBuffer intbuffer = BufferUtils.createIntBuffer(1);
    int i = GL20.glGetShaderi(shader, 35716);

    if (i <= 1)
    {
        return true;
    }
    else
    {
        for (int j = 0; j < listFiles.size(); ++j)
        {
            String s = (String)listFiles.get(j);
            SMCLog.info("File: " + (j + 1) + " = " + s);
        }

        String s1 = GL20.glGetShaderInfoLog(shader, i);
        SMCLog.info("Shader info log: " + name + "\n" + s1);
        return false;
    }
}
 
Example 2
Project: 19porn   File: OpenGlUtils.java   Source Code and License 6 votes vote down vote up
public static int loadTexture(final IntBuffer data, final Size size, final int usedTexId) {
    int textures[] = new int[1];
    if (usedTexId == NO_TEXTURE) {
        GLES20.glGenTextures(1, textures, 0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, size.width, size.height,
                0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, data);
    } else {
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, usedTexId);
        GLES20.glTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, size.width,
                size.height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, data);
        textures[0] = usedTexId;
    }
    return textures[0];
}
 
Example 3
Project: lwjgl3_stuff   File: Model.java   Source Code and License 6 votes vote down vote up
public Model(float[] vertices, float[] tex_coords, int[] indices) {
    draw_count = indices.length;

    v_id = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, v_id);
    glBufferData(GL_ARRAY_BUFFER, createBuffer(vertices), GL_STATIC_DRAW);

    t_id = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, t_id);
    glBufferData(GL_ARRAY_BUFFER, createBuffer(tex_coords), GL_STATIC_DRAW);

    i_id = glGenBuffers();

    IntBuffer buffer = BufferUtils.createIntBuffer(indices.length);
    buffer.put(indices);
    buffer.flip();

    glBufferData(GL_ELEMENT_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, i_id);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
}
 
Example 4
Project: multiple-dimension-spread   File: BufferDirectSequentialNumberCellIndex.java   Source Code and License 6 votes vote down vote up
@Override
public Set<Integer> getLt( final IDicManager dicManager , final IntBuffer dicIndexIntBuffer , final NumberFilter numberFilter ) throws IOException{
  long target;
  try{
    target = numberFilter.getNumberObject().getLong();
  }catch( NumberFormatException e ){
    return null;
  }
  Set<Integer> matchDicList = new HashSet<Integer>();
  for( int i = 0 ; i < dicManager.getDicSize() ; i++ ){
    PrimitiveObject numObj = dicManager.get( i );
    if( numObj == null ){
      continue;
    }
    if( numObj.getLong() < target ){
      matchDicList.add( Integer.valueOf( i ) );
    }
  }

  return matchDicList;
}
 
Example 5
Project: openjdk-jdk10   File: ImageReader.java   Source Code and License 6 votes vote down vote up
void visitPackageLocation(ImageLocation loc) {
    // Retrieve package name
    String pkgName = getBaseExt(loc);
    // Content is array of offsets in Strings table
    byte[] stringsOffsets = getResource(loc);
    ByteBuffer buffer = ByteBuffer.wrap(stringsOffsets);
    buffer.order(getByteOrder());
    IntBuffer intBuffer = buffer.asIntBuffer();
    // For each module, create a link node.
    for (int i = 0; i < stringsOffsets.length / SIZE_OF_OFFSET; i++) {
        // skip empty state, useless.
        intBuffer.get(i);
        i++;
        int offset = intBuffer.get(i);
        String moduleName = getString(offset);
        Node targetNode = findNode("/modules/" + moduleName);
        if (targetNode != null) {
            String pkgDirName = packagesDir.getName() + "/" + pkgName;
            Directory pkgDir = (Directory) nodes.get(pkgDirName);
            newLinkNode(pkgDir, pkgDir.getName() + "/" + moduleName, targetNode);
        }
    }
}
 
Example 6
Project: multiple-dimension-spread   File: BufferDirectSequentialNumberCellIndex.java   Source Code and License 6 votes vote down vote up
@Override
public Set<Integer> getGt( final IDicManager dicManager , final IntBuffer dicIndexIntBuffer , final NumberFilter numberFilter ) throws IOException{
  long target;
  try{
    target = numberFilter.getNumberObject().getLong();
  }catch( NumberFormatException e ){
    return null;
  }
  Set<Integer> matchDicList = new HashSet<Integer>();
  for( int i = 0 ; i < dicManager.getDicSize() ; i++ ){
    PrimitiveObject numObj = dicManager.get( i );
    if( numObj == null ){
      continue;
    }
    if( target < numObj.getLong() ){
      matchDicList.add( Integer.valueOf( i ) );
    }
  }

  return matchDicList;
}
 
Example 7
Project: multiple-dimension-spread   File: TestBufferDirectSequentialNumberCellIndexFloat.java   Source Code and License 6 votes vote down vote up
@Test
public void T_float_filter_8() throws IOException{
  List<PrimitiveObject> dic = new ArrayList<PrimitiveObject>();
  dic.add( new FloatObj( (float) 1.00001 ) );
  dic.add( new FloatObj( (float) 2.00001 ) );
  dic.add( new FloatObj( (float) 3.00001 ) );
  dic.add( new FloatObj( (float) 4.00001 ) );
  dic.add( new FloatObj( (float) 5.00001 ) );
  IntBuffer buffer = IntBuffer.allocate( 100 );
  for( int i = 0 ; i < 100 ; i++ ){
    buffer.put( i % 5 );
  }
  ICellIndex index = new BufferDirectSequentialNumberCellIndex( ColumnType.FLOAT , new TestDicManager( dic ) , buffer );
  IFilter filter = new NumberFilter( NumberFilterType.GE , new DoubleObj( Double.valueOf( Float.MIN_VALUE ) / (double)10 ) );

  assertEquals( null , index.filter( filter , new boolean[100] ) );
}
 
Example 8
Project: BWS-Android   File: ImageFormatConverter.java   Source Code and License 6 votes vote down vote up
/**
 * Converts a GrayscaleImage to a Bitmap.
 */
@NonNull
public Bitmap grayscaleImageToBitmap(@NonNull GrayscaleImage img) {
    String stopwatchSessionId = log.startStopwatch(getStopwatchSessionId("grayscaleImageToBitmap"));

    int size = img.width * img.height;
    int[] buffer = new int[size];

    for (int index = 0; index < size; index++) {
        // "AND 0xff" for the signed byte issue
        int luminance = img.data[index] & 0xff;
        // normal encoding for bitmap
        buffer[index] = (0xff000000 | luminance << 16 | luminance << 8 | luminance);
    }

    Bitmap bitmap = Bitmap.createBitmap(img.width, img.height, Bitmap.Config.ARGB_8888);
    bitmap.copyPixelsFromBuffer(IntBuffer.wrap(buffer));

    log.stopStopwatch(stopwatchSessionId);
    return bitmap;
}
 
Example 9
Project: multiple-dimension-spread   File: TestBufferDirectSequentialNumberCellIndexShort.java   Source Code and License 6 votes vote down vote up
@Test
public void T_short_filter_4() throws IOException{
  List<PrimitiveObject> dic = new ArrayList<PrimitiveObject>();
  dic.add( new ShortObj( (short) 1000 ) );
  dic.add( new ShortObj( (short) 2000 ) );
  dic.add( new ShortObj( (short) 3000 ) );
  dic.add( new ShortObj( (short) 4000 ) );
  dic.add( new ShortObj( (short) 5000 ) );
  IntBuffer buffer = IntBuffer.allocate( 100 );
  for( int i = 0 ; i < 100 ; i++ ){
    buffer.put( i % 5 );
  }
  ICellIndex index = new BufferDirectSequentialNumberCellIndex( ColumnType.SHORT , new TestDicManager( dic ) , buffer );
  IFilter filter = new NumberFilter( NumberFilterType.LE , new ShortObj( (short) 2000 ) );

  FilterdExpressionIndex result = new FilterdExpressionIndex( index.filter( filter , new boolean[100] ) );
  assertEquals( result.size() , 40 );
  for( int i = 0,n=0 ; n < 100 ; i+=2,n+=5 ){
    assertEquals( result.get(i) , n );
    assertEquals( result.get(i+1) , n+1 );
  }
}
 
Example 10
Project: multiple-dimension-spread   File: BufferDirectSequentialNumberCellIndex.java   Source Code and License 6 votes vote down vote up
@Override
public Set<Integer> getGt( final IDicManager dicManager , final IntBuffer dicIndexIntBuffer , final NumberFilter numberFilter ) throws IOException{
  byte target;
  try{
    target = numberFilter.getNumberObject().getByte();
  }catch( NumberFormatException e ){
    return null;
  }
  Set<Integer> matchDicList = new HashSet<Integer>();
  for( int i = 0 ; i < dicManager.getDicSize() ; i++ ){
    PrimitiveObject numObj = dicManager.get( i );
    if( numObj == null ){
      continue;
    }
    if( target < numObj.getByte() ){
      matchDicList.add( Integer.valueOf( i ) );
    }
  }

  return matchDicList;
}
 
Example 11
Project: trashjam2017   File: StreamSound.java   Source Code and License 6 votes vote down vote up
/**
 * Clean up the buffers applied to the sound source
 */
private void cleanUpSource() {
	SoundStore store = SoundStore.get();
	
	AL10.alSourceStop(store.getSource(0));
	IntBuffer buffer = BufferUtils.createIntBuffer(1);
	int queued = AL10.alGetSourcei(store.getSource(0), AL10.AL_BUFFERS_QUEUED);
	
	while (queued > 0)
	{
		AL10.alSourceUnqueueBuffers(store.getSource(0), buffer);
		queued--;
	}
	
	AL10.alSourcei(store.getSource(0), AL10.AL_BUFFER, 0);
}
 
Example 12
Project: multiple-dimension-spread   File: BufferDirectSequentialNumberCellIndex.java   Source Code and License 6 votes vote down vote up
@Override
public Set<Integer> getGt( final IDicManager dicManager , final IntBuffer dicIndexIntBuffer , final NumberFilter numberFilter ) throws IOException{
  Float target;
  try{
    target = Float.valueOf( numberFilter.getNumberObject().getFloat() );
  }catch( NumberFormatException e ){
    return null;
  }
  Set<Integer> matchDicList = new HashSet<Integer>();
  for( int i = 0 ; i < dicManager.getDicSize() ; i++ ){
    PrimitiveObject numObj = dicManager.get( i );
    if( numObj == null ){
      continue;
    }
    if( target.compareTo( numObj.getFloat() ) < 0 ){
      matchDicList.add( Integer.valueOf( i ) );
    }
  }

  return matchDicList;
}
 
Example 13
Project: multiple-dimension-spread   File: BufferDirectSequentialNumberCellIndex.java   Source Code and License 6 votes vote down vote up
@Override
public Set<Integer> getGt( final IDicManager dicManager , final IntBuffer dicIndexIntBuffer , final NumberFilter numberFilter ) throws IOException{
  Double target;
  try{
    target = Double.valueOf( numberFilter.getNumberObject().getDouble() );
  }catch( NumberFormatException e ){
    return null;
  }
  Set<Integer> matchDicList = new HashSet<Integer>();
  for( int i = 0 ; i < dicManager.getDicSize() ; i++ ){
    PrimitiveObject numObj = dicManager.get( i );
    if( numObj == null ){
      continue;
    }
    if( target.compareTo( numObj.getDouble() ) < 0 ){
      matchDicList.add( Integer.valueOf( i ) );
    }
  }

  return matchDicList;
}
 
Example 14
Project: angel   File: ServerArbitraryIntRow.java   Source Code and License 6 votes vote down vote up
private void densePlusSparse(IntBuffer keys, IntBuffer values) {
  int length = keys.capacity();
  int ov, value, key;
  for (int i = 0; i < length; i++) {
    key = keys.get(i);
    ov = denseRep.get(key);
    value = ov + values.get(i);
    if (ov != 0 && value == 0)
      nnz--;
    denseRep.put(key, value);
  }

  int size = (int)(endCol - startCol);
  if (nnz < threshold * size)
    denseToSparse();
}
 
Example 15
Project: Synapse   File: DbHelper.java   Source Code and License 6 votes vote down vote up
@Nullable
private static int[] byteArray2IntArray(byte... array) {
    if (array == null) {
        return null;
    }

    final int[] res = new int[array.length >> 2];

    try {
        final IntBuffer buffer = ByteBuffer.wrap(array).asIntBuffer();

        for (int i = 0, iLen = res.length; i < iLen; ++i) {
            res[i] = buffer.get();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return res;
}
 
Example 16
Project: multiple-dimension-spread   File: TestBufferDirectSequentialNumberCellIndexByte.java   Source Code and License 6 votes vote down vote up
@Test
public void T_byte_filter_3() throws IOException{
  List<PrimitiveObject> dic = new ArrayList<PrimitiveObject>();
  dic.add( new ByteObj( (byte) 10 ) );
  dic.add( new ByteObj( (byte) 20 ) );
  dic.add( new ByteObj( (byte) 30 ) );
  dic.add( new ByteObj( (byte) 40 ) );
  dic.add( new ByteObj( (byte) 50 ) );
  IntBuffer buffer = IntBuffer.allocate( 100 );
  for( int i = 0 ; i < 100 ; i++ ){
    buffer.put( i % 5 );
  }
  ICellIndex index = new BufferDirectSequentialNumberCellIndex( ColumnType.BYTE , new TestDicManager( dic ) , buffer );
  IFilter filter = new NumberFilter( NumberFilterType.LT , new ByteObj( (byte) 20 ) );

  FilterdExpressionIndex result = new FilterdExpressionIndex( index.filter( filter , new boolean[100] ) );
  assertEquals( result.size() , 20 );
  for( int i = 0,n=0 ; n < 100 ; i++,n+=5 ){
    assertEquals( result.get(i) , n );
  }
}
 
Example 17
Project: multiple-dimension-spread   File: TestBufferDirectSequentialNumberCellIndexByte.java   Source Code and License 6 votes vote down vote up
@Test
public void T_byte_filter_8() throws IOException{
  List<PrimitiveObject> dic = new ArrayList<PrimitiveObject>();
  dic.add( new ByteObj( (byte) 10 ) );
  dic.add( new ByteObj( (byte) 20 ) );
  dic.add( new ByteObj( (byte) 30 ) );
  dic.add( new ByteObj( (byte) 40 ) );
  dic.add( new ByteObj( (byte) 50 ) );
  IntBuffer buffer = IntBuffer.allocate( 100 );
  for( int i = 0 ; i < 100 ; i++ ){
    buffer.put( i % 5 );
  }
  ICellIndex index = new BufferDirectSequentialNumberCellIndex( ColumnType.BYTE , new TestDicManager( dic ) , buffer );
  IFilter filter = new NumberFilter( NumberFilterType.GE , new LongObj( Long.valueOf( Byte.MIN_VALUE ) - (long)1 ) );

  assertEquals( null , index.filter( filter , new boolean[100] ) );
}
 
Example 18
Project: DecompiledMinecraft   File: TextureUtil.java   Source Code and License 5 votes vote down vote up
private static void uploadTextureSub(int p_147947_0_, int[] p_147947_1_, int p_147947_2_, int p_147947_3_, int p_147947_4_, int p_147947_5_, boolean p_147947_6_, boolean p_147947_7_, boolean p_147947_8_)
{
    int i = 4194304 / p_147947_2_;
    setTextureBlurMipmap(p_147947_6_, p_147947_8_);
    setTextureClamped(p_147947_7_);
    int l;

    for (int j = 0; j < p_147947_2_ * p_147947_3_; j += p_147947_2_ * l)
    {
        int k = j / p_147947_2_;
        l = Math.min(i, p_147947_3_ - k);
        int i1 = p_147947_2_ * l;
        copyToBufferPos(p_147947_1_, j, i1);
        GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, p_147947_0_, p_147947_4_, p_147947_5_ + k, p_147947_2_, l, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)dataBuffer);
    }
}
 
Example 19
Project: multiple-dimension-spread   File: OptimizeLongColumnBinaryMaker.java   Source Code and License 5 votes vote down vote up
@Override
public IntBuffer getIndexIntBuffer( final byte[] buffer , final int start , final int length ) throws IOException{
  int size = length / Short.BYTES;
  ByteBuffer wrapBuffer = ByteBuffer.wrap( buffer , start , length );
  IntBuffer result = IntBuffer.allocate( size );
  for( int i = 0 ; i < size ; i++ ){
    result.put( (int)( wrapBuffer.getShort() ) );
  }
  result.position( 0 );
  return result;
}
 
Example 20
Project: Ultraino   File: Shader.java   Source Code and License 5 votes vote down vote up
int createProgramFromBuffer(GL2 gl, String vProgram, String fProgram, HashMap<String,String> templates){
    int program = 0;
    vertexShader = initShader(gl, GL2.GL_VERTEX_SHADER, preProcessVertex( getSourceCode(vProgram), templates ));
    fragmentShader = initShader(gl, GL2.GL_FRAGMENT_SHADER, preProcessFragment( getSourceCode(fProgram), templates ));

    if (vertexShader != 0 && fragmentShader != 0) {
        program = gl.glCreateProgram();

        if (program != 0) {
            gl.glAttachShader(program, vertexShader);                
            gl.glAttachShader(program, fragmentShader);
            gl.glLinkProgram(program);
            IntBuffer linkStatus = BufferUtils.createIntBuffer(1);
            gl.glGetProgramiv(program, GL2.GL_LINK_STATUS, linkStatus);

            if (linkStatus.get(0) != GL2.GL_TRUE) {
                IntBuffer infoLen = BufferUtils.createIntBuffer(1);
                gl.glGetProgramiv(program, GL2.GL_INFO_LOG_LENGTH, infoLen);
                int length = infoLen.get();
                if (length != 0) {
                    ByteBuffer buf = BufferUtils.createByteBuffer(length);
                    infoLen.flip();
                    gl.glGetProgramInfoLog(program, length, infoLen, buf);
                    byte[] b = new byte[length];
                    buf.get(b);
                    System.err.println("Could not link program: " + new String(b));
                }
            }
        }
    }

    return program;
}
 
Example 21
Project: debug   File: ARBDirectStateAccess.java   Source Code and License 5 votes vote down vote up
public static void glCreateVertexArrays(IntBuffer arrays) {
    org.lwjgl.opengl.ARBDirectStateAccess.glCreateVertexArrays(arrays);
    if (Properties.VALIDATE.enabled) {
        Context context = CURRENT_CONTEXT.get();
        int position = arrays.position();
        for (int i = 0; i < arrays.remaining(); i++) {
            VAO vao = new VAO(context.GL_MAX_VERTEX_ATTRIBS);
            CURRENT_CONTEXT.get().vaos.put(arrays.get(position + i), vao);
        }
    }
}
 
Example 22
Project: DecompiledMinecraft   File: OpenGlHelper.java   Source Code and License 5 votes vote down vote up
public static void glUniform3(int location, IntBuffer values)
{
    if (arbShaders)
    {
        ARBShaderObjects.glUniform3ARB(location, values);
    }
    else
    {
        GL20.glUniform3(location, values);
    }
}
 
Example 23
Project: Backmemed   File: ShadersTex.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 24
Project: Towan   File: InternalTextureLoader.java   Source Code and License 5 votes vote down vote up
/**
 * Create a new texture ID 
 *
 * @return A new texture ID
 */
public static int createTextureID() 
{ 
   IntBuffer tmp = createIntBuffer(1); 
   GL.glGenTextures(tmp); 
   return tmp.get(0);
}
 
Example 25
Project: Backmemed   File: GlStateManager.java   Source Code and License 5 votes vote down vote up
public static void deleteTextures(IntBuffer p_deleteTextures_0_)
{
    p_deleteTextures_0_.rewind();

    while (p_deleteTextures_0_.position() < p_deleteTextures_0_.limit())
    {
        int i = p_deleteTextures_0_.get();
        deleteTexture(i);
    }

    p_deleteTextures_0_.rewind();
}
 
Example 26
Project: Backmemed   File: Shaders.java   Source Code and License 5 votes vote down vote up
private static IntBuffer fillIntBufferZero(IntBuffer buf)
{
    int i = buf.limit();

    for (int j = buf.position(); j < i; ++j)
    {
        buf.put(j, 0);
    }

    return buf;
}
 
Example 27
Project: Progetto-C   File: OpenALStreamPlayer.java   Source Code and License 5 votes vote down vote up
/**
 * Clean up the buffers applied to the sound source
 */
private void removeBuffers() {
	IntBuffer buffer = BufferUtils.createIntBuffer(1);
	int queued = AL10.alGetSourcei(source, AL10.AL_BUFFERS_QUEUED);
	
	while (queued > 0)
	{
		AL10.alSourceUnqueueBuffers(source, buffer);
		queued--;
	}
}
 
Example 28
Project: BaseClient   File: InternalTextureLoader.java   Source Code and License 5 votes vote down vote up
/**
 * Create a new texture ID 
 *
 * @return A new texture ID
 */
public static int createTextureID() 
{ 
   IntBuffer tmp = createIntBuffer(1); 
   GL.glGenTextures(tmp); 
   return tmp.get(0);
}
 
Example 29
Project: MC-Ray-Tracer   File: WorldLoader.java   Source Code and License 5 votes vote down vote up
/**
 * 
 * @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;
}
 
Example 30
Project: Backmemed   File: Mipmaps.java   Source Code and License 5 votes vote down vote up
public static void allocateMipmapTextures(int p_allocateMipmapTextures_0_, int p_allocateMipmapTextures_1_, String p_allocateMipmapTextures_2_)
{
    Dimension[] adimension = makeMipmapDimensions(p_allocateMipmapTextures_0_, p_allocateMipmapTextures_1_, p_allocateMipmapTextures_2_);

    for (int i = 0; i < adimension.length; ++i)
    {
        Dimension dimension = adimension[i];
        int j = dimension.width;
        int k = dimension.height;
        int l = i + 1;
        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, l, GL11.GL_RGBA, j, k, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)((IntBuffer)null));
    }
}
 
Example 31
Project: debug   File: Context.java   Source Code and License 5 votes vote down vote up
public static void deleteVertexArrays(IntBuffer indices) {
    Context context = CURRENT_CONTEXT.get();
    int pos = indices.position();
    for (int i = 0; i < indices.remaining(); i++) {
        int index = indices.get(pos + i);
        if (index == 0)
            continue;
        VAO vao = context.vaos.get(index);
        if (vao != null && vao == context.currentVao) {
            context.currentVao = context.defaultVao;
        }
        context.vaos.remove(index);
    }
}
 
Example 32
Project: debug   File: ARBDrawElementsBaseVertex.java   Source Code and License 5 votes vote down vote up
public static void glDrawElementsBaseVertex(int mode, IntBuffer indices, int basevertex) {
    if (Properties.VALIDATE.enabled) {
        checkBeforeDrawCall();
    }
    if (Properties.PROFILE.enabled) {
        RT.beforeDraw();
    }
    org.lwjgl.opengl.ARBDrawElementsBaseVertex.glDrawElementsBaseVertex(mode, indices, basevertex);
    if (Properties.PROFILE.enabled) {
        RT.draw(indices.remaining());
    }
}
 
Example 33
Project: angel   File: PeriodHATest.java   Source Code and License 5 votes vote down vote up
private long sum(IntBuffer buffer, int size) {
  long ret = 0L;
  for(int i = 0; i < size; i++) {
    ret += buffer.get(i);
  }

  return ret;
}
 
Example 34
Project: DecompiledMinecraft   File: OpenGlHelper.java   Source Code and License 5 votes vote down vote up
public static void glUniform1(int location, IntBuffer values)
{
    if (arbShaders)
    {
        ARBShaderObjects.glUniform1ARB(location, values);
    }
    else
    {
        GL20.glUniform1(location, values);
    }
}
 
Example 35
Project: G2Dj   File: Texture.java   Source Code and License 5 votes vote down vote up
@Override
protected void finalize() throws Throwable
{
    GL.glDeleteTextures(1, IntBuffer.wrap(new int[]{m_TextureHandle}));
    
    super.finalize();
    
}
 
Example 36
Project: debug   File: GL11.java   Source Code and License 5 votes vote down vote up
public static void glGetIntegerv(int pname, IntBuffer params) {
    if (Properties.PROFILE.enabled && pname == org.lwjgl.opengl.GL30.GL_NUM_EXTENSIONS) {
        int numExtensions = org.lwjgl.opengl.GL11.glGetInteger(pname);
        params.put(params.position(), numExtensions + 2); // <- for GREMEDY_string_marker and GREMEDY_frame_terminator
        return;
    }
    org.lwjgl.opengl.GL11.glGetIntegerv(pname, params);
}
 
Example 37
Project: debug   File: GL31.java   Source Code and License 5 votes vote down vote up
public static void glDrawElementsInstanced(int mode, IntBuffer indices, int primcount) {
    if (Properties.VALIDATE.enabled) {
        checkBeforeDrawCall();
    }
    if (Properties.PROFILE.enabled) {
        RT.beforeDraw();
    }
    org.lwjgl.opengl.GL31.glDrawElementsInstanced(mode, indices, primcount);
    if (Properties.PROFILE.enabled) {
        RT.draw(indices.remaining() * primcount);
    }
}
 
Example 38
Project: mao-android   File: CameraView.java   Source Code and License 5 votes vote down vote up
public void capture(final ICaptureCallback callback) {
    mLog.i("capture");
    runOnDrawEnd(new Runnable() {
        @Override
        public void run() {
            IntBuffer ib = IntBuffer.allocate(mSurfaceWidth * mSurfaceHeight);
            GLES20.glReadPixels(0, 0, mSurfaceWidth, mSurfaceHeight, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ib);
            Bitmap result = Bitmap.createBitmap(mSurfaceWidth, mSurfaceHeight, Bitmap.Config.ARGB_8888);
            result.copyPixelsFromBuffer(ib);

            callback.onCapture(result);
        }
    });
}
 
Example 39
Project: Progetto-C   File: InternalTextureLoader.java   Source Code and License 5 votes vote down vote up
/**
 * Create a new texture ID 
 *
 * @return A new texture ID
 */
public static int createTextureID() 
{ 
   IntBuffer tmp = createIntBuffer(1); 
   GL.glGenTextures(tmp); 
   return tmp.get(0);
}
 
Example 40
Project: Mass   File: StaticMeshLoader.java   Source Code and License 5 votes vote down vote up
/**
 * Proceses the indices of a mesh.
 * 
 * @param aiMesh - AIMesh to process indices for.
 * @param indices - List of indices to add processed indices to.
 */
private static void processIndices(AIMesh aiMesh, List<Integer> indices) {
	int numFaces = aiMesh.mNumFaces();
	AIFace.Buffer aiFaces = aiMesh.mFaces();
	
	for (int i = 0; i < numFaces; i++) {
		AIFace aiFace = aiFaces.get();
		IntBuffer buffer = aiFace.mIndices();
		while (buffer.remaining() > 0) {
			indices.add(buffer.get());
		}
	}
}