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

Pages: [1]
1
Graphics / Re: window.draw(sprite) White Screen
« on: March 03, 2018, 01:17:41 pm »
Have a look at the first code snippet and look closely where draw(), clear() and display() are called ;) (inside or outside of the isOpen() loop)

https://www.sfml-dev.org/tutorials/2.4/graphics-draw.php


AlexAUT

I can't believe it how stupid I am! :) It seems that other pair of eyes can see things my won't :)
Thank you very much!

2
Graphics / [SOLVED] window.draw(sprite) White Screen
« on: March 03, 2018, 10:22:41 am »
Hello,

After searching the whole internet, I'm desperately asking for help.
While executing the code below, I'm getting a white screen instead of the texture!
What might be the cause?
I'm not destructing Texture anywhere, file is loaded into the texture...

Thank you anyway! :)

#include "stdafx.h"
#include <SFML/Graphics.hpp>
#include <iostream>

using namespace sf;

int main()
{

        VideoMode vm(1280, 720);

        RenderWindow window(vm, "TIMBER_VS17", Style::Default);

        Texture backgroundTexture;

        //DEBUG LOADING TEXTURE FROM FILE//
        if (!backgroundTexture.loadFromFile("graphics/background.jpg"))
        {
                std::cout << "LOG:\tCANNOT OPEN THE FILE\n";
        }
        else if (backgroundTexture.loadFromFile("graphics/background.jpg"))
        {
                std::cout << "LOG:\tFILE LOADED SUCCESSFULLY\n";
        }

        Sprite spriteBackground;
        spriteBackground.setTexture(backgroundTexture);
        spriteBackground.setPosition(0, 0);
       
        while (window.isOpen())
        {
                if (Keyboard::isKeyPressed(Keyboard::Escape))
                {
                        window.close();
                }
        }
       
        window.clear();

        window.draw(spriteBackground);

        window.display();

        return 0;
}
 

3
Graphics / Re: Sprite draw unresolved externals
« on: March 02, 2018, 01:36:02 pm »
Did you try using the absolute path?

And a little update:

Texture textureBackground;
        textureBackground.loadFromFile("background.png");
        if (!textureBackground.loadFromFile("background.png"))
        {
                std::cout << "ERROR";
        }
        else if (textureBackground.loadFromFile("background.png"))
        {
                std::cout << "FILE FOUND";
        }
 

Cout throws out "FILE FOUND".
Sorry for being such annoying, but I'm really desperate.

4
Graphics / Re: Sprite draw unresolved externals
« on: March 02, 2018, 01:28:14 pm »
Did you try using the absolute path?

I did the following:

// TIMBER4.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <SFML/Graphics.hpp>
#include <iostream>

using namespace sf;


int main()
{
        system("dir");
       
        //Creating object 'vm' of 'VideoMode' class
        VideoMode vm(1280, 720);

        //Creating object 'window' of 'RenderWindow' class
        RenderWindow window(vm, "TIMBER", Style::Default);

        //Setting texture
        Texture textureBackground;
       
        if (!textureBackground.loadFromFile("graphics/background.png"))
        {
                std::cout << "ERROR";
        }

        //Create Sprite and attach a Texture
        Sprite spriteBackground;
        spriteBackground.setTexture(textureBackground);
        spriteBackground.setPosition(0, 0);

        while (window.isOpen())
        {
                if (Keyboard::isKeyPressed(Keyboard::Escape))
                {
                        window.close();
                }

        }

        window.clear();

        //window.draw(spriteBackground);

        window.display();

        return 0;
}
 

Result? Printed out DIR (it's OK so far I can say) and did not print our "ERROR" message. Does it mean that the texture.loadFromFile successfully loaded a texture from the file?

If so, I don't understand why I'm getting the error. If the line '//window.draw(spriteBackground);' is not commented out, the error LNK2001 (unresolved external symbol) appears with message: 'Severity   Code   Description   Project   File   Line   Suppression State
Error   LNK2001   unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)'. So far I understand - the draw fce is not able to process the argument Sprite, am I right?

If so, why is that happening?

5
Graphics / Re: Sprite draw unresolved externals
« on: March 02, 2018, 09:34:15 am »
Did you try using the absolute path?

I did. Even tried to move file to non-system disc "D", but still failed.
Am I missing any library? Using WIN32 console and 32 libraries mentioned in the original post.

6
Graphics / Re: Sprite draw unresolved externals
« on: March 01, 2018, 08:40:50 pm »
You should always check the boolean result of loading an image (and most other things too) to see whether it succeeds or fails, rather than just carry on as if it's fine.

The image might be in an unsupported format or you may have the path incorrect. A good way to check both is to specify the image's absolute path. If it still doesn't work (and the absolute path is correct), the image is the problem, and if the does work, your path was the problem.

Thank you for suggestions.
I did a simple check:
if (!backgroundTexture.loadFromFile("graphics/background2.jpg")) {
                return 1;
        }
 
It returned false. My thoughts are that VS doesn't have sufficient permissions to read the file. But the error appears anyway, despite changed folder.
Am I missing something? Maybe the main reason is that project was created from custom template...

7
Graphics / Re: Sprite draw unresolved externals
« on: March 01, 2018, 04:24:02 pm »
Since I'm very clever :), I changed Style::Fullscreen to Style::default and I witnessed an error message:


Failed to load image "graphics/background". Reason: Unable to open file

Project path:
C:\Users\cpp_shared\documents\visual studio 2015\Projects\test004\
Image path:
C:\Users\cpp_shared\documents\visual studio 2015\Projects\test004\graphics\

What might be the problem in here?

8
Graphics / [SOLVED] Sprite draw unresolved externals
« on: March 01, 2018, 04:10:33 pm »
Hi there,
While declaring code, I got two errors - Unresolved external symbol and 1 unresolved externals. I see that the first causes the second one. The 'graphics' folder is located in the Project Location:
C:\Users\cpp_shared\documents\visual studio 2015\Projects\test004\graphics

SFML libraries declared in Project->Properties->Debug->Linker->Input:
sfml-graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;sfml-network-d.lib;sfml-audio-d.lib;

I would be very happy if anyone could help me :)

Code:

// SFML_default.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <SFML/Graphics.hpp>

using namespace sf;


int main()
{
        VideoMode vm(1280, 720);

        RenderWindow window(vm, "TEST", Style::Default);

        Texture backgroundTexture;

        backgroundTexture.loadFromFile("graphics/background");

        Sprite backgroundSprite;

        backgroundSprite.setTexture(backgroundTexture);

        backgroundSprite.setOrigin(0, 0);

        while (window.isOpen())
        {
                if (Keyboard::isKeyPressed(Keyboard::Escape))
                {
                        window.close();
                }
        }

        window.clear();

        window.draw(backgroundSprite); //<--|| Here goes the failure

        window.display();
       
        return 0;
}
 

Pages: [1]