Java Code Examples for org.lwjgl.BufferUtils#createIntBuffer()
The following examples show how to use
org.lwjgl.BufferUtils#createIntBuffer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Model.java From LWJGL-3-Tutorial with MIT License | 6 votes |
public Model(float[] vertices, float[] tex_coords, int[] indices) { drawCount = indices.length; vertexObject = glGenBuffers(); glBindBuffer(GL_ARRAY_BUFFER, vertexObject); glBufferData(GL_ARRAY_BUFFER, createBuffer(vertices), GL_STATIC_DRAW); textureCoordObject = glGenBuffers(); glBindBuffer(GL_ARRAY_BUFFER, textureCoordObject); glBufferData(GL_ARRAY_BUFFER, createBuffer(tex_coords), GL_STATIC_DRAW); indexObject = glGenBuffers(); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexObject); 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, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); }
Example 2
Source File: GLIntImage.java From tribaltrouble with GNU General Public License v2.0 | 6 votes |
public final IntBuffer createCursorPixels() { IntBuffer cursor_pixels = BufferUtils.createIntBuffer(pixels.capacity()); boolean true_alpha_supported = (org.lwjgl.input.Cursor.getCapabilities() & org.lwjgl.input.Cursor.CURSOR_8_BIT_ALPHA) != 0; while (pixels.hasRemaining()) { int rgba_pixel = pixels.get(); int r = (rgba_pixel >> 24) & 0xff; int g = (rgba_pixel >> 16) & 0xff; int b = (rgba_pixel >> 8) & 0xff; int a = rgba_pixel & 0xff; if (!true_alpha_supported && a != 0) a = 0xff; int cursor_pixel = (a << 24) | (r << 16) | (g << 8) | b; cursor_pixels.put(cursor_pixel); } pixels.clear(); cursor_pixels.clear(); return cursor_pixels; }
Example 3
Source File: DesktopComputeJobManager.java From graphicsfuzz with Apache License 2.0 | 6 votes |
@Override public void prepareEnvironment(JsonObject environmentJson) { final JsonObject bufferJson = environmentJson.get("buffer").getAsJsonObject(); final int bufferBinding = bufferJson.get("binding").getAsInt(); final int[] bufferInput = UniformSetter.getIntArray(bufferJson.get("input").getAsJsonArray()); final IntBuffer intBufferData = BufferUtils.createIntBuffer(bufferInput.length); intBufferData.put(bufferInput); intBufferData.flip(); shaderStorageBufferObject = GL15.glGenBuffers(); checkError(); GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, shaderStorageBufferObject); checkError(); GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, intBufferData, GL15.GL_STATIC_DRAW); checkError(); GL30.glBindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, bufferBinding, shaderStorageBufferObject); checkError(); numGroups = UniformSetter.getIntArray(environmentJson.get("num_groups").getAsJsonArray()); }
Example 4
Source File: VkImageLoader.java From oreon-engine with GNU General Public License v3.0 | 6 votes |
public static ImageMetaData getImageMetaData(String file){ ByteBuffer imageBuffer; try { imageBuffer = ioResourceToByteBuffer(file, 128 * 128); } catch (IOException e) { throw new RuntimeException(e); } IntBuffer x = BufferUtils.createIntBuffer(1); IntBuffer y = BufferUtils.createIntBuffer(1); IntBuffer channels = BufferUtils.createIntBuffer(1); // Use info to read image metadata without decoding the entire image. if (!stbi_info_from_memory(imageBuffer, x, y, channels)) { throw new RuntimeException("Failed to read image information: " + stbi_failure_reason()); } return new ImageMetaData(x.get(0), y.get(0), channels.get(0)); }
Example 5
Source File: FramebufferRenderer.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
private void deleteBuffers() { IntBuffer tmp = BufferUtils.createIntBuffer(4); tmp.put(0, fb_id); EXTFramebufferObject.glDeleteFramebuffersEXT(tmp); tmp.put(0, rb_id); EXTFramebufferObject.glDeleteRenderbuffersEXT(tmp); }
Example 6
Source File: GearGL33.java From ldparteditor with MIT License | 5 votes |
public GearGL33() { bvertices = BufferUtils.createFloatBuffer(3); bvertices.put(0f); bvertices.put(0f); bvertices.put(0f); bindices = BufferUtils.createIntBuffer(3); bindices.put((short) 0); bindices.put((short) 0); bindices.put((short) 0); bvertices.flip(); bindices.flip(); }
Example 7
Source File: FramebufferTextureRenderer.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
private void deleteBuffers() { IntBuffer tmp = BufferUtils.createIntBuffer(4); tmp.put(0, fb_id); EXTFramebufferObject.glDeleteFramebuffersEXT(tmp); tmp.put(0, rb_id); GL11.glDeleteTextures(tmp); }
Example 8
Source File: OpenALStreamPlayer.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
/** * Create a new player to work on an audio stream * * @param source The source on which we'll play the audio * @param ref A reference to the audio file to stream */ public OpenALStreamPlayer(int source, String ref) { this.source = source; this.ref = ref; bufferNames = BufferUtils.createIntBuffer(BUFFER_COUNT); AL10.alGenBuffers(bufferNames); }
Example 9
Source File: FBOGraphics.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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"); } }
Example 10
Source File: Vbo.java From OpenGL-Animation with The Unlicense | 4 votes |
public void storeData(int[] data){ IntBuffer buffer = BufferUtils.createIntBuffer(data.length); buffer.put(data); buffer.flip(); storeData(buffer); }
Example 11
Source File: Test.java From tribaltrouble with GNU General Public License v2.0 | 4 votes |
public final static void main(String[] args) { try { Display.setDisplayMode(new DisplayMode(DISPLAY_WIDTH, DISPLAY_HEIGHT)); Display.create(); initGL(); // Load font InputStream font_is = Utils.makeURL("/fonts/tahoma.ttf").openStream(); java.awt.Font src_font = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, font_is); java.awt.Font font = src_font.deriveFont(14f); // Load text InputStreamReader text_is = new InputStreamReader(Utils.makeURL("/test_text.txt").openStream()); StringBuffer str_buffer = new StringBuffer(); int c = text_is.read(); do { str_buffer.append((char)c); c = text_is.read(); } while (c != -1); String str = str_buffer.toString(); // Build texture int[] pixels = new int[WIDTH*HEIGHT]; // ByteBuffer pixel_data = ByteBuffer.wrap(pixels); // NEW // pixelDataFromString(WIDTH, HEIGHT, str, font, pixels); // NEW IntBuffer pixel_data = BufferUtils.createIntBuffer(WIDTH*HEIGHT); // OLD pixel_data.put(pixels); // OLD pixel_data.rewind(); int texture_handle = createTexture(WIDTH, HEIGHT, pixel_data); FontRenderContext frc = g2d.getFontRenderContext(); AttributedString att_str = new AttributedString(str); att_str.addAttribute(TextAttribute.FONT, font); AttributedCharacterIterator iterator = att_str.getIterator(); LineBreakMeasurer measurer = new LineBreakMeasurer(iterator, frc); while (!Display.isCloseRequested()) { long start_time = System.currentTimeMillis(); for (int i = 0; i < 10; i++) { pixelDataFromString(WIDTH, HEIGHT, str, font, pixels, measurer); pixel_data.put(pixels); // OLD pixel_data.rewind(); //texture_handle = createTexture(WIDTH, HEIGHT, pixel_data); updateTexture(WIDTH, HEIGHT, pixel_data); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glLoadIdentity(); // Background /* GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor4f(.1f, .1f, .1f, 1f); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(0f, DISPLAY_HEIGHT-RENDER_SIZE, 1f); GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT-RENDER_SIZE, 1f); GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT, 1f); GL11.glVertex3f(0f, DISPLAY_HEIGHT, 1f); GL11.glEnd(); */ // Text GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glColor4f(1f, 1f, 1f, 1f); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0f, 1f); GL11.glVertex3f(0f, DISPLAY_HEIGHT-RENDER_SIZE, 1f); GL11.glTexCoord2f(1f, 1f); GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT-RENDER_SIZE, 1f); GL11.glTexCoord2f(1f, 0f); GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT, 1f); GL11.glTexCoord2f(0f, 0f); GL11.glVertex3f(0f, DISPLAY_HEIGHT, 1f); GL11.glEnd(); Display.update(); } long total_time = System.currentTimeMillis() - start_time; System.out.println("total_time = " + total_time); } Display.destroy(); } catch (Exception t) { t.printStackTrace(); } }
Example 12
Source File: LwjglTextureUtils.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 4 votes |
public static int createTexture(BufferedImage[] mips, TextureFilter filterMode) { IntBuffer buff = BufferUtils.createIntBuffer(16); buff.limit(1); GL11.glGenTextures(buff); int textureId = buff.get(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); if (filterMode == TextureFilter.NEAREST) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); } else { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); } GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); for (int mip=0; mip<mips.length; mip++) { BufferedImage imageData = mips[mip]; imageData = convertToGlFormat(imageData); ByteBuffer scratch = ByteBuffer.allocateDirect(4*imageData.getWidth()*imageData.getHeight()); Raster raster = imageData.getRaster(); byte data[] = (byte[])raster.getDataElements(0, 0, imageData.getWidth(), imageData.getHeight(), null); scratch.clear(); scratch.put(data); scratch.rewind(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, mip, GL11.GL_RGBA, // Mip level & Internal format imageData.getWidth(), imageData.getHeight(), 0, // width, height, border GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, // pixel data format scratch); // pixel data // GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, // 0, 0, // imageData.getWidth(), imageData.getHeight(), // GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, // format, type // scratch); } return textureId; }
Example 13
Source File: AsyncContextCreator.java From settlers-remake with MIT License | 4 votes |
@Override public void run() { async_init(); parent.wrapNewContext(); while(continue_run) { if (change_res) { if(!ignore_resize) { width = new_width; height = new_height; async_set_size(width, height); parent.resize_gl(width, height); bi = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR); pixels = BufferUtils.createIntBuffer(width * height); } ignore_resize = false; change_res = false; } async_refresh(); parent.draw(); if (offscreen) { synchronized (wnd_lock) { GL11.glReadPixels(0, 0, width, height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixels); for (int x = 0; x != width; x++) { for (int y = 0; y != height; y++) { bi.setRGB(x, height - y - 1, pixels.get(y * width + x)); } } } } if(!offscreen || clear_offscreen ){ if(clear_offscreen) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); clear_offscreen = false; } async_swapbuffers(); } } async_stop(); }
Example 14
Source File: GLImageLoader.java From oreon-engine with GNU General Public License v3.0 | 4 votes |
public static ImageMetaData loadImage(String file, int handle) { 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()); } int width = w.get(0); int height = h.get(0); int comp = c.get(0); glBindTexture(GL_TEXTURE_2D, handle); if (comp == 3) { if ((width & 3) != 0) { glPixelStorei(GL_UNPACK_ALIGNMENT, 2 - (width & 1)); } glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image); } else { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); } stbi_image_free(image); ImageMetaData metaData = new ImageMetaData(width,height,comp); return metaData; }
Example 15
Source File: MusicController.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * Stops and releases all sources, clears each of the specified Audio * buffers, destroys the OpenAL context, and resets SoundStore for future use. * * Calling SoundStore.get().init() will re-initialize the OpenAL context * after a call to destroyOpenAL (Note: AudioLoader.getXXX calls init for you). * * @author davedes (http://slick.ninjacave.com/forum/viewtopic.php?t=3920) */ private static void destroyOpenAL() { if (!trackExists()) return; stop(); if (!AL.isCreated()) return; try { // get Music object's (private) Audio object reference Field sound = player.getClass().getDeclaredField("sound"); sound.setAccessible(true); Audio audio = (Audio) (sound.get(player)); // first clear the sources allocated by SoundStore int max = SoundStore.get().getSourceCount(); IntBuffer buf = BufferUtils.createIntBuffer(max); for (int i = 0; i < max; i++) { int source = SoundStore.get().getSource(i); buf.put(source); // stop and detach any buffers at this source AL10.alSourceStop(source); AL10.alSourcei(source, AL10.AL_BUFFER, 0); } buf.flip(); AL10.alDeleteSources(buf); int exc = AL10.alGetError(); if (exc != AL10.AL_NO_ERROR) { throw new SlickException( "Could not clear SoundStore sources, err: " + exc); } // delete any buffer data stored in memory, too... if (audio != null && audio.getBufferID() != 0) { buf = BufferUtils.createIntBuffer(1).put(audio.getBufferID()); buf.flip(); AL10.alDeleteBuffers(buf); exc = AL10.alGetError(); if (exc != AL10.AL_NO_ERROR) { throw new SlickException("Could not clear buffer " + audio.getBufferID() + ", err: "+exc); } } // clear OpenAL AL.destroy(); // reset SoundStore so that next time we create a Sound/Music, it will reinit SoundStore.get().clear(); player = null; } catch (Exception e) { ErrorHandler.error("Failed to destroy the OpenAL context.", e, true); } }
Example 16
Source File: MusicController.java From opsu-dance with GNU General Public License v3.0 | 4 votes |
/** * Stops and releases all sources, clears each of the specified Audio * buffers, destroys the OpenAL context, and resets SoundStore for future use. * * Calling SoundStore.get().init() will re-initialize the OpenAL context * after a call to destroyOpenAL (Note: AudioLoader.getXXX calls init for you). * * @author davedes (http://slick.ninjacave.com/forum/viewtopic.php?t=3920) */ private static void destroyOpenAL() { if (!trackExists()) return; stop(); try { // get Music object's (private) Audio object reference Field sound = player.getClass().getDeclaredField("sound"); sound.setAccessible(true); Audio audio = (Audio) (sound.get(player)); // first clear the sources allocated by SoundStore int max = SoundStore.get().getSourceCount(); IntBuffer buf = BufferUtils.createIntBuffer(max); for (int i = 0; i < max; i++) { int source = SoundStore.get().getSource(i); buf.put(source); // stop and detach any buffers at this source AL10.alSourceStop(source); AL10.alSourcei(source, AL10.AL_BUFFER, 0); } buf.flip(); AL10.alDeleteSources(buf); int exc = AL10.alGetError(); if (exc != AL10.AL_NO_ERROR) { throw new SlickException( "Could not clear SoundStore sources, err: " + exc); } // delete any buffer data stored in memory, too... if (audio != null && audio.getBufferID() != 0) { buf = BufferUtils.createIntBuffer(1).put(audio.getBufferID()); buf.flip(); AL10.alDeleteBuffers(buf); exc = AL10.alGetError(); if (exc != AL10.AL_NO_ERROR) { throw new SlickException("Could not clear buffer " + audio.getBufferID() + ", err: "+exc); } } // clear OpenAL AL.destroy(); // reset SoundStore so that next time we create a Sound/Music, it will reinit SoundStore.get().clear(); player = null; } catch (Exception e) { softErr(e, "Failed to destroy OpenAL"); } }
Example 17
Source File: LwjglTextureUtils.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 4 votes |
public static int createTexture(BufferedImage imageData, TextureFilter filterMode) { imageData = convertToGlFormat(imageData); IntBuffer buff = BufferUtils.createIntBuffer(16); buff.limit(1); GL11.glGenTextures(buff); int textureId = buff.get(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); if (filterMode == TextureFilter.NEAREST) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); } else { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); } GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); ByteBuffer scratch = ByteBuffer.allocateDirect(4*imageData.getWidth()*imageData.getHeight()); Raster raster = imageData.getRaster(); byte data[] = (byte[])raster.getDataElements(0, 0, imageData.getWidth(), imageData.getHeight(), null); scratch.clear(); scratch.put(data); scratch.rewind(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, // Mip level & Internal format imageData.getWidth(), imageData.getHeight(), 0, // width, height, border GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, // pixel data format scratch); // pixel data GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, imageData.getWidth(), imageData.getHeight(), GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, // format, type scratch); return textureId; }
Example 18
Source File: Sonics.java From AnyaBasic with MIT License | 4 votes |
public SoundEntity() { buffer = BufferUtils.createIntBuffer(1); source = BufferUtils.createIntBuffer(1); sourcePos = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] { 0.0f, 0.0f, 0.0f }).rewind(); sourceVel = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] { 0.0f, 0.0f, 0.0f }).rewind(); listenerPos = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] { 0.0f, 0.0f, 0.0f }).rewind(); listenerVel = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] { 0.0f, 0.0f, 0.0f }).rewind(); listenerOri = (FloatBuffer)BufferUtils.createFloatBuffer(6).put(new float[] { 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f }).rewind(); }
Example 19
Source File: SoundStore.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * Get the Sound based on a specified OGG file * * @param ref The reference to the OGG file in the classpath * @param in The stream to the OGG to load * @return The Sound read from the OGG file * @throws IOException Indicates a failure to load the OGG */ public Audio getOgg(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.OGG); } int buffer = -1; if (loaded.get(ref) != null) { buffer = ((Integer) loaded.get(ref)).intValue(); } else { try { IntBuffer buf = BufferUtils.createIntBuffer(1); OggDecoder decoder = new OggDecoder(); OggData ogg = decoder.getData(in); AL10.alGenBuffers(buf); AL10.alBufferData(buf.get(0), ogg.channels > 1 ? AL10.AL_FORMAT_STEREO16 : AL10.AL_FORMAT_MONO16, ogg.data, ogg.rate); loaded.put(ref,new Integer(buf.get(0))); buffer = buf.get(0); } catch (Exception e) { Log.error(e); Sys.alert("Error","Failed to load: "+ref+" - "+e.getMessage()); throw new IOException("Unable to load: "+ref); } } if (buffer == -1) { throw new IOException("Unable to load: "+ref); } return new AudioImpl(this, buffer); }
Example 20
Source File: BigImage.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 3 votes |
/** * Get the maximum size of an image supported by the underlying * hardware. * * @return The maximum size of the textures supported by the underlying * hardware. */ public static final int getMaxSingleImageSize() { IntBuffer buffer = BufferUtils.createIntBuffer(16); GL.glGetInteger(SGL.GL_MAX_TEXTURE_SIZE, buffer); return buffer.get(0); }