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

Pages: [1]
1
General / Re: I can't use std::ofstream
« on: November 05, 2015, 10:31:28 pm »
No, as I said there are no compile errors no runtime errors and nothing on the terminal. And I checked sf::Texture::loadFromFile() does it's job, but program terminates before main loop somehow.

2
General / Re: I can't use std::ofstream
« on: November 05, 2015, 02:18:47 am »
I've simplify it trying(deactivating-activating) line by line. And I got this:
#include<SFML/Graphics.hpp>
#include<fstream>

int main()
{
        std::ofstream record( "Records/file.txt" );
    sf::RenderWindow mainWindow;
    sf::Event event;
    sf::Texture BGTexture;
    sf::Sprite Background;
    sf::Clock clock;

    mainWindow.create( sf::VideoMode::getDesktopMode(), "Moving Arrows" );
    mainWindow.setVerticalSyncEnabled(true);

    [b]BGTexture.loadFromFile("Background.jpg");[/b]
    Background.setTexture( BGTexture );

    if( mainWindow.isOpen() )
    {
        mainWindow.pollEvent( event );
        mainWindow.clear( sf::Color::Black );
        mainWindow.display();
        clock.restart();

        while( event.type != sf::Event::Closed )
        {
                        mainWindow.pollEvent( event );

                        mainWindow.clear( sf::Color::Black );
                        mainWindow.draw(Background);
                        mainWindow.display();
                        record<<"X";
                }

                mainWindow.close();
                record.close();
        }
        return 0;
}
 
This works on Windows, but when try it on Ubuntu it acts same as before. The problem is with sf::Texture::loadFromFile() function. When I delete it(or either std::ofstream) it works as it suppossed to be.
Of course shows a black screen.
On the other hand, I tried deleting same function from the main file(and from the arrow.hpp) and same problem kept occuring on Ubuntu.
I guess I will be working with Windows for now, when I have time I'll try to solve that problem with Ubuntu.

3
General / I can't use std::ofstream
« on: November 05, 2015, 12:09:08 am »
I'm trying to make an animation of moving arrows and I need to keep record of time, in a text file, how much arrows stays visible on the screen. But when I write(and not even use that variable):
std::ofstream record;
It compiles without an error but screen shows up and closes immediately. It shows one frame but never gets into main loop. But when I delete only that line everything else works fine.
I suspected namespace members overlapping somehow but that's not the issue.I tried on Windows 7 x64 with CodeBlocks+mingw(GCC 4.8.1) and on Ubuntu 15.04 x64 with gcc 5.1.0.
I tried with a simple program (one that is here bottom of the page : http://www.sfml-dev.org/tutorials/2.3/start-cb.php) and added that the lines that I'm trying to use to write to a text file,only with a random string, and it works.
There are a little too much code so I didn't paste it all here and couldn't simplify it but I'm adding the files as an attachment.
This is how I compile if it's relevant:
g++ -std=c++11 -Wall -Wextra -Werror main.cpp -lm arrow.hpp -lsfml-graphics -lsfml-window -lsfml-system

I really need to keep the records and if there is another way of doing it, I'd like to know.

Pages: [1]