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

Author Topic: SFML Port Problem: Textures Not Displayed  (Read 1805 times)

0 Members and 1 Guest are viewing this topic.

spacechase0

  • Newbie
  • *
  • Posts: 39
    • AOL Instant Messenger - thespacechase0
    • View Profile
    • http://spacechase0.com/
SFML Port Problem: Textures Not Displayed
« on: April 15, 2012, 09:19:00 pm »
I've been sporadically working on an SFML port for a while, and I almost have every module (except audio) working. The main problem is that the graphics module won't work with textures.

#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
        std::streambuf* coutBuf = std::cout.rdbuf();
        std::streambuf* errBuf = sf::err().rdbuf();
        sf::err().rdbuf( coutBuf );
       
        sf::RenderWindow window( sf::VideoMode( 320, 240, 24 ),"Window" );
        window.setFramerateLimit( 1 );
       
        sf::Font font;
        std::cout << "Loading \"resources/sansation.ttf\"... " << ( font.loadFromFile("resources/sansation.ttf") ? "Success" : "Failure" ) << std::endl;

        sf::Texture tex;
        std::cout << "Loading \"resources/image.png\"... " << ( tex.loadFromFile( "resources/image.png" ) ? "Success" : "Failure" ) << std::endl;
       
        std::cout<<"SC\n\n";
        sf::Text text( "String", font, 20.f );
        std::cout<<"MC\n\n";
        sf::Sprite spr;
        spr.setTexture( tex, true );
        spr.setPosition( sf::Vector2f( 100, 100 ) );
        std::cout << "EC\n\n";
       
        while ( window.isOpen() )
        {
                sf::Event event;
                while ( window.pollEvent( event ) )
                {
                        if ( event.type == sf::Event::Closed )
                        {
                                window.close();
                        }
                        else if ( event.type == sf::Event::KeyPressed )
                        {
                                std::cout << "Key pressed" << std::endl;
                                if ( event.key.code == sf::Keyboard::Menu )
                                {
                                        window.close();
                                }
                        }
                }
               
                window.clear();
                window.draw( text );
                window.draw( spr );
                window.display();
        }
       
        std::cout.rdbuf( coutBuf );
        sf::err().rdbuf( errBuf );
}
This works fine on my computer, but on the GP2X Wiz (what I'm porting to), it doesn't.

Whether I use sf::Sprite or sf::Text (or both), nothing gets displayed. If I use sf::Sprite, there is a segmentation fault after the main loop (maybe from sf::Texture?).

sf::*Shape works fine though. :) I haven't tested it with a texture.

The logs (minus a bunch of unrelated stuff):
Code: [Select]
Loading "resources/sansation.ttf"... Success
Loading "resources/image.png"... Success
SC

Failed to create texture, invalid size (0x0)
Failed to create texture, invalid size (0x0)
Trying to access the pixels of an empty image
MC

EC

Key pressed
Key pressed
Segmentation fault

So, I'm completely lost. :P Any ideas?

EDIT: Oops, forgot to mention the code is here: https://github.com/spacechase0/SFML/tree/wiz
« Last Edit: April 15, 2012, 09:21:48 pm by spacechase0 »

 

anything