Fix typo
Misspelled package name
no I'm pretty sure it's 2.0: https://packages.ubuntu.com/xenial/libsdl-ttf2.0-dev
Its actually 2, not 2.0. Just like the rest are all just 2. No 2.0. Exactly what I had to do to get it to work. There's 2.0 but that's not what I used. Its just ...2-dev
are you on ubuntu?
Yes. elementary OS precisely but its Ubuntu based. Version 16.04 at the moment.
Do it's not 2.0, its just 2, just like the rest of the sdl packages I added. When you install the 2.0 one, it'll not work
can you check if the ttf package is even needed? It might even be libsdl2-ttf-2.0 or libsdl2-ttf-dev which you need instead
here apply this patch and then try to run the example game to see if it works (try without any sdl ttf packages installed first and then try installing until it works):
diff --git a/example/dub.sdl b/example/dub.sdl
index 0bfa1a2..f411776 100644
--- a/example/dub.sdl
+++ b/example/dub.sdl
@@ -2,5 +2,5 @@ name "example"
dependency "d2dgame" path=".."
-versions "BindSDL_Image" "BindSDL_Mixer"
+versions "BindSDL_Image" "BindSDL_Mixer" "BindSDL_TTF"
diff --git a/example/source/app.d b/example/source/app.d
index 129a36d..575c220 100644
--- a/example/source/app.d
+++ b/example/source/app.d
@@ -60,7 +60,7 @@ private:
int currentX, currentY;
bool clicked = false;
int thrown = 0;
- ShaderProgram shader, textShader;
+ ShaderProgram shader;
Texture normal;
Sound whosh;
Music music;
@@ -100,24 +100,13 @@ public:
shader.set("tex", 0);
shader.set("tex2", 1);
- textShader = new ShaderProgram();
- textShader.attach(Shader.create(ShaderType.Vertex, import ("font.vert")));
- textShader.attach(Shader.create(ShaderType.Fragment, import ("default.frag")));
- textShader.link();
- textShader.registerUniform("projection");
- textShader.registerUniform("transform");
- textShader.registerUniform("tex");
- textShader.registerUniform("texRect");
- textShader.registerUniform("sizeRect");
-
- textShader.set("tex", 0);
-
normal = new Texture("res/tex/shuriken-normal.png", TextureFilterMode.LinearMipmapLinear, TextureFilterMode.Linear, TextureClampMode.ClampToEdge, TextureClampMode.ClampToEdge);
- font = new BMFont("res/font/");
- font.load("res/font/roboto.fnt", 0);
+ font = new TTFFont();
+ font.load("/usr/share/fonts/TTF/Roboto-Regular.ttf", 20);
text = font.renderMultiline("Shuriken Simulator EXTREME SUPER ULTRA DELUXE EDITION OMEGA 2.WHOA\nThrown: " ~ thrown.to!string);
+ import std.stdio; writeln("text dimensions: ", font.measureText("hello world"));
}
override void update(float delta)
@@ -180,7 +169,7 @@ public:
window.draw(mouse, shader);
}
- window.draw(text, textShader);
+ window.draw(text);
}
}