java.lang.Object
overrungl.stb.STBEasyFont
STBEasyFont
relies on preview features of the Java platform:
STBEasyFont
refers to one or more preview APIs:MemorySegment
,SegmentAllocator
.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Easy-to-deploy,
reasonably compact,
extremely inefficient performance-wise,
crappy-looking,
ASCII-only,
bitmap font for use in 3D APIs.
Intended for when you just want to get some text displaying in a 3D app as quickly as possible.
Doesn't use any textures, instead builds characters out of quads.
Sample Code
Here's sample code for old OpenGL; it's a lot more complicated to make work on modern APIs, and that's your problem.import java.lang.foreign.Arena;
static MemorySegment buffer = Arena.ofAuto().allocate(99999);
void printString(float x, float y, String text, float r, float g, float b) {
int numQuads = STBEasyFont.print(x, y, text, MemorySegment.NULL, buffer, (int) buffer.byteSize());
GL10.color3f(r, g, b);
GL11.enableClientState(GL.VERTEX_ARRAY);
GL11.vertexPointer(2, GL.FLOAT, 16, buffer);
GL.drawArrays(GL.QUADS, 0, numQuads * 4);
GL11.disableClientState(GL.VERTEX_ARRAY);
}
- Since:
- 0.1.0
- Author:
- squid233
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
drawSegs
(SegmentAllocatorPREVIEW allocator, float x, float y, byte[] segs, boolean vertical, byte[] c, MemorySegmentPREVIEW vbuf, int vbufSize, int offset) static float
static int
static int
ndrawSegs
(float x, float y, MemorySegmentPREVIEW segs, int numSegs, boolean vertical, MemorySegmentPREVIEW c, MemorySegmentPREVIEW vbuf, int vbufSize, int offset) static int
nheight
(MemorySegmentPREVIEW text) static int
nprint
(float x, float y, MemorySegmentPREVIEW text, MemorySegmentPREVIEW color, MemorySegmentPREVIEW vertexBuffer, int vbufSize) static int
nwidth
(MemorySegmentPREVIEW text) static int
print
(SegmentAllocatorPREVIEW allocator, float x, float y, String text, byte[] color, MemorySegmentPREVIEW vertexBuffer, int vbufSize) static void
setSpacing
(float spacing) static int
-
Method Details
-
ndrawSegs
public static int ndrawSegs(float x, float y, MemorySegmentPREVIEW segs, int numSegs, boolean vertical, MemorySegmentPREVIEW c, MemorySegmentPREVIEW vbuf, int vbufSize, int offset) -
drawSegs
public static int drawSegs(SegmentAllocatorPREVIEW allocator, float x, float y, byte[] segs, boolean vertical, byte[] c, MemorySegmentPREVIEW vbuf, int vbufSize, int offset) -
getSpacing
public static float getSpacing() -
setSpacing
public static void setSpacing(float spacing) -
nprint
public static int nprint(float x, float y, MemorySegmentPREVIEW text, MemorySegmentPREVIEW color, MemorySegmentPREVIEW vertexBuffer, int vbufSize) -
print
public static int print(SegmentAllocatorPREVIEW allocator, float x, float y, String text, byte[] color, MemorySegmentPREVIEW vertexBuffer, int vbufSize) -
nwidth
-
width
-
nheight
-
height
-
STBEasyFont
when preview features are enabled.