本文整理汇总了Java中java.nio.IntBuffer.get方法的典型用法代码示例。如果您正苦于以下问题:Java IntBuffer.get方法的具体用法?Java IntBuffer.get怎么用?Java IntBuffer.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.IntBuffer
的用法示例。
在下文中一共展示了IntBuffer.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: glShaderSource
import java.nio.IntBuffer; //导入方法依赖的package包/类
public static void glShaderSource(int shader, org.lwjgl.PointerBuffer strings, IntBuffer length) {
if (TRACE.enabled) {
/* Log the shader source */
StringBuilder sb = new StringBuilder();
if (strings != null && length != null) {
int stringsPos = strings.position();
int lengthPos = length.position();
for (int i = 0; i < strings.remaining(); i++) {
int len = length.get(lengthPos + i);
ByteBuffer string = org.lwjgl.system.MemoryUtil.memByteBuffer(strings.get(stringsPos + i), len);
String source = org.lwjgl.system.MemoryUtil.memASCII(string, len);
sb.append(source);
}
}
trace("Shader source for shader [" + shader + "]:\n" + sb.toString());
}
org.lwjgl.opengl.ARBShaderObjects.glShaderSourceARB(shader, strings, length);
}
示例2: glDeleteFramebuffersEXT
import java.nio.IntBuffer; //导入方法依赖的package包/类
public static void glDeleteFramebuffersEXT(IntBuffer framebuffers) {
org.lwjgl.opengl.EXTFramebufferObject.glDeleteFramebuffersEXT(framebuffers);
if (Properties.VALIDATE.enabled) {
Context context = CURRENT_CONTEXT.get();
int pos = framebuffers.position();
for (int i = 0; i < framebuffers.remaining(); i++) {
int framebuffer = framebuffers.get(pos + i);
if (framebuffer == 0)
continue;
FBO fbo = context.fbos.get(framebuffer);
if (fbo != null && fbo == context.currentFbo) {
context.currentFbo = context.defaultFbo;
}
context.fbos.remove(framebuffer);
}
}
}
示例3: glDeleteTextures
import java.nio.IntBuffer; //导入方法依赖的package包/类
public static void glDeleteTextures(IntBuffer textures) {
org.lwjgl.opengl.GL11.glDeleteTextures(textures);
if (Properties.PROFILE.enabled) {
Context ctx = CURRENT_CONTEXT.get();
int pos = textures.position();
for (int i = 0; i < textures.remaining(); i++) {
int buffer = textures.get(pos + i);
TextureObject to = ctx.textureObjects.remove(buffer);
Iterator<Map.Entry<Integer, TextureObject>> it = ctx.textureObjectBindings.entrySet().iterator();
while (it.hasNext()) {
if (it.next().getValue() == to) {
it.remove();
}
}
}
}
}
示例4: perform
import java.nio.IntBuffer; //导入方法依赖的package包/类
@Override
public String perform(String num1, String num2) {
int maxlen = computeMaxLength(num1, num2) + 1;
IntBuffer res = initBuf(num1, maxlen);
IntBuffer carry = initBuf(num2, maxlen);
while (!isCarryZero(carry)) {
for (int i = 0; i < maxlen; i++) {
int r = res.get(i);
int c = carry.get(i);
carry.put(i, 0);
if (r + c >= 10) {
res.put(i, r + c - 10);
if (i != 0)
carry.put(i - 1, 1);
} else {
res.put(i, r + c);
}
}
}
return bufToIntegerString(res);
}
示例5: init
import java.nio.IntBuffer; //导入方法依赖的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);
}
}
}
示例6: ConvertToIntArray
import java.nio.IntBuffer; //导入方法依赖的package包/类
public static int[] ConvertToIntArray(byte[] input){
IntBuffer intBuf =
ByteBuffer.wrap(input)
.order(ByteOrder.BIG_ENDIAN)
.asIntBuffer();
int[] output = new int[intBuf.remaining()];
intBuf.get(output);
return output;
}
示例7: initShader
import java.nio.IntBuffer; //导入方法依赖的package包/类
int initShader(GL2 gl, int nShaderType, String source) {
int shader = gl.glCreateShader(nShaderType);
if (shader != 0) {
String[] sources = new String[]{ source };
gl.glShaderSource(shader, 1, sources, null);
gl.glCompileShader(shader);
IntBuffer compiled = BufferUtils.createIntBuffer(1);
gl.glGetShaderiv(shader, GL2.GL_COMPILE_STATUS, compiled);
if (compiled.get() == 0) {
IntBuffer infoLen = BufferUtils.createIntBuffer(1);
gl.glGetShaderiv(shader, GL2.GL_INFO_LOG_LENGTH, infoLen);
int length = infoLen.get();
if (length > 0) {
ByteBuffer buf = BufferUtils.createByteBuffer(length);
infoLen.flip();
gl.glGetShaderInfoLog(shader, length, infoLen, buf);
byte[] b = new byte[infoLen.get()];
buf.get(b);
System.out.println("Prgram : " + fProgram);
System.out.println(source);
System.err.println("Error compiling shader " + vProgram + " " + fProgram + " -> " + new String(b));
}
}
}
return shader;
}
示例8: glGenBuffersARB
import java.nio.IntBuffer; //导入方法依赖的package包/类
public static void glGenBuffersARB(IntBuffer buffers) {
org.lwjgl.opengl.ARBVertexBufferObject.glGenBuffersARB(buffers);
if (Properties.PROFILE.enabled) {
Context ctx = CURRENT_CONTEXT.get();
int pos = buffers.position();
for (int i = 0; i < buffers.remaining(); i++) {
int buffer = buffers.get(pos + i);
ctx.bufferObjects.put(buffer, new BufferObject());
}
}
}
示例9: byteArrayToIntArray
import java.nio.IntBuffer; //导入方法依赖的package包/类
private int[] byteArrayToIntArray(byte[] byteArray) {
IntBuffer intBuf =
ByteBuffer.wrap(byteArray)
.order(ByteOrder.LITTLE_ENDIAN)
.asIntBuffer();
int[] array = new int[intBuf.remaining()];
intBuf.get(array);
return array;
}
示例10: visitLocation
import java.nio.IntBuffer; //导入方法依赖的package包/类
void visitLocation(ImageLocation loc, LocationVisitor visitor) {
byte[] offsets = getResource(loc);
ByteBuffer buffer = ByteBuffer.wrap(offsets);
buffer.order(getByteOrder());
IntBuffer intBuffer = buffer.asIntBuffer();
for (int i = 0; i < offsets.length / SIZE_OF_OFFSET; i++) {
int offset = intBuffer.get(i);
ImageLocation pkgLoc = getLocation(offset);
visitor.visit(pkgLoc);
}
}
示例11: serialize
import java.nio.IntBuffer; //导入方法依赖的package包/类
public void serialize(ByteBuf buf, ServerDenseIntRow row) {
try {
row.getLock().readLock().lock();
IntBuffer ints = row.getData();
int len = (int)(row.getEndCol() - row.getStartCol());
int cnt = 0;
for (int i = 0; i < len; i++)
if (ints.get(i) > 0)
cnt++;
if (cnt > len * 0.5) {
// dense
buf.writeByte(0);
buf.writeShort(len);
buf.writeBytes(row.getDataArray());
} else {
// sparse
buf.writeByte(1);
buf.writeShort(cnt);
for (int i = 0; i < len; i++) {
if (ints.get(i) > 0) {
buf.writeShort(i);
buf.writeInt(ints.get(i));
}
}
}
} finally {
row.getLock().readLock().unlock();
}
}
示例12: init
import java.nio.IntBuffer; //导入方法依赖的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");
}
}
示例13: glGenFramebuffers
import java.nio.IntBuffer; //导入方法依赖的package包/类
public static void glGenFramebuffers(IntBuffer framebuffers) {
org.lwjgl.opengl.GL30.glGenFramebuffers(framebuffers);
if (Properties.VALIDATE.enabled) {
Context ctx = CURRENT_CONTEXT.get();
int pos = framebuffers.position();
for (int i = 0; i < framebuffers.remaining(); i++) {
int handle = framebuffers.get(pos + i);
FBO fbo = new FBO(handle);
ctx.fbos.put(handle, fbo);
}
}
}
示例14: getOgg
import java.nio.IntBuffer; //导入方法依赖的package包/类
/**
* 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);
}
示例15: CMapFormat12
import java.nio.IntBuffer; //导入方法依赖的package包/类
CMapFormat12(ByteBuffer buffer, int offset, char[] xlat) {
if (xlat != null) {
throw new RuntimeException("xlat array for cmap fmt=12");
}
numGroups = buffer.getInt(offset+12);
startCharCode = new long[numGroups];
endCharCode = new long[numGroups];
startGlyphID = new int[numGroups];
buffer.position(offset+16);
buffer = buffer.slice();
IntBuffer ibuffer = buffer.asIntBuffer();
for (int i=0; i<numGroups; i++) {
startCharCode[i] = ibuffer.get() & INTMASK;
endCharCode[i] = ibuffer.get() & INTMASK;
startGlyphID[i] = ibuffer.get() & INTMASK;
}
/* Finds the high bit by binary searching through the bits */
int value = numGroups;
if (value >= 1 << 16) {
value >>= 16;
highBit += 16;
}
if (value >= 1 << 8) {
value >>= 8;
highBit += 8;
}
if (value >= 1 << 4) {
value >>= 4;
highBit += 4;
}
if (value >= 1 << 2) {
value >>= 2;
highBit += 2;
}
if (value >= 1 << 1) {
value >>= 1;
highBit += 1;
}
power = 1 << highBit;
extra = numGroups - power;
}