-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenll-example.c
More file actions
66 lines (39 loc) · 2.07 KB
/
openll-example.c
File metadata and controls
66 lines (39 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Create and initialize font face
LLhandle fontface = 0;
llCreateFontFace(1, & fontface);
const char * fontFaceContents = 0x0; // load from file OpenSans.fnt
llLoadFontFaceData(fontface, LL_FONTFACE_FORMAT_DISTANCE_FIELD_FONT_FILE, fontFileContents);
// Create and initialize text
LLhandle text = 0;
llCreateText(1, &text);
llLoadTextContents(text, LL_TEXT_INTERNAL_FORMAT_UC32, LL_TEXT_ENCODING_ANSII, 0, "Hello Word");
// Derive glyph sequence
LLhandle glyphsequence = 0;
llCreateGlyphSequence(1, &glyphsequence);
llAssignGlyphSequenceText(glyphsequence, text);
llAssignGlyphSequenceFontFace(glyphsequence, fontface);
// llSetGlyphSequenceAttrib(glyphsequence, LL_TYPESET_WORD_WRAP, LL_TRUE);
llSetGlyphSequenceAttrib(glyphsequence, LL_TYPESET_ALIGNMENT, LL_TYPESET_ALIGNMENT_LEFT_ALIGNED);
llSetGlyphSequenceAttrib(glyphsequence, LL_TYPESET_LINE_ANCHOR, LL_TYPESET_LINE_ANCHOR_BASELINE);
llSetGlyphSequenceAttrib(glyphsequence, LL_TYPESET_LINE_ANCHOR, LL_TYPESET_LINE_ANCHOR_BASELINE);
llSetGlyphSequenceAttrib(glyphsequence, LL_TYPESET_FONT_SIZE, 12.0);
llSetGlyphSequenceAttrib(glyphsequence, LL_TYPESET_FONT_SIZE_UNIT, LL_SIZE_UNIT_PT);
llSetGlyphSequenceAttrib(glyphsequence, LL_TYPESET_POSITION, { 100, 200 });
llSetGlyphSequenceAttrib(glyphsequence, LL_TYPESET_POSITION_UNIT, LL_SIZE_UNIT_PX);
// Surface
LLhandle surface llCreateSurface(LL_OPENGL_DEFAULT_FRAMEBUFFER_SURFACE, GL_BACK_LEFT);
// llSetSurfaceAttrib(surface, LL_SURFACE_DEVICE_PIXEL_RATIO, 2.0);
// llSetSurfaceAttrib(surface, LL_SURFACE_REFERENCE_PIXEL_PER_INCH, 72.0);
llSetSurfaceAttrib(surface, LL_SURFACE_PIXEL_PER_INCH, 120.0);
llSetSurfaceAttrib(surface, LL_SURFACE_VIEWPORT, { 0, 0, 1920, 1080 });
// Render
LLhandle renderer = llCreateRenderer(LL_RENDERER_OPENGL);
llSetRendererAttrib(renderer, LL_RENDERER_SUPERSAMPLING, LL_TRUE);
llSetRendererAttrib(renderer, LL_RENDERER_ENABLE_FONT_COLORS, LL_FALSE);
llRenderGlyphSequence(renderer, surface, glyphsequence);
// Cleanup
destroyRenderer(renderer);
destroySurface(surface);
destroyGlyphSequence(glyphsequence);
destroyFontFace(fontface);
destroyText(text);