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

Pages: [1]
1
Graphics / Re: LoadFromFile undefined reference problem
« on: September 27, 2016, 07:21:05 pm »
Thank you a plenty eXpl0it3r, this fixed my issue.

2
Graphics / LoadFromFile undefined reference problem
« on: September 26, 2016, 11:03:36 pm »
I have no idea what to do. I tried loading images (bmp), music (wav) or font (ttf) with LoadFromFile function, but the compiler always spits out similar error.

|In function `main':|
C:\_stuff\code blocks\projects\game1\main.cpp|14|undefined reference to `sf::Texture::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Rect<int> const&)'|
C:\_stuff\code blocks\projects\game1\main.cpp|15|undefined reference to `sf::Font::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
 

This is how the source code looks:

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

int main()
{
    sf::Font font;
    sf::Texture hero_idle_texture;
    hero_idle_texture.loadFromFile("hero_idle.bmp");
    font.loadFromFile("arial.ttf");
    return 0;
}

I put files both in the obj file and in the exe file directory. I tried reinstalling SFML, compiler and Code::Blocks several times, but it didn't work.

I'm programming in Code::Blocks, using SFML 2.3.2 and my OS is Windows 10 64 bit.

I also tried to recompile SFML using CMake but I got this problem: http://stackoverflow.com/questions/39680283/cannot-generate-files-with-cmake-using-mingw-makefiles

3
Graphics / Re: sf::RenderWindow problem
« on: April 14, 2015, 09:25:46 pm »
Don't listen what MasterDeveloper said. He seems to be a troll.

Do you link dynamically against SFML?
What's your compiler (Code::Blocks is an IDE not a compiler) and from where did you get SFML?
Yes.
MinGW32 and from official website. I'm using v2.2

4
Graphics / Re: sf::RenderWindow problem
« on: April 12, 2015, 05:19:57 pm »
I would suggest editing the code so that mode is set to a fixed value and isn't changed by the program. Then try mode as 0,1 and 2 by changing the initialisation to see in which part of the program the problem is. If this doesn't change anything then you've narrowed down the problem to the initialisation, the draw call or the event handling. This may not completely solve the problem but it has helped me in the past and if you know where the problem is then it is a lot easier to correct. It is, after all entirely possible that the window contruction is okay and the problem is elsewhere which is stopping it from showing.

Also, why have you included <iostream> and <cmath>?
It crashes when it calls any SFML - related function, apparently.

This is not in the code, but for communicates about loaded files in the console and trygonometric functions.
What bit Windows do you have? (x86 - x64)????
What mode are you using for compiling???
x86
What mode?
It was with me to. :) You may use release libs for debud or debug libs for release - this is the reason for crashing! So if you want to stop crashing use sfml-xxx-d.lib in linker when you compile the debug version of programm or sfml-xxx.lib for release version. :)
I relinked the files and it still doesn't work.

5
Graphics / sf::RenderWindow problem
« on: April 11, 2015, 07:56:02 pm »
I apoligize for my laziness if a thread with this problem has already been created.

I have a problem with RenderWindow. Specifically, after compilation, I get a crash report like this:
Quote from: Windows
gamePrototype.exe stopped working
An error caused a program to stop working correctly. Windows will close the program and notify you of available solutions.
The window doesn't want to open, but the console still works.
My code:
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <cmath>
#include <iostream>
float falling(float time)
{
    return 10*(time/1000);
}
int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600, 32), "My Window");   //1
    window.setFramerateLimit(60);
    sf::Texture texture;
    sf::Sprite sprite;
    sf::Clock clock;
    sf::Event event;
    texture.loadFromFile("cos.png");
    sprite.setTexture(texture);
    sprite.setScale(sf::Vector2f(0.1f, 0.1f));
    sf::RectangleShape rectangle(sf::Vector2f(30, 600));
    rectangle.setFillColor(sf::Color::Red);
    rectangle.setPosition(510,0);
    int a = -30, mode = 1;
    while (window.isOpen())
    {
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::F10))
                window.close();
        }
        if(mode==0)
        {
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))sprite.move(-4,0);
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))sprite.move(4,0);
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::X))
            {
                sf::Time playerTime=clock.getElapsedTime();
                float time=playerTime.asMilliseconds();
                sprite.move(0,a+falling(time));
                mode = 1;
            }
            if(sprite.getPosition().x>510&&sprite.getPosition().x<540)
            {
                if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))mode = 2;
                if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))mode = 2;
            }
            clock.restart();
        }
        if(mode==1)
        {
            sf::Time playerTime=clock.getElapsedTime();
            float time=playerTime.asMilliseconds();
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))sprite.move(-4,0);
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))sprite.move(4,0);
            if(sprite.getPosition().y<500)
            {
                sprite.move(0,falling(time));
            }
            else mode = 0;
            if(sprite.getPosition().x>510&&sprite.getPosition().x<540)
            {
                if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))mode = 2;
                if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))mode = 2;
            }
        }
        if(mode==2)
        {
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))sprite.move(0,-4);
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
            {
                if(sprite.getPosition().y<500)sprite.move(0,4);
                else mode = 0;
            }
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::X))mode = 1;
            clock.restart();
        }
        window.clear(sf::Color::White);
        window.draw(rectangle);
        window.draw(sprite);
        window.display();
    }

    return 0;
}
// 1 = everything except for this line is alright
 
I use Code::Blocks.

Pages: [1]