Here's an example of how to output some text to the screen:
#define _BUILD_STRING_ "Odorless Entertainment - Framework - Build: " __DATE__ " at " __TIME__#include "src/FW.h"#include "src/UI/Fonts/FontManager.h"#include Odorless::Framework::UI::Fonts::FontManager *fontManager;void Initialize(){ fontManager = new Odorless::Framework::UI::Fonts::FontManager(); fontManager->AddFont("base/textures/fonts/phantom"); fontManager->SetFont("base/textures/fonts/phantom"); glEnable(GL_LINE); glEnable(GL_POINT); glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); glEnable(GL_ALPHA); glEnable(GL_TEXTURE_2D);}void Update(double deltaTime){ return;}void Draw(double deltaTime){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor4f(1, 1, 1, 1.0f); glPushMatrix(); fontManager->Write("Gamedev.net\nNew line test!"); glPopMatrix();}void OnResize(int width, int height){ Odorless::Framework::Base::VSync(false); glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0f, width, height, 0.0f, -1.0f, 1.0f);}int main(){ Odorless::Framework::Base::InitializeFramework(); Odorless::Framework::Base::OpenWindow(800, 600, 8, 8, 8, 8, 24, 8); Odorless::Framework::Base::SetWindowResize(OnResize); Odorless::Framework::Base::SetWindowTitle(_BUILD_STRING_); Odorless::Framework::Base::SetInitialize(Initialize); Odorless::Framework::Base::SetUpdate(Update); Odorless::Framework::Base::SetDraw(Draw); Odorless::Framework::Base::Initialize(); while (Odorless::Framework::Base::IsRunning()) { Odorless::Framework::Base::Update(0.0); Odorless::Framework::Base::Draw(0.0); Odorless::Framework::Base::Flush(); Odorless::Framework::Base::SwapBuffers(); if (glfwGetKey(GLFW_KEY_ESC) || !glfwGetWindowParam(GLFW_OPENED)) break; } Odorless::Framework::Base::Dispose(); delete fontManager; return 0;}
The code above gives you the following:
I still need to write the routine to calculate the UVs for each character so it's not monospaced.