text size can now be entered in the filepath with a comma separator, like this "filepath,16"
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "../OpenGL.h"
|
||||
#include "../GLM.h"
|
||||
@@ -21,6 +24,10 @@ public:
|
||||
glm::ivec2 Bearing; // Offset from baseline to left/top of glyph
|
||||
GLuint Advance; // Offset to advance to next glyph
|
||||
};
|
||||
|
||||
FT_Face Face;
|
||||
|
||||
|
||||
~Font();
|
||||
|
||||
std::map<GLchar, Character> m_Characters;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "../OpenGL.h"
|
||||
#include "../GLM.h"
|
||||
|
||||
@@ -1,58 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Entity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd" xmlns:c="components">
|
||||
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="0"/>
|
||||
<Orientation X="0" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="1" Z="10"/>
|
||||
</c:Transform>
|
||||
<c:Model>
|
||||
<Resource>Models/Camera.obj</Resource>
|
||||
</c:Model>
|
||||
<c:Camera>
|
||||
<Name>MainCamera</Name>
|
||||
</c:Camera>
|
||||
</Components>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Position X="5" Y="1" Z="5"/>
|
||||
</c:Transform>
|
||||
<c:Model>
|
||||
<Resource>Models/Camera.obj</Resource>
|
||||
</c:Model>
|
||||
<c:Camera>
|
||||
<Name>ActionCamera</Name>
|
||||
</c:Camera>
|
||||
</Components>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="-1" Z="0"/>
|
||||
<Scale X="100" Y="1" Z="100"/>
|
||||
</c:Transform>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitPlane.obj</Resource>
|
||||
</c:Model>
|
||||
</Components>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Model>
|
||||
<Resource>An error</Resource>
|
||||
</c:Model>
|
||||
</Components>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Camera>
|
||||
<Name>MainCamera</Name>
|
||||
</c:Camera>
|
||||
<c:Model>
|
||||
<Resource>Models/Camera.obj</Resource>
|
||||
<Visible>false</Visible>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0.624614298" Y="0.345819205" Z="5.40656805"/>
|
||||
<Orientation X="0.0523599274" Y="-0.104719244" Z="8.8963592e-09"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Camera>
|
||||
<Name>ActionCamera</Name>
|
||||
</c:Camera>
|
||||
<c:Model>
|
||||
<Resource>Models/Camera.obj</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="5" Y="1" Z="5"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitPlane.obj</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="-1" Z="0"/>
|
||||
<Scale X="100" Y="1" Z="100"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>An error</Resource>
|
||||
</c:Model>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>asdasdasdasdasd</Content>
|
||||
<Resource>Fonts/DroidSans.ttf</Resource>
|
||||
</c:Text>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
|
||||
</Entity>
|
||||
|
||||
@@ -3,22 +3,48 @@
|
||||
|
||||
Font::Font(std::string path)
|
||||
{
|
||||
typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
|
||||
boost::char_separator<char> sep(",");
|
||||
tokenizer tok(path, sep);
|
||||
|
||||
int fontSize = 16;
|
||||
|
||||
tokenizer::iterator it = tok.begin();
|
||||
std::string filePath = "";
|
||||
|
||||
if (it != tok.end()) {
|
||||
filePath = (*it).c_str();
|
||||
it++;
|
||||
if (it != tok.end()) {
|
||||
try {
|
||||
LOG_INFO("DFhdoölshöldsihjgf");
|
||||
fontSize = boost::lexical_cast<int>((*it).c_str());
|
||||
} catch (boost::bad_lexical_cast const&) {
|
||||
std::cout << "Error: input string was not valid" << std::endl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
|
||||
if (FT_Init_FreeType(&library)) {
|
||||
LOG_ERROR("FreeType error: init failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (FT_New_Face(library, path.c_str(), 0, &face)) {
|
||||
if (FT_New_Face(library, filePath.c_str(), 0, &Face)) {
|
||||
LOG_ERROR("FreeType error: loading font");
|
||||
return;
|
||||
}
|
||||
|
||||
FT_Set_Pixel_Sizes(face, 0, 48);
|
||||
FT_Set_Char_Size(Face, 0, fontSize*64, 300, 300); // temp
|
||||
FT_Set_Pixel_Sizes(Face, 0, fontSize); //
|
||||
|
||||
if (FT_Load_Char(face, 'X', FT_LOAD_RENDER)) {
|
||||
if (FT_Load_Char(Face, 'X', FT_LOAD_RENDER)) {
|
||||
LOG_ERROR("FreeType error: loading char");
|
||||
return;
|
||||
}
|
||||
@@ -26,8 +52,10 @@ Font::Font(std::string path)
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
for (GLubyte c = 0; c < 128; c++) {
|
||||
|
||||
|
||||
//Load character glyph
|
||||
if (FT_Load_Char(face, c, FT_LOAD_RENDER)) {
|
||||
if (FT_Load_Char(Face, c, FT_LOAD_RENDER)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -40,12 +68,12 @@ Font::Font(std::string path)
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RED,
|
||||
face->glyph->bitmap.width,
|
||||
face->glyph->bitmap.rows,
|
||||
Face->glyph->bitmap.width,
|
||||
Face->glyph->bitmap.rows,
|
||||
0,
|
||||
GL_RED,
|
||||
GL_UNSIGNED_BYTE,
|
||||
face->glyph->bitmap.buffer
|
||||
Face->glyph->bitmap.buffer
|
||||
);
|
||||
// Set texture options
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
@@ -55,15 +83,15 @@ Font::Font(std::string path)
|
||||
// Now store character for later use
|
||||
Character character = {
|
||||
texture,
|
||||
glm::ivec2(face->glyph->bitmap.width, face->glyph->bitmap.rows),
|
||||
glm::ivec2(face->glyph->bitmap_left, face->glyph->bitmap_top),
|
||||
face->glyph->advance.x
|
||||
glm::ivec2(Face->glyph->bitmap.width, Face->glyph->bitmap.rows),
|
||||
glm::ivec2(Face->glyph->bitmap_left, Face->glyph->bitmap_top),
|
||||
Face->glyph->advance.x
|
||||
};
|
||||
|
||||
m_Characters.insert(std::pair<GLchar, Character>(c, character));
|
||||
}
|
||||
|
||||
FT_Done_Face(face);
|
||||
FT_Done_Face(Face);
|
||||
FT_Done_FreeType(library);
|
||||
GLERROR("Font Load");
|
||||
}
|
||||
|
||||
@@ -46,10 +46,8 @@ void PickingPass::InitializeShaderPrograms()
|
||||
void PickingPass::Draw(RenderScene& scene)
|
||||
{
|
||||
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
|
||||
|
||||
|
||||
//TODO: Render: Add code for more jobs than modeljobs.
|
||||
|
||||
GLuint ShaderHandle = m_PickingProgram->GetHandle();
|
||||
m_PickingProgram->Bind();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user