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

Author Topic: Problem with sprites/textures  (Read 2326 times)

0 Members and 1 Guest are viewing this topic.

KyleGBC

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Problem with sprites/textures
« on: March 29, 2018, 12:44:45 am »
When I try to load a texture, create a sprite with that texture, and then draw that sprite, I get a bunch of weird characters in the console and then a runtime error.
==Details==
  • I am running Windows 10, with a Nvidia quadro K5000M graphics card
  • Using dynamic SMFL 2.4.2
  • Using Visual Studio 2015 community
Here is the code:
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <iostream>

int main()
{
        sf::Texture myTexture;
        myTexture.loadFromFile("Images/profilePicture.jpg");
        sf::Sprite mySprite;
        mySprite.setTexture(myTexture);
        sf::RenderWindow window(sf::VideoMode(200, 200), "SFMLgame");
        sf::Clock clock;
        sf::CircleShape shape(100.f);
        while (window.isOpen())
        {
                sf::Time theTime = clock.getElapsedTime();
                std::cout << theTime.asSeconds() << std::endl;
                sf::Event event;
                while (window.pollEvent(event))
                {
                       
                        switch (event.type)
                        {

                        case sf::Event::Closed:
                                window.close();
                                break;


                        case sf::Event::MouseMoved:
                                break;

                        }
                       
                }

                window.clear(sf::Color::Cyan);
                window.draw(mySprite);
                window.display();
        }
       
        system("pause");
        return 0;
}
The console is attached, no other window is created
The debug text is this:
Code: [Select]
'SFMLgame.exe' (Win32): Loaded 'C:\Users\Kyle\Documents\Visual Studio 2015\Projects\SFMLgame\Debug\SFMLgame.exe'. Symbols loaded.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Users\Kyle\Documents\Visual Studio 2015\Projects\SFMLgame\SFMLgame\sfml-graphics-2.dll'. Module was built without symbols.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp140d.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbase.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Users\Kyle\Documents\Visual Studio 2015\Projects\SFMLgame\SFMLgame\sfml-system-2.dll'. Module was built without symbols.
'SFMLgame.exe' (Win32): Loaded 'C:\Users\Kyle\Documents\Visual Studio 2015\Projects\SFMLgame\SFMLgame\sfml-window-2.dll'. Module was built without symbols.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\vcruntime140d.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ucrtbased.dll'
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32full.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ucrtbased.dll'
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\opengl32.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp140.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp_win.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\vcruntime140.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmm.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\win32u.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmmbase.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmmbase.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\winmmbase.dll'
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\glu32.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\System32\DriverStore\FileRepository\nvdm.inf_amd64_d7a8661bc29bbf05\nvinit.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ig7icd32.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\wtsapi32.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\igdusc32.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dwmapi.dll'. Cannot find or open the PDB file.
'SFMLgame.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\version.dll'
'SFMLgame.exe' (Win32): Unloaded 'C:\Windows\System32\DriverStore\FileRepository\nvdm.inf_amd64_d7a8661bc29bbf05\nvinit.dll'
The thread 0x2a30 has exited with code 0 (0x0).
'SFMLgame.exe' (Win32): Loaded 'C:\Windows\SysWOW64\powrprof.dll'. Cannot find or open the PDB file.
Exception thrown at 0x73DEE37D (vcruntime140.dll) in SFMLgame.exe: 0xC0000005: Access violation reading location 0x02BAF000.



eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Problem with sprites/textures
« Reply #1 on: March 29, 2018, 02:24:51 am »
You're either linking debug libs in release mode or release libs in debug mode.

The modes need to match.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

KyleGBC

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Problem with sprites/textures
« Reply #2 on: March 29, 2018, 05:44:05 am »
The suggested solution worked, no runtime error, no weird characters, but there is still no sprite drawn, and there are still the debug messages seen in the original post.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Problem with sprites/textures
« Reply #3 on: March 29, 2018, 08:39:21 am »
Make sure to check that texture loading succeeds.

Also you might want to use setTexture(texture, true) to adjust the texture rect.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything