diff --git a/examples/text/Game.cpp b/examples/text/Game.cpp new file mode 100644 index 0000000..99d34b4 --- /dev/null +++ b/examples/text/Game.cpp @@ -0,0 +1,88 @@ + +#include +#include +#include +#include +#include "Game.h" + +Font smallFont; +Font myFont; +Font fntLarge; + +Text myText; +Text txtLarge; +Text txtKerning; +Text fpsText; +Text txtSmall; + +Camera2D guiCamera; + +BatchRenderer2D *renderer; + +void TextExample::init() +{ + Graphics* g = getGraphics(); + + g->setClearColor(52.0f / 255.0f, 58.0f / 255.0f, 80.0f / 255.0f); + + smallFont.loadFromFile("assets/fonts/RobotoCondensed-Regular.ttf", 14); + myFont.loadFromFile("assets/fonts/RobotoCondensed-Regular.ttf", 20); + fntLarge.loadFromFile("assets/fonts/OPTIBelwe-Medium.otf", 48); + + myText.setFont(myFont); + myText.setColor(Color::Green); + myText.setString("Hello"); + myText.setPosition(25.0f, 50.0f); + + txtLarge.setFont(myFont); + txtLarge.setColor(Color(200, 100, 0)); + txtLarge.setString("Large Text, Looks good?"); + txtLarge.setPosition(300.0f, 150.0f); + txtLarge.setScale(2.0f); + + txtKerning.setFont(fntLarge); + txtKerning.setColor(Color(150, 0, 230)); + txtKerning.setString("Kerning: VA Ta"); + txtKerning.setPosition(150.0f, 200.0f); + + txtSmall.setFont(smallFont); + txtSmall.setString("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a rhoncus odio, nec finibus libero."); + txtSmall.setPosition(50.0f, 450.0f); + + fpsText.setFont(myFont); + fpsText.setString("FPS: 0"); + fpsText.setPosition(10.0f, 10.0f); + + renderer = new BatchRenderer2D(); +} + +void TextExample::update(double dt) +{ + InputModule* input = getInput(); + input->update(); + + if (getFpsCounter().update()) { + std::string str = "FPS: " + core::to_string(getFpsCounter().getFPS(), 0); + fpsText.setString(str); + } +} + +void TextExample::render() +{ + Graphics* g = getGraphics(); + + g->clearBuffer(); + + renderer->begin(); + + renderer->submit(fpsText); + renderer->submit(myText); + renderer->submit(txtLarge); + renderer->submit(txtKerning); + renderer->submit(txtSmall); + + renderer->setCamera(guiCamera); + renderer->render(); + + g->swapBuffers(); +} \ No newline at end of file diff --git a/examples/text/Game.h b/examples/text/Game.h new file mode 100644 index 0000000..0a8904d --- /dev/null +++ b/examples/text/Game.h @@ -0,0 +1,20 @@ + +#ifndef TEXT_GAME_H +#define TEXT_GAME_H + +#include +#include +#include + +class TextExample : public Game, public InputListener +{ +protected : + + void init(); + + void update(double dt); + + void render(); +}; + +#endif /* TEXT_GAME_H*/ \ No newline at end of file diff --git a/examples/text/main.cpp b/examples/text/main.cpp new file mode 100644 index 0000000..8f2af62 --- /dev/null +++ b/examples/text/main.cpp @@ -0,0 +1,11 @@ + +#include "Game.h" + +int main(int argc, char **argv) { + + TextExample game; + + game.run(); + + return 0; +} \ No newline at end of file diff --git a/examples/vsproj/example_text.filters b/examples/vsproj/example_text.filters new file mode 100644 index 0000000..d7ef6a1 --- /dev/null +++ b/examples/vsproj/example_text.filters @@ -0,0 +1,17 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + \ No newline at end of file diff --git a/vsproj/Examples.sln b/vsproj/Examples.sln new file mode 100644 index 0000000..e6fb77f --- /dev/null +++ b/vsproj/Examples.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_text", "examples\vsproj\example_text.vcxproj", "{C33DE942-1754-4592-AAA4-ED75BFF50E44}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Spectre", "Spectre.vcxproj", "{E789E1AD-BD26-4D1C-BAA7-A5A0FF50D59C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C33DE942-1754-4592-AAA4-ED75BFF50E44}.Debug|Win32.ActiveCfg = Debug|Win32 + {C33DE942-1754-4592-AAA4-ED75BFF50E44}.Debug|Win32.Build.0 = Debug|Win32 + {C33DE942-1754-4592-AAA4-ED75BFF50E44}.Release|Win32.ActiveCfg = Release|Win32 + {C33DE942-1754-4592-AAA4-ED75BFF50E44}.Release|Win32.Build.0 = Release|Win32 + {E789E1AD-BD26-4D1C-BAA7-A5A0FF50D59C}.Debug|Win32.ActiveCfg = Debug|Win32 + {E789E1AD-BD26-4D1C-BAA7-A5A0FF50D59C}.Debug|Win32.Build.0 = Debug|Win32 + {E789E1AD-BD26-4D1C-BAA7-A5A0FF50D59C}.Release|Win32.ActiveCfg = Release|Win32 + {E789E1AD-BD26-4D1C-BAA7-A5A0FF50D59C}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal