Skip to content

Commit 3cd1597

Browse files
committed
new text system
1 parent e7095ea commit 3cd1597

File tree

6 files changed

+30
-24
lines changed

6 files changed

+30
-24
lines changed

Qor/BasicState.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ void BasicState :: preload()
2525
{
2626
m_pCamera = make_shared<Camera>(m_pQor->resources(), m_pQor->window());
2727
m_pRoot->add(m_pCamera->as_node());
28+
29+
//m_pFont = m_pQor->resources()->cache_as<Font>("PressStart2P-Regular.ttf:30");
30+
//m_pText = make_shared<Text>(m_pFont);
31+
//m_pText->set("Hello World!");
32+
//auto text2 = make_shared<Text>(m_pFont);
33+
//text2->set("Testing");
34+
//m_pRoot->add(text2);
35+
//m_pText->position(glm::vec3(10.0f, 0.0f, 0.0f));
36+
//m_pRoot->add(m_pText);
2837
}
2938

3039
BasicState :: ~BasicState()
@@ -34,6 +43,9 @@ BasicState :: ~BasicState()
3443

3544
void BasicState :: enter()
3645
{
46+
m_pCamera->ortho(false);
47+
m_pPipeline->winding(true);
48+
3749
//LOG("enter");
3850
//m_pRoot->add(Mesh::line(
3951
// vec3(100.0f, 100.0f, 0.0f), vec3(200.0f, 200.0f, 0.0f),

Qor/BasicState.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "Sprite.h"
1111
#include "PlayerInterface2D.h"
1212
#include "Light.h"
13+
#include "Text.h"
1314

1415
class Qor;
1516

@@ -44,6 +45,9 @@ class BasicState:
4445
//unsigned m_DetailShader = ~0u;
4546

4647
//unsigned m_Shader = ~0u;
48+
49+
std::shared_ptr<Font> m_pFont;
50+
std::shared_ptr<Text> m_pText;
4751
};
4852

4953
#endif

Qor/Font.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

Qor/Qor.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "Particle.h"
1313
#include "Material.h"
1414
#include "LoadingState.h"
15+
#include "Text.h"
1516
//#include "GUI.h"
1617
#include "kit/freq/freq.h"
1718
#include "kit/log/log.h"
@@ -74,7 +75,7 @@ Qor :: Qor(const Args& args):
7475
//m_Resources.register_class<Particle::Data>("particledata");
7576
//m_Resources.register_class<ParticleSystem::Data>("particlesystemdata");
7677
//m_Resources.register_class<Scene>("scene");
77-
//m_Resources.register_class<GUI::Font>("font");
78+
m_Resources.register_class<Font>("font");
7879
//m_Resources.register_class<GUI::Form>("form");
7980
m_Resources.register_class<PipelineShader>("shader");
8081

@@ -384,14 +385,14 @@ unsigned Qor :: resolve_resource(
384385
return class_id;
385386
}
386387
#endif
387-
if(ends_with(fn_cut, ".otf")) {
388+
if(ends_with(fn_cut, ".ttf")) {
388389
static unsigned class_id = m_Resources.class_id("font");
389390
return class_id;
390391
}
391-
if(ends_with(fn_cut, ".rml")) {
392-
static unsigned class_id = m_Resources.class_id("form");
393-
return class_id;
394-
}
392+
//if(ends_with(fn_cut, ".rml")) {
393+
// static unsigned class_id = m_Resources.class_id("form");
394+
// return class_id;
395+
//}
395396

396397
WARNINGf("wtf @ %s", fn);
397398
return std::numeric_limits<unsigned>::max();

Qor/Window.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <vector>
77
#include <future>
88
#include "Texture.h"
9+
#include "Text.h"
910

1011
using namespace std;
1112

@@ -31,6 +32,8 @@ Window :: Window(
3132
if(SDL_Init(SDL_INIT_EVERYTHING) < 0)
3233
K_ERROR(LIBRARY, "SDL");
3334

35+
Text::init();
36+
3437
try{
3538

3639
glm::ivec2 resolution;
@@ -174,6 +177,8 @@ void Window :: destroy()
174177
}
175178
m_condDelay.notify_all();
176179
m_DelayThread.join();
180+
181+
Text::deinit();
177182

178183
if(m_GLContext)
179184
SDL_GL_DeleteContext(*m_GLContext);

premake4.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ solution("qor")
3030
-- buildoptions { "-std=c++11", "-pedantic", "-Wall", "-Wextra", '-v', '-fsyntax-only'}
3131
links {
3232
"pthread",
33+
"SDL2_ttf",
3334
"SDL2",
3435
"GLEW",
3536
"assimp",
@@ -98,6 +99,7 @@ solution("qor")
9899
"OpenGL32",
99100
"GLU32",
100101
"SDL2",
102+
"SDL2_ttf",
101103
"GLEW32",
102104
"assimp",
103105
"freeimage",

0 commit comments

Comments
 (0)