summaryrefslogtreecommitdiffstats
path: root/dev/MinGfx/src/text_shader.h
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2021-09-20 18:15:14 -0500
committerMatt Strapp <matt@mattstrapp.net>2021-09-20 18:15:14 -0500
commit342403a02f8063903d0f38327430721d4d0ae331 (patch)
tree29d020a27bc16939c568dd4b29166566d1c0e658 /dev/MinGfx/src/text_shader.h
parentFix parenthesis (diff)
downloadcsci4611-342403a02f8063903d0f38327430721d4d0ae331.tar
csci4611-342403a02f8063903d0f38327430721d4d0ae331.tar.gz
csci4611-342403a02f8063903d0f38327430721d4d0ae331.tar.bz2
csci4611-342403a02f8063903d0f38327430721d4d0ae331.tar.lz
csci4611-342403a02f8063903d0f38327430721d4d0ae331.tar.xz
csci4611-342403a02f8063903d0f38327430721d4d0ae331.tar.zst
csci4611-342403a02f8063903d0f38327430721d4d0ae331.zip
Diffstat (limited to 'dev/MinGfx/src/text_shader.h')
-rw-r--r--dev/MinGfx/src/text_shader.h220
1 files changed, 110 insertions, 110 deletions
diff --git a/dev/MinGfx/src/text_shader.h b/dev/MinGfx/src/text_shader.h
index a075cd2..8739bb3 100644
--- a/dev/MinGfx/src/text_shader.h
+++ b/dev/MinGfx/src/text_shader.h
@@ -1,110 +1,110 @@
-/*
- This file is part of the MinGfx Project.
-
- Copyright (c) 2017,2018 Regents of the University of Minnesota.
- All Rights Reserved.
-
- Original Author(s) of this File:
- Dan Keefe, 2018, University of Minnesota
-
- Author(s) of Significant Updates/Modifications to the File:
- ...
- */
-
-#ifndef SRC_TEXT_SHADER_H_
-#define SRC_TEXT_SHADER_H_
-
-#include <string>
-#include <map>
-
-#include "matrix4.h"
-#include "mesh.h"
-#include "shader_program.h"
-#include "texture2d.h"
-
-// disable warnings for this 3rd party code
-#pragma warning ( push, 0 )
-#include <stb_truetype.h>
-#pragma warning ( pop )
-
-namespace mingfx {
-
-
-
-/**
- */
-class TextShader {
-public:
- TextShader();
- virtual ~TextShader();
-
- /// Call this from within the InitOpenGL() function since it will initialize
- /// not just the Font's internal data but also an OpenGL texture to be
- /// stored on the graphics card. Internally, this uses the stb_truetype
- /// library to load true type fonts (files with a .ttf extension).
- bool Init(const std::string &font_file, int native_font_size);
-
- enum class HorizAlign {
- HORIZ_ALIGN_LEFT,
- HORIZ_ALIGN_CENTER,
- HORIZ_ALIGN_RIGHT
- };
-
- enum class VertAlign {
- VERT_ALIGN_TOP,
- VERT_ALIGN_CENTER,
- VERT_ALIGN_BASELINE,
- VERT_ALIGN_BOTTOM
- };
-
- class TextFormat {
- public:
- // constructor sets defaults
- TextFormat() :
- size(0.1f),
- color(1,1,1,1),
- h_align(HorizAlign::HORIZ_ALIGN_CENTER),
- v_align(VertAlign::VERT_ALIGN_BASELINE) {}
-
- float size;
- Color color;
- HorizAlign h_align;
- VertAlign v_align;
- };
-
-
- //void Draw2D(const Point2 &pos,
- // const std::string &text, TextFormat format, bool cache=false);
-
-
- void Draw3D(const Matrix4 &model, const Matrix4 &view, const Matrix4 &projection,
- const std::string &text, TextFormat format, bool cache=false);
-
-
- Vector2 TextExtents(const std::string &text, TextFormat format, bool cache=false);
-
- float native_font_size();
-
-private:
- Texture2D atlas_;
- float native_font_size_;
-
- stbtt_packedchar chardata_[128];
-
- struct MeshData {
- Mesh mesh;
- Point2 min;
- Point2 max;
- };
-
- void SetTextMesh(const std::string &text, MeshData *md);
-
- std::map<std::string, MeshData> cache_;
- MeshData tmp_md_;
-
- ShaderProgram shader_;
-};
-
-} // end namespace
-
-#endif
+/*
+ This file is part of the MinGfx Project.
+
+ Copyright (c) 2017,2018 Regents of the University of Minnesota.
+ All Rights Reserved.
+
+ Original Author(s) of this File:
+ Dan Keefe, 2018, University of Minnesota
+
+ Author(s) of Significant Updates/Modifications to the File:
+ ...
+ */
+
+#ifndef SRC_TEXT_SHADER_H_
+#define SRC_TEXT_SHADER_H_
+
+#include <string>
+#include <map>
+
+#include "matrix4.h"
+#include "mesh.h"
+#include "shader_program.h"
+#include "texture2d.h"
+
+// disable warnings for this 3rd party code
+#pragma warning ( push, 0 )
+#include <stb_truetype.h>
+#pragma warning ( pop )
+
+namespace mingfx {
+
+
+
+/**
+ */
+class TextShader {
+public:
+ TextShader();
+ virtual ~TextShader();
+
+ /// Call this from within the InitOpenGL() function since it will initialize
+ /// not just the Font's internal data but also an OpenGL texture to be
+ /// stored on the graphics card. Internally, this uses the stb_truetype
+ /// library to load true type fonts (files with a .ttf extension).
+ bool Init(const std::string &font_file, int native_font_size);
+
+ enum class HorizAlign {
+ HORIZ_ALIGN_LEFT,
+ HORIZ_ALIGN_CENTER,
+ HORIZ_ALIGN_RIGHT
+ };
+
+ enum class VertAlign {
+ VERT_ALIGN_TOP,
+ VERT_ALIGN_CENTER,
+ VERT_ALIGN_BASELINE,
+ VERT_ALIGN_BOTTOM
+ };
+
+ class TextFormat {
+ public:
+ // constructor sets defaults
+ TextFormat() :
+ size(0.1f),
+ color(1,1,1,1),
+ h_align(HorizAlign::HORIZ_ALIGN_CENTER),
+ v_align(VertAlign::VERT_ALIGN_BASELINE) {}
+
+ float size;
+ Color color;
+ HorizAlign h_align;
+ VertAlign v_align;
+ };
+
+
+ //void Draw2D(const Point2 &pos,
+ // const std::string &text, TextFormat format, bool cache=false);
+
+
+ void Draw3D(const Matrix4 &model, const Matrix4 &view, const Matrix4 &projection,
+ const std::string &text, TextFormat format, bool cache=false);
+
+
+ Vector2 TextExtents(const std::string &text, TextFormat format, bool cache=false);
+
+ float native_font_size();
+
+private:
+ Texture2D atlas_;
+ float native_font_size_;
+
+ stbtt_packedchar chardata_[128];
+
+ struct MeshData {
+ Mesh mesh;
+ Point2 min;
+ Point2 max;
+ };
+
+ void SetTextMesh(const std::string &text, MeshData *md);
+
+ std::map<std::string, MeshData> cache_;
+ MeshData tmp_md_;
+
+ ShaderProgram shader_;
+};
+
+} // end namespace
+
+#endif