本文整理匯總了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);
}
示例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();
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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--;
}
}
示例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;
}
示例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);
}
示例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");
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}