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


Java BufferUtils.createIntBuffer方法代码示例

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


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

示例1: cleanUpSource

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:19,代码来源:StreamSound.java

示例2: ShaderUniform

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
public ShaderUniform(String name, int type, int count, ShaderManager manager)
{
    this.shaderName = name;
    this.uniformCount = count;
    this.uniformType = type;
    this.shaderManager = manager;

    if (type <= 3)
    {
        this.uniformIntBuffer = BufferUtils.createIntBuffer(count);
        this.uniformFloatBuffer = null;
    }
    else
    {
        this.uniformIntBuffer = null;
        this.uniformFloatBuffer = BufferUtils.createFloatBuffer(count);
    }

    this.uniformLocation = -1;
    this.markDirty();
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:22,代码来源:ShaderUniform.java

示例3: init

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
/**
* Initialise OpenAL LWJGL styley
*/
  public void init() {
  	try {
	AL.create();
	soundWorks = true;
} catch (LWJGLException e) {
	System.err.println("Failed to initialise LWJGL OpenAL");
	soundWorks = false;
	return;
}

if (soundWorks) {
	IntBuffer sources = BufferUtils.createIntBuffer(1);
	AL10.alGenSources(sources);
	
	if (AL10.alGetError() != AL10.AL_NO_ERROR) {
		System.err.println("Failed to create sources");
		soundWorks = false;
	} else {
		source = sources.get(0);
	}
	
}
  }
 
开发者ID:imaTowan,项目名称:Towan,代码行数:27,代码来源:OpenALMODPlayer.java

示例4: destroy

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
/**
 * @see org.newdawn.slick.Graphics#destroy()
 */
public void destroy() {
	super.destroy();

	IntBuffer buffer = BufferUtils.createIntBuffer(1);
	buffer.put(FBO);
	buffer.flip();
	
	EXTFramebufferObject.glDeleteFramebuffersEXT(buffer);
	valid = false;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:14,代码来源:FBOGraphics.java

示例5: loadImageToByteBuffer

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
public static ByteBuffer loadImageToByteBuffer(String file){
		ByteBuffer imageBuffer;
        try {
            imageBuffer = ioResourceToByteBuffer(file, 128 * 128);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        
        IntBuffer w    = BufferUtils.createIntBuffer(1);
        IntBuffer h    = BufferUtils.createIntBuffer(1);
        IntBuffer c = BufferUtils.createIntBuffer(1);

        // Use info to read image metadata without decoding the entire image.
        if (!stbi_info_from_memory(imageBuffer, w, h, c)) {
            throw new RuntimeException("Failed to read image information: " + stbi_failure_reason());
        }
  
//        System.out.println("Image width: " + w.get(0));
//        System.out.println("Image height: " + h.get(0));
//        System.out.println("Image components: " + c.get(0));
//        System.out.println("Image HDR: " + stbi_is_hdr_from_memory(imageBuffer));

        // Decode the image
        ByteBuffer image = stbi_load_from_memory(imageBuffer, w, h, c, 0);
        if (image == null) {
            throw new RuntimeException("Failed to load image: " + stbi_failure_reason());
        }
        
        return image;
	}
 
开发者ID:oreonengine,项目名称:Lwjgl3-Game-Engine-Programming-Series,代码行数:31,代码来源:ImageLoader.java

示例6: OpenALStreamPlayer

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
/**
 * Create a new player to work on an audio stream
 * 
 * @param source The source on which we'll play the audio
 * @param url A reference to the audio file to stream
 */
public OpenALStreamPlayer(int source, URL url) {
	this.source = source;
	this.url = url;

	bufferNames = BufferUtils.createIntBuffer(BUFFER_COUNT);
	AL10.alGenBuffers(bufferNames);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:14,代码来源:OpenALStreamPlayer.java

示例7: printLogInfo

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
private static boolean printLogInfo(int obj, String name)
{
    IntBuffer intbuffer = BufferUtils.createIntBuffer(1);
    ARBShaderObjects.glGetObjectParameterARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB, (IntBuffer)intbuffer);
    int i = intbuffer.get();

    if (i > 1)
    {
        ByteBuffer bytebuffer = BufferUtils.createByteBuffer(i);
        intbuffer.flip();
        ARBShaderObjects.glGetInfoLogARB(obj, intbuffer, bytebuffer);
        byte[] abyte = new byte[i];
        bytebuffer.get(abyte);

        if (abyte[i - 1] == 0)
        {
            abyte[i - 1] = 10;
        }

        String s = new String(abyte);
        SMCLog.info("Info log: " + name + "\n" + s);
        return false;
    }
    else
    {
        return true;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:29,代码来源:Shaders.java

示例8: removeBuffers

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
/**
 * 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--;
	}
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:14,代码来源:OpenALStreamPlayer.java

示例9: storeDataInIntBuffer

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
/**
 * Stores given data to a int buffer for use
 * @param data - Data to store into buffer.
 * @return - Returns buffer with data in it.
 */
private IntBuffer storeDataInIntBuffer(int[] data) {
    IntBuffer buffer = BufferUtils.createIntBuffer(data.length);
    buffer.put(data);
    buffer.flip();
    return buffer;
}
 
开发者ID:Essentria,项目名称:Elgin-Plant-Game,代码行数:12,代码来源:Loader.java

示例10: Track

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
/**
 * (Probably don't use this unless you have a really specific reason!)
 * Creates a new Track from the wav file at filepath, with custom source position, source velocity,
 * gain and pitch.
 * @param filepath The path to the wav file to load in.
 * @param sourcePos Custom position of the source - (Float, Float, Float).
 * @param sourceVel Custom velocity of the source - (Float, Float, Float).
 * @param gain Custom gain of the track.
 * @param pitch Custom pitch of the track.
 */
public Track(String filepath, FloatBuffer sourcePos, FloatBuffer sourceVel, Float gain, Float pitch) {
    buffer = BufferUtils.createIntBuffer(1);
    source = BufferUtils.createIntBuffer(1);

    this.sourcePos = sourcePos;
    this.sourceVel = sourceVel;
    this.gain = gain;
    this.pitch = pitch;

    loadALData(filepath);
}
 
开发者ID:TauOmicronMu,项目名称:TeamProject,代码行数:22,代码来源:AudioEngine.java

示例11: init

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
/**
 * Initialise the FBO that will be used to render to
 * 
 * @throws SlickException
 */
private void init() throws SlickException {
	IntBuffer buffer = BufferUtils.createIntBuffer(1);
	EXTFramebufferObject.glGenFramebuffersEXT(buffer); 
	FBO = buffer.get();

	// for some reason FBOs won't work on textures unless you've absolutely just
	// created them.
	try {
		Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter());
		
		EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, FBO);
		EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 
													   EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT,
													   GL11.GL_TEXTURE_2D, tex.getTextureID(), 0);
		
		completeCheck();
		unbind();
		
		// Clear our destination area before using it
		clear();
		flush();
		
		// keep hold of the original content
		drawImage(image, 0, 0);
		image.setTexture(tex);
		
	} catch (Exception e) {
		throw new SlickException("Failed to create new texture for FBO");
	}
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:36,代码来源:FBOGraphics.java

示例12: getTexture

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
/**
 * Get a texture from a image file
 * 
 * @param dataSource The image data to generate the texture from
 * @param filter The filter to use when scaling the texture
 * @return The texture created
 * @throws IOException Indicates the texture is too big for the hardware
 */
public Texture getTexture(ImageData dataSource, int filter) throws IOException
{ 
	int target = SGL.GL_TEXTURE_2D;

    ByteBuffer textureBuffer;
	textureBuffer = dataSource.getImageBufferData();
	
    // create the texture ID for this texture 
    int textureID = createTextureID(); 
    TextureImpl texture = new TextureImpl("generated:"+dataSource, target ,textureID); 
    
    int minFilter = filter;
    int magFilter = filter;
    boolean flipped = false;
    
    // bind this texture 
    GL.glBindTexture(target, textureID); 
	
    int width;
    int height;
    int texWidth;
    int texHeight;
    
    boolean hasAlpha;
	
	width = dataSource.getWidth();
	height = dataSource.getHeight();
	hasAlpha = dataSource.getDepth() == 32;
	
	texture.setTextureWidth(dataSource.getTexWidth());
	texture.setTextureHeight(dataSource.getTexHeight());

    texWidth = texture.getTextureWidth();
    texHeight = texture.getTextureHeight();
    
    int srcPixelFormat = hasAlpha ? SGL.GL_RGBA : SGL.GL_RGB;
    int componentCount = hasAlpha ? 4 : 3;
    
    texture.setWidth(width);
    texture.setHeight(height);
    texture.setAlpha(hasAlpha);
    
    IntBuffer temp = BufferUtils.createIntBuffer(16);
    GL.glGetInteger(SGL.GL_MAX_TEXTURE_SIZE, temp);
    int max = temp.get(0);
    if ((texWidth > max) || (texHeight > max)) {
    	throw new IOException("Attempt to allocate a texture to big for the current hardware");
    }

    if (holdTextureData) {
    	texture.setTextureData(srcPixelFormat, componentCount, minFilter, magFilter, textureBuffer);
    }
    
    GL.glTexParameteri(target, SGL.GL_TEXTURE_MIN_FILTER, minFilter); 
    GL.glTexParameteri(target, SGL.GL_TEXTURE_MAG_FILTER, magFilter); 
    
    // produce a texture from the byte buffer
    GL.glTexImage2D(target, 
                  0, 
                  dstPixelFormat, 
                  get2Fold(width), 
                  get2Fold(height), 
                  0, 
                  srcPixelFormat, 
                  SGL.GL_UNSIGNED_BYTE, 
                  textureBuffer); 
    
    return texture; 
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:78,代码来源:InternalTextureLoader.java

示例13: getWAV

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
/**
 * Get the Sound based on a specified WAV file
 * 
 * @param ref The reference to the WAV file in the classpath
 * @param in The stream to the WAV to load
 * @return The Sound read from the WAV file
 * @throws IOException Indicates a failure to load the WAV
 */
public Audio getWAV(String ref, InputStream in) throws IOException {
	if (!soundWorks) {
		return new NullAudio();
	}
	if (!inited) {
		throw new RuntimeException("Can't load sounds until SoundStore is init(). Use the container init() method.");
	}
	if (deferred) {
		return new DeferredSound(ref, in, DeferredSound.WAV);
	}
	
	int buffer = -1;
	
	if (loaded.get(ref) != null) {
		buffer = ((Integer) loaded.get(ref)).intValue();
	} else {
		try {
			IntBuffer buf = BufferUtils.createIntBuffer(1);
			
			WaveData data = WaveData.create(in);
			AL10.alGenBuffers(buf);
			AL10.alBufferData(buf.get(0), data.format, data.data, data.samplerate);
			
			loaded.put(ref,new Integer(buf.get(0)));
			buffer = buf.get(0);
		} catch (Exception e) {
			Log.error(e);
			IOException x = new IOException("Failed to load: "+ref);
			x.initCause(e);
			
			throw x;
		}
	}
	
	if (buffer == -1) {
		throw new IOException("Unable to load: "+ref);
	}
	
	return new AudioImpl(this, buffer);
}
 
开发者ID:imaTowan,项目名称:Towan,代码行数:49,代码来源:SoundStore.java

示例14: storeDataInIntBuffer

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
private IntBuffer storeDataInIntBuffer(int[] data) {
	IntBuffer buffer = BufferUtils.createIntBuffer(data.length);
	buffer.put(data);
	buffer.flip();
	return buffer;
}
 
开发者ID:marcioz98,项目名称:MRCEngine,代码行数:7,代码来源:Loader.java

示例15: getTexture

import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
/**
   * Get a texture from a image file
   * 
   * @param in The stream from which we can load the image
   * @param resourceName The name to give this image in the internal cache
   * @param flipped True if we should flip the image on the y-axis while loading
   * @param target The texture target we're loading this texture into
   * @param minFilter The scaling down filter
   * @param magFilter The scaling up filter
* @param transparent The colour to interpret as transparent or null if none
   * @return The texture loaded
   * @throws IOException Indicates a failure to load the image
   */
  private TextureImpl getTexture(InputStream in, 
  						  String resourceName, 
                            int target, 
                            int magFilter, 
                            int minFilter, boolean flipped, int[] transparent) throws IOException 
  { 
      // create the texture ID for this texture 
      ByteBuffer textureBuffer;
      
      LoadableImageData imageData = ImageDataFactory.getImageDataFor(resourceName);
  	textureBuffer = imageData.loadImage(new BufferedInputStream(in), flipped, transparent);

      int textureID = createTextureID(); 
      TextureImpl texture = new TextureImpl(resourceName, target, textureID); 
      // bind this texture 
      GL.glBindTexture(target, textureID); 
 
      int width;
      int height;
      int texWidth;
      int texHeight;
      
      boolean hasAlpha;
      
  	width = imageData.getWidth();
  	height = imageData.getHeight();
  	hasAlpha = imageData.getDepth() == 32;
  	
  	texture.setTextureWidth(imageData.getTexWidth());
  	texture.setTextureHeight(imageData.getTexHeight());

      texWidth = texture.getTextureWidth();
      texHeight = texture.getTextureHeight();

      IntBuffer temp = BufferUtils.createIntBuffer(16);
      GL.glGetInteger(SGL.GL_MAX_TEXTURE_SIZE, temp);
      int max = temp.get(0);
      if ((texWidth > max) || (texHeight > max)) {
      	throw new IOException("Attempt to allocate a texture to big for the current hardware");
      }
      
      int srcPixelFormat = hasAlpha ? SGL.GL_RGBA : SGL.GL_RGB;
      int componentCount = hasAlpha ? 4 : 3;
      
      texture.setWidth(width);
      texture.setHeight(height);
      texture.setAlpha(hasAlpha);

      if (holdTextureData) {
      	texture.setTextureData(srcPixelFormat, componentCount, minFilter, magFilter, textureBuffer);
      }
      
      GL.glTexParameteri(target, GL.GL_TEXTURE_MIN_FILTER, minFilter); 
      GL.glTexParameteri(target, GL.GL_TEXTURE_MAG_FILTER, magFilter); 
      
      // produce a texture from the byte buffer
      GL.glTexImage2D(target, 
                    0, 
                    dstPixelFormat, 
                    get2Fold(width), 
                    get2Fold(height), 
                    0, 
                    srcPixelFormat, 
                    SGL.GL_UNSIGNED_BYTE, 
                    textureBuffer); 
      
      return texture; 
  }
 
开发者ID:imaTowan,项目名称:Towan,代码行数:82,代码来源:InternalTextureLoader.java


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