/** * Returns the UTF8 string value at the specified byte range. */ public String stringValueUTF8(int offset, int limit) { buffer.position(offset); buffer.limit(limit); try { return MemoryUtil.memUTF8(buffer); } finally { buffer.clear(); } }
/** * Ensures space for the specified string encoded in UTF-8, encodes the * string at the allocated offset and returns that offset. */ public int stringParamUTF8(CharSequence value, boolean nullTerminated) { if (value == null) { return -1; } int encodedLen = MemoryUtil.memLengthUTF8(value, nullTerminated); int offset = bufferParam(encodedLen); MemoryUtil.memUTF8(value, nullTerminated, buffer, offset); return offset; }
/** * UTF8 encodes the specified strings with a null-terminator and ensures * space for a buffer filled with the memory addresses of the encoded * strings. * * <p> * The encoded buffers must be later freed with * {@link #pointerArrayFree(int, int)}.</p> * * @return the offset to the memory address buffer */ public int pointerArrayParamUTF8(CharSequence... strings) { int buffersAddress = bufferParam(strings.length << POINTER_SHIFT); for (int i = 0; i < strings.length; i++) { ByteBuffer buffer = MemoryUtil.memUTF8(strings[i]); pointerParam(buffersAddress, i, memAddress(buffer)); } return buffersAddress; }
/** * UTF8 encodes the specified strings and ensures space for two additional * buffers filled with the lengths and memory addresses of the encoded * strings, respectively. The lengths are 4-bytes integers and the memory * address buffer starts immediately after the lengths buffer. * * <p> * The encoded buffers must be later freed with * {@link #pointerArrayFree(int, int)}.</p> * * @return the offset to the lengths buffer */ public int pointerArrayParamUTF8i(CharSequence... strings) { int buffersAddress = bufferParam(strings.length << POINTER_SHIFT); int lengthsAddress = bufferParam(strings.length << 2); for (int i = 0; i < strings.length; i++) { ByteBuffer buffer = MemoryUtil.memUTF8(strings[i]); pointerParam(buffersAddress, i, memAddress(buffer)); intParam(lengthsAddress, i, buffer.remaining()); } return buffersAddress; }
/** * UTF8 encodes the specified strings and ensures space for two additional * buffers filled with the lengths and memory addresses of the encoded * strings, respectively. The lengths are pointer-sized integers and the * memory address buffer starts immediately after the lengths buffer. * * <p> * The encoded buffers must be later freed with * {@link #pointerArrayFree(int, int)}.</p> * * @return the offset to the lengths buffer */ public int pointerArrayParamUTF8p(CharSequence... strings) { int buffersAddress = bufferParam(strings.length << POINTER_SHIFT); int lengthsAddress = bufferParam(strings.length << POINTER_SHIFT); for (int i = 0; i < strings.length; i++) { ByteBuffer buffer = MemoryUtil.memUTF8(strings[i]); pointerParam(buffersAddress, i, memAddress(buffer)); pointerParam(lengthsAddress, i, buffer.remaining()); } return buffersAddress; }
/** * Converts the specified {@link VkDebugReportCallbackEXT} argument to a String. * * <p>This method may only be used inside a {@code VkDebugReportCallbackEXT} invocation.</p> * * @param string the argument to decode * * @return the message as a String */ public static String getString(long string) { return memUTF8(string); }
/** * Returns a ByteBuffer containing the specified text UTF-8 encoded and null-terminated. * * @param text the text to encode * * @return the encoded text. The returned buffer must be deallocated manually with {@link #memFree}. */ public static ByteBuffer memUTF8(CharSequence text) { return memUTF8(text, true); }
/** * Converts the specified {@link GLFWErrorCallback} argument to a String. * * <p>This method may only be used inside a GLFWErrorCallback invocation.</p> * * @param description pointer to the UTF-8 encoded description string * * @return the description as a String */ public static String getDescription(long description) { return memUTF8(description); }
/** Like {@link #memUTF8(CharSequence) memASCII}, but returns {@code null} if {@code text} is {@code null}. */ @Nullable public static ByteBuffer memUTF8Safe(@Nullable CharSequence text) { return text == null ? null : memUTF8(text, true); }
/** Like {@link #memUTF8(CharSequence, boolean) memASCII}, but returns {@code null} if {@code text} is {@code null}. */ @Nullable public static ByteBuffer memUTF8Safe(@Nullable CharSequence text, boolean nullTerminated) { return text == null ? null : memUTF8(text, nullTerminated); }
/** * Returns the UTF8 string value at the specified byte range. */ public String stringValueUTF8(int offset, int limit) { buffer.position(offset); buffer.limit(limit); try { return MemoryUtil.memUTF8(buffer); } finally { buffer.clear(); } }
/** * Reads the pointer at this buffer's current position, and then increments the position. The pointer is evaluated as a null-terminated UTF-8 string, which * is decoded and returned as a {@link String} instance. * * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit */ public String getStringUTF8() { return memUTF8(get()); }
/** * Decodes the specified {@link GLFWDropCallback} arguments to a String. * * <p>This method may only be used inside a {@code GLFWDropCallback} invocation.</p> * * @param names pointer to the array of UTF-8 encoded path names of the dropped files * @param index the index to decode * * @return the name at the specified index as a String */ public static String getName(long names, int index) { return memUTF8(memGetAddress(names + Pointer.POINTER_SIZE * index)); }
/** * Converts the specified {@link GLDebugMessageAMDCallback} arguments to a String. * * <p>This method may only be used inside a GLDebugMessageAMDCallback invocation.</p> * * @param length the GLDebugMessageAMDCallback {@code length} argument * @param message the GLDebugMessageAMDCallback {@code message} argument * * @return the message as a String */ public static String getMessage(int length, long message) { return memUTF8(memByteBuffer(message, length)); }
/** * Converts the specified {@link GLDebugMessageKHRCallback} arguments to a String. * * <p>This method may only be used inside a GLDebugMessageKHRCallback invocation.</p> * * @param length the GLDebugMessageKHRCallback {@code length} argument * @param message the GLDebugMessageKHRCallback {@code message} argument * * @return the message as a String */ public static String getMessage(int length, long message) { return memUTF8(memByteBuffer(message, length)); }
/** * Ensures space for the specified string encoded in UTF-8, encodes the * string at the allocated offset and returns that offset. */ public int stringParamUTF8(CharSequence value, boolean nullTerminated) { if (value == null) { return -1; } int encodedLen = MemoryUtil.memLengthUTF8(value, nullTerminated); int offset = bufferParam(encodedLen); MemoryUtil.memUTF8(value, nullTerminated, buffer, offset); return offset; }
private void createShaderStage(int stage){ shaderStageInfo = VkPipelineShaderStageCreateInfo.calloc() .sType(VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO) .stage(stage) .module(handle) .pName(memUTF8("main")) .pSpecializationInfo(null); }
@NativeType("void") public static String glGetObjectLabelEXT(@NativeType("GLenum") int type, @NativeType("GLuint") int object, @NativeType("GLsizei") int bufSize) { MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { IntBuffer length = stack.ints(0); ByteBuffer label = stack.malloc(bufSize); nglGetObjectLabelEXT(type, object, bufSize, memAddress(length), memAddress(label)); return memUTF8(label, length.get(0)); } finally { stack.setPointer(stackPointer); } }
@NativeType("void") public static String glGetObjectLabelEXT(@NativeType("GLenum") int type, @NativeType("GLuint") int object, @NativeType("GLsizei") int bufSize) { MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { IntBuffer length = stack.ints(0); ByteBuffer label = stack.malloc(bufSize); nglGetObjectLabelEXT(type, object, bufSize, memAddress(length), memAddress(label)); return memUTF8(label, length.get(0)); } finally { stack.setPointer(stackPointer); } }
@NativeType("void") public static String glGetProgramPipelineInfoLogEXT(@NativeType("GLuint") int pipeline, @NativeType("GLsizei") int bufSize) { MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); ByteBuffer infoLog = memAlloc(bufSize); try { IntBuffer length = stack.ints(0); nglGetProgramPipelineInfoLogEXT(pipeline, bufSize, memAddress(length), memAddress(infoLog)); return memUTF8(infoLog, length.get(0)); } finally { memFree(infoLog); stack.setPointer(stackPointer); } }