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 - litedrive

Pages: [1]
1
Hi, I just compiled SFML 2.0 from source and am dynamically linking the libraries.

Currently, all I've really been doing is playing with the API in hopes to make a basic Asteroids game. The main issue I'm having though is trying to understand what could be causing this issue, as the sf::Text is being rendered squares and not as actual text. I've tried using different fonts, loading the font object itself differently, setting different char sizes; sf::Colors; sf::BlendModes, etc and none of that has worked.

To give you an example, I'll post some code.

At first, there is a utility function which simply performs the following:

void LoadFont( const std::string& fontname, sf::Font& out_font )
{
        const std::string fullpath = "assets/fonts/" + fontname;

        if ( !out_font.loadFromFile( fullpath ) )
                ErrorQuit( "loading font \"" + fullpath + "\" failed." );
}

In the main game class, the font is loaded like so at the beginning of execution:

LoadFont( "arial.ttf", mMainFont );

And then the code to actually draw the text resides in a simple function ( DrawText() ):

void Game::DrawText( void )
{
        // Draw current mouse coordinates:

        sf::Vector2i mousepos = sf::Mouse::getPosition( mWindow );

        sf::Text out;

        out.setFont( mMainFont );
        out.setCharacterSize( 30 );
        out.setColor( sf::Color( 255, 255, 0, 0 ) );
        out.setPosition( 20.0f, 20.0f );

        std::ostringstream oss;

        oss << "Mouse X => " << mousepos.x << "\n Mouse Y => " << mousepos.y;

        out.setString( oss.str() );

        mWindow.draw( out, sf::RenderStates( sf::BlendMode::BlendNone ) );
}
 

And, as a result, I get the following:



Please note that sf::RenderStates::Default returns a linker error, hence why I'm embedding a sf::RenderStates option within the mWindow.draw().

Also, I should also say that I compiled this to be used with MSVC 2012. I'm not sure if I need to link with FreeType font library as well for this to work, so if any clarification with that could be made, I'd appreciate it.

Thanks.

2
System / Installing SFML in VS 2010
« on: December 03, 2011, 06:57:09 pm »
Before anyone mentions it, I've already followed the directions listed a http://www.sfml-dev.org/forum/viewtopic.php?p=8576, and unfortunately, they didn't work. My errors are the following:

Code: [Select]
Error 1 error LNK2019: unresolved external symbol "void __cdecl sf::Sleep(float)" (?Sleep@sf@@YAXM@Z) referenced in function _main c:\Users\Owner\documents\visual studio 2010\Projects\Engine\Engine\main.obj Engine
Error 2 error LNK2019: unresolved external symbol "public: float __thiscall sf::Clock::GetElapsedTime(void)const " (?GetElapsedTime@Clock@sf@@QBEMXZ) referenced in function _main c:\Users\Owner\documents\visual studio 2010\Projects\Engine\Engine\main.obj Engine
Error 3 error LNK2019: unresolved external symbol "public: __thiscall sf::Clock::Clock(void)" (??0Clock@sf@@QAE@XZ) referenced in function _main c:\Users\Owner\documents\visual studio 2010\Projects\Engine\Engine\main.obj Engine
Error 4 error LNK1120: 3 unresolved externals c:\users\owner\documents\visual studio 2010\Projects\Engine\Debug\Engine.exe 1 1 Engine


Could someone help me out with this? Any help would be greatly appreciated.
 :D

Pages: [1]
anything