Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    56
  • comments
    80
  • views
    41942

Easy to use

Sign in to follow this  
bladerunner627

208 views

With simplicity comes ease of use, at least in my case.

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:

Text example

I still need to write the routine to calculate the UVs for each character so it's not monospaced.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!