private static int getInternalTextureFormat(Bitmap.Format format) { switch (format) { case GRAYSCALE: return GL11.GL_LUMINANCE; case GRAYSCALEALPHA: return GL11.GL_LUMINANCE_ALPHA; case RGB: return GL21.GL_SRGB; case RGBA: return GL21.GL_SRGB_ALPHA; case DEPTH: return GL14.GL_DEPTH_COMPONENT16; default: throw new UnsupportedOperationException("Unrecognized bitmap format!"); } }
private PixelPackBuffer(int id, int size) { super(String.valueOf(id), "pbo"); this.id = id; this.size = size; bind(); GL15.nglBufferData(GL21.GL_PIXEL_PACK_BUFFER, size, MemoryUtil.NULL, GL15.GL_STREAM_READ); unbind(); }
/** * Get this buffer * @param dest The destination buffer * @return The detination buffer or a new buffer it it was <code>null</code> */ public ByteBuffer get(ByteBuffer dest) { if (dest == null) dest = BufferUtils.createByteBuffer(size); bind(); ByteBuffer src = GL15.glMapBuffer(GL21.GL_PIXEL_PACK_BUFFER, GL15.GL_READ_ONLY); MemoryUtil.memCopy(MemoryUtil.memAddress(src), MemoryUtil.memAddress(dest), size); GL15.glUnmapBuffer(GL21.GL_PIXEL_PACK_BUFFER); unbind(); return dest; }
private static void buildMapping() { if (mapping != null) return; Multimap<Integer, String> map = HashMultimap.create(); List<Class<?>> classes = ImmutableList.of( GL11.class, GL12.class, GL13.class, GL14.class, GL15.class, GL20.class, GL21.class, GL30.class, GL31.class, GL32.class, GL33.class, GL40.class, GL41.class, GL42.class, GL43.class, GL44.class, GL45.class, GLFW.class ); for (Class<?> clazz : classes) { for (Field f : clazz.getDeclaredFields()) { if (f.getName().toUpperCase(Locale.ROOT).equals(f.getName()) && f.getType() == int.class && Modifier.isPublic(f.getModifiers()) && Modifier.isStatic(f.getModifiers())) { List<String> li = Splitter.on('_').splitToList(f.getName()); li = li.subList(1, li.size()); String clean = Joiner.on(' ').join( li.stream() .map(Errors::toTitleCase) .iterator()); try { map.put(f.getInt(null), clean); } catch (Throwable t) { t.printStackTrace(); } } } } mapping = map; }
private void func_148082_k() { switch (this.field_148100_d) { case 8: GL20.glUniformMatrix2(this.field_148102_b, true, this.field_148098_f); break; case 9: GL20.glUniformMatrix3(this.field_148102_b, true, this.field_148098_f); break; case 10: GL20.glUniformMatrix4(this.field_148102_b, true, this.field_148098_f); break; case 11: GL21.glUniformMatrix2x3(this.field_148102_b, true, this.field_148098_f); break; case 12: GL21.glUniformMatrix2x4(this.field_148102_b, true, this.field_148098_f); break; case 13: GL21.glUniformMatrix3x2(this.field_148102_b, true, this.field_148098_f); break; case 14: GL21.glUniformMatrix3x4(this.field_148102_b, true, this.field_148098_f); break; case 15: GL21.glUniformMatrix4x2(this.field_148102_b, true, this.field_148098_f); break; case 16: GL21.glUniformMatrix4x3(this.field_148102_b, true, this.field_148098_f); } }
/** * Bind this buffer */ public void bind() { GL15.glBindBuffer(GL21.GL_PIXEL_PACK_BUFFER, id); }
/** * Unbind this buffer */ public void unbind() { GL15.glBindBuffer(GL21.GL_PIXEL_PACK_BUFFER, 0); }
@Override public void glUniformMatrix2x3fv (int location, int count, boolean transpose, FloatBuffer value) { GL21.glUniformMatrix2x3fv(location, transpose, value); }
@Override public void glUniformMatrix3x2fv (int location, int count, boolean transpose, FloatBuffer value) { GL21.glUniformMatrix3x2fv(location, transpose, value); }
@Override public void glUniformMatrix2x4fv (int location, int count, boolean transpose, FloatBuffer value) { GL21.glUniformMatrix2x4fv(location, transpose, value); }
@Override public void glUniformMatrix4x2fv (int location, int count, boolean transpose, FloatBuffer value) { GL21.glUniformMatrix4x2fv(location, transpose, value); }
@Override public void glUniformMatrix3x4fv (int location, int count, boolean transpose, FloatBuffer value) { GL21.glUniformMatrix3x4fv(location, transpose, value); }
@Override public void glUniformMatrix4x3fv (int location, int count, boolean transpose, FloatBuffer value) { GL21.glUniformMatrix4x3fv(location, transpose, value); }
@Override public void glUniformMatrix2x3fv (int location, int count, boolean transpose, FloatBuffer value) { GL21.glUniformMatrix2x3(location, transpose, value); }
@Override public void glUniformMatrix3x2fv (int location, int count, boolean transpose, FloatBuffer value) { GL21.glUniformMatrix3x2(location, transpose, value); }
@Override public void glUniformMatrix2x4fv (int location, int count, boolean transpose, FloatBuffer value) { GL21.glUniformMatrix2x4(location, transpose, value); }
@Override public void glUniformMatrix4x2fv (int location, int count, boolean transpose, FloatBuffer value) { GL21.glUniformMatrix4x2(location, transpose, value); }
@Override public void glUniformMatrix3x4fv (int location, int count, boolean transpose, FloatBuffer value) { GL21.glUniformMatrix3x4(location, transpose, value); }
@Override public void glUniformMatrix4x3fv (int location, int count, boolean transpose, FloatBuffer value) { GL21.glUniformMatrix4x3(location, transpose, value); }