public class VidTexture {
int w, h, textureId, pbo;
VidTexture(int w, int h, ByteBuffer buf) {
this.w = w;
this.h = h;
buf.flip();
pbo = glGenBuffers();
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
glBufferData(GL_PIXEL_UNPACK_BUFFER, w*h*3L, GL_STREAM_DRAW);
ByteBuffer bb = glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
bb.put(buf);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
textureId = glGenTextures();
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
glBindTexture(GL_TEXTURE_2D, textureId);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w,
h, 0, GL_BGR, GL_UNSIGNED_BYTE, 0);
glGenerateMipmap(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, -1);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
buf.clear();
}
//Here is cleanUp and bind functions
}
private static final class GlfwKeyListener implements GLFWKeyCallbackI {
private int key;
@Override
public void invoke(long window, int key, int scancode, int action, int mods) {
KeyClass.key = key;
//schedule to set key to 0 on next frame
}
}
private void logUsedKeys() {
int key = KeyClass.key;
if (key != 0) {
LOGGER.info("Key {}", key);
}
}
shaderc_compile_into_spv takes an explicit size_t source_text_size parameter and LWJGL passes sourceBuffer.remaining() there implicitly, which includes the null-terminator.sourceBuffer = stack.UTF8(shaderSource.trim(), false), which will encode the source buffer without the null-terminator.
Matrix4f m = new Matrix4f();
Quaternionf q = new Quaternionf(0.0f, 0.965f, 0.2622f, 0.0f);
m.rotate(q);
AxisAngle4f a = new AxisAngle4f();
m.getRotation(a);
System.out.println(a);
m.getRotation(a);
System.out.println(a);
m.getRotation(a);
System.out.println(a);
m.getRotation(a);
System.out.println(a);
( 0.000E+0 9.650E-1 2.530E-1 <| 3.142E+0)
( 0.000E+0 9.650E-1 1.000E+0 <| 3.142E+0)
( 0.000E+0 9.650E-1 2.530E-1 <| 3.142E+0)
( 0.000E+0 9.650E-1 1.000E+0 <| 3.142E+0)