Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Nemykal

Pages: [1]
1
Graphics / [solved] Embedding fonts like arial.hpp
« on: October 04, 2011, 11:48:33 am »
By int I just meant a standard int32_t

2
Graphics / [solved] Embedding fonts like arial.hpp
« on: October 04, 2011, 11:07:04 am »
Been playing around with what you posted, which doesn't work by the way.

I compared the output with arial.hpp and I'm just not sure what data Font::LoadFromMemory expects. Is it expecting an array of ints, as your solution indicates, or is it expecting an array of bytes, which is what arial.hpp has? I tried a few utilities to convert files to .c source, such as Hex Workshop from http://www.bpsoft.com.

I declare the array of fontdata in a header as such:

const char terminus_data[] =
{
   #include "terminus.h"
};

and terminus.h contains only the array of data, just like arial.hpp.

Compiles without issues, and LoadFromMemory returns without errors, but nothing is displayed on screen.

The only thing I changed in my initialization code was commenting out the LoadFromFile and replacing it with the LoadFromMemory, and it was working fine with LoadFromFile, so I think the problem is the format of the terminus.h

Any help is appreciated


[EDIT]

Nevermind, fixed it. I had inadvertently commented out these two lines in my drawing thread (before and after drawing the text) since I thought they weren't necessary anymore:
window->SaveGLStates();
//draw stuff
window->RestoreGLStates();

With those lines uncommented, it displays fine.

So for future reference for anyone else, I used that program I linked above in order to convert a .ttf to a c source.

3
Graphics / [solved] Embedding fonts like arial.hpp
« on: October 04, 2011, 08:35:04 am »
I can find a lot of information for doing this with images, but nothing with regards to .ttf files. Is there any recommended utility for encoding them?

4
Graphics / [solved] Embedding fonts like arial.hpp
« on: October 04, 2011, 06:31:10 am »
Hi,
What is the process for encoding a ttf font so that I can embed that data into a header file, just like arial.hpp, the default font?
Thanks

5
Window / SetFramerateLimit() not working precisely
« on: September 24, 2011, 12:40:54 pm »
Is there some way to modify sf::Sleep to be more precise? I would think that stuff like QueryPerformanceCounter() should at least give enough precision. 1 / 60 isn't that precise...

6
Window / SetFramerateLimit() not working precisely
« on: September 24, 2011, 12:07:08 pm »
Hi, I want to limit my program to 60fps, but when I call
Code: [Select]
window->SetFramerateLimit(60); it results in an FPS that fluctuates between 62.5 and 67 FPS.

I made a sample test program to demonstrate this:

Code: [Select]
#include <stdint.h>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>


sf::Text* fpstext;
sf::Font* pixelfont;
sf::RenderWindow* window;
sf::Event event;

double gameFPS = 0.0f;
bool PROGRAM_EXIT = false;

void handleEvents()
{
while (window->PollEvent(event))
{
// Close window : exit
if (event.Type == sf::Event::Closed)
{
PROGRAM_EXIT = true;
}
}
}

void init()
{
window = new sf::RenderWindow(sf::VideoMode(1024, 768), "FPS Test", sf::Style::Default | sf::Style::Resize, sf::ContextSettings(32, 8, 0));
window->SetFramerateLimit(60);
window->EnableVerticalSync(false);

sf::Event event = sf::Event();
pixelfont = new sf::Font();
fpstext = new sf::Text("Fps!");
fpstext->SetCharacterSize(16);
fpstext->SetPosition(0, 0);
//fpstext->SetFont(*pixelfont);
fpstext->SetColor(sf::Color::Red);
}

void drawFPS()
{
static sf::String fps;
static char buf[128];
memset(buf, 0, 128);
sprintf(buf, "FPS: %8.4f", gameFPS);
fps = buf;
fpstext->SetString(fps);
window->Draw(*fpstext);
}

int main(int argc, char** argv)
{
init();
while (!PROGRAM_EXIT)
{
handleEvents();
window->Clear();
drawFPS();
window->Display();
gameFPS = 1.f / window->GetFrameTime() * 1000;
}

return 0;
}


For what it's worth, I am using the latest git of SFML 2.0, compiled for VS2010 64 bit. I am also using SFML_STATIC and linking with the static libs.

Any help or advice is appreciated, I just want to know why I can't get a flat 60fps.

Pages: [1]
anything