mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 06:21:16 +01:00
Port the glyphy-demo to use the hb-gpu API. Builds as util/hb-gpu and requires GLEW, GLFW3, and OpenGL 3.3. Includes default text and embedded font for quick testing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
62 lines
1.2 KiB
C++
62 lines
1.2 KiB
C++
/*
|
|
* Copyright 2026 Behdad Esfahbod. All Rights Reserved.
|
|
*/
|
|
|
|
#include "demo-glstate.h"
|
|
|
|
struct demo_glstate_t {
|
|
GLuint program;
|
|
demo_atlas_t *atlas;
|
|
};
|
|
|
|
demo_glstate_t *
|
|
demo_glstate_create (void)
|
|
{
|
|
demo_glstate_t *st = (demo_glstate_t *) calloc (1, sizeof (demo_glstate_t));
|
|
|
|
st->program = demo_shader_create_program ();
|
|
st->atlas = demo_atlas_create (1024 * 1024);
|
|
|
|
return st;
|
|
}
|
|
|
|
void
|
|
demo_glstate_destroy (demo_glstate_t *st)
|
|
{
|
|
if (!st)
|
|
return;
|
|
|
|
demo_atlas_destroy (st->atlas);
|
|
glDeleteProgram (st->program);
|
|
|
|
free (st);
|
|
}
|
|
|
|
void
|
|
demo_glstate_setup (demo_glstate_t *st)
|
|
{
|
|
glUseProgram (st->program);
|
|
|
|
demo_atlas_set_uniforms (st->atlas);
|
|
|
|
glEnable (GL_BLEND);
|
|
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
}
|
|
|
|
demo_atlas_t *
|
|
demo_glstate_get_atlas (demo_glstate_t *st)
|
|
{
|
|
return st->atlas;
|
|
}
|
|
|
|
void
|
|
demo_glstate_set_matrix (demo_glstate_t *st, float mat[16])
|
|
{
|
|
glUniformMatrix4fv (glGetUniformLocation (st->program, "u_matViewProjection"), 1, GL_FALSE, mat);
|
|
|
|
GLint viewport[4];
|
|
glGetIntegerv (GL_VIEWPORT, viewport);
|
|
glUniform2f (glGetUniformLocation (st->program, "u_viewport"),
|
|
(float) viewport[2], (float) viewport[3]);
|
|
}
|