{"id":16856427,"url":"https://github.com/vallentin/gltext","last_synced_at":"2025-03-17T05:32:20.612Z","repository":{"id":38151293,"uuid":"58666941","full_name":"vallentin/glText","owner":"vallentin","description":"Cross-platform single header text rendering library for OpenGL","archived":false,"fork":false,"pushed_at":"2023-05-30T07:51:13.000Z","size":30,"stargazers_count":172,"open_issues_count":21,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-27T18:26:57.657Z","etag":null,"topics":["c","computer-graphics","cpp","drawing","graphics","opengl","rendering","text"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vallentin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-12T18:33:40.000Z","updated_at":"2025-01-17T20:58:59.000Z","dependencies_parsed_at":"2024-10-27T12:08:48.419Z","dependency_job_id":"dab17c59-7d93-4cd1-8b82-c68d1536c02a","html_url":"https://github.com/vallentin/glText","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2FglText","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2FglText/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2FglText/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2FglText/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vallentin","download_url":"https://codeload.github.com/vallentin/glText/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243846976,"owners_count":20357294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","computer-graphics","cpp","drawing","graphics","opengl","rendering","text"],"created_at":"2024-10-13T14:04:13.681Z","updated_at":"2025-03-17T05:32:19.530Z","avatar_url":"https://github.com/vallentin.png","language":"C","readme":"\n# glText\n\n[![Build Status][glTextBuildStatus]][glTextCI]\n![Release][glTextVersionBadge]\n![Supported OpenGL 3.3][glTextOpenGLVersionsBadge]\n![License][glTextLicenseBadge]\n\n[glText][glText] is a simple cross-platform single header text rendering\nlibrary for OpenGL. [glText][glText] requires no additional files\n(such as fonts or textures) for drawing text, everything comes pre-packed\nin the header.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"479\" height=\"168\" src=\"examples/simple.png\" alt=\"simple example\" /\u003e\n\u003c/p\u003e\n\n*The above screenshot is of the [simple.c](examples/simple.c) example.*\n\n## Example\n\n```c\n// Initialize glText\ngltInit();\n\n// Creating text\nGLTtext *text = gltCreateText();\ngltSetText(text, \"Hello World!\");\n\n// Begin text drawing (this for instance calls glUseProgram)\ngltBeginDraw();\n\n// Draw any amount of text between begin and end\ngltColor(1.0f, 1.0f, 1.0f, 1.0f);\ngltDrawText2D(text, x, y, scale);\n\n// Finish drawing text\ngltEndDraw();\n\n// Deleting text\ngltDeleteText(text);\n\n// Destroy glText\ngltTerminate();\n```\n\n\n## Implementation\n\nIn one C or C++ file, define `GLT_IMPLEMENTATION` prior to inclusion to create the implementation.\n\n```c\n#define GLT_IMPLEMENTATION\n#include \"gltext.h\"\n```\n\n\n## Optimization\n\nEach time `gltDraw*()` functions are called, `glGetIntegerv(GL_VIEWPORT, ...)`\nis called. To avoid this and optimize that call away, define `GLT_MANUAL_VIEWPORT`\nbefore including `gltext.h`.\n\n```c\n#define GLT_MANUAL_VIEWPORT\n#include \"gltext.h\"\n```\n\nThen when the viewport is resized manually call:\n\n```c\ngltViewport(width, height)\n```\n\n\n## Manual Model, View, Projection Matrix\n\nThe example uses [LinearAlgebra](https://github.com/vallentin/LinearAlgebra).\n\n```c\nGLfloat fontScale = 0.01f;\n\nGLfloat x = 0.0f;\nGLfloat y = 0.0f;\n\nx -= gltGetTextWidth(text, fontScale) * 0.5f;\ny -= gltGetTextHeight(text, fontScale) * 0.5f;\n\nmat4 proj = mat4::perspective(70.0f, viewportWidth, viewportHeight, 0.1f, 10.0f);\n\nmat4 view = ...;\n\nmat4 model = mat4::identity;\nmodel.translate(x, y + gltGetTextHeight(text, fontScale));\nmodel.scale(fontScale, -fontScale);\n\nmat4 mvp = proj * view * model;\n\ngltDrawText(text, (GLfloat*)\u0026mvp);\n```\n\n\n## Aligned Text\n\n```c\n// Where horizontal is either:\n// - GLT_LEFT (default)\n// - GLT_CENTER\n// - GLT_RIGHT\n\n// Where vertical is either:\n// - GLT_TOP (default)\n// - GLT_CENTER\n// - GLT_BOTTOM\n\ngltDrawText2DAligned(text, x, y, scale, horizontal, vertical);\n```\n\n\n## No Dependencies\n\n[glText][glText] has no external dependencies besides [OpenGL][OpenGL] and the standard C libraries.\nBy default [glText][glText] uses `stdlib.h`, `string.h` and `stdint.h`.\n\nIf `GLT_DEBUG` is defined `assert.h` is needed. If `GLT_DEBUG_PRINT` is defined `stdio.h` is needed.\n\n\n## Reporting Bugs \u0026 Requests\n\nFeel free to use the [issue tracker][glTextIssues],\nfor reporting bugs, submitting patches or requesting features.\n\nBefore submitting bugs, make sure that you're using the latest version of [glText][glText].\n\n\n[glText]: https://github.com/vallentin/glText\n\n[glTextReleases]: https://github.com/vallentin/glText/releases\n\n[glTextBuildStatus]: https://drone.io/github.com/vallentin/glText/status.png\n[glTextCI]: https://drone.io/github.com/vallentin/glText/latest\n\n[glTextVersionBadge]: https://img.shields.io/badge/release-v1.1.6-blue.svg\n[glTextLicenseBadge]: https://img.shields.io/badge/license-%20free%20to%20use%2C%20share%2C%20modify%20and%20redistribute-blue.svg\n\n[glTextOpenGLVersionsBadge]: https://img.shields.io/badge/OpenGL-3.3-blue.svg\n\n[glTextIssues]: https://github.com/vallentin/glText/issues\n\n[OpenGL]: https://en.wikipedia.org/wiki/OpenGL\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Fgltext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvallentin%2Fgltext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Fgltext/lists"}