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

Author Topic: Problem to load a texture  (Read 1050 times)

0 Members and 1 Guest are viewing this topic.

LearningC++

  • Newbie
  • *
  • Posts: 2
    • View Profile
Problem to load a texture
« on: September 23, 2018, 10:57:08 am »
Hello guys im not able to load any image or texture to my game.

i always get this error:"Failed to load image ".jpg    Á楠 ". Reason: Unable to open file" (it`srare not full name only .jpg display error"

My code:

Quote
#include <SFML/Graphics.hpp>
#include "../include/head.h"
#include "../include/mainfuctions.h"



//
SystemT* main_system=nullptr;


//
int main()
{

    sf::RenderWindow window(sf::VideoMode(224, 256), "SpaceInvader");
    sf::Texture texture;
    texture.loadFromFile("logo.jpg");
    window.setFramerateLimit(60);
    main_system=SystemTInit();
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {

            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.display();
    }

    return 0;
}

SystemT * SystemTInit()
{
  SystemT *pointer=NULL;
  pointer=(SystemT*)calloc(1,sizeof(SystemT));
  return pointer;
}

my dir where im running the program and also where i have the logo.jpg file:
Quote
23/09/2018  10:51    <DIR>          .
23/09/2018  10:51    <DIR>          ..
22/09/2018  12:46               526 compilacion.old.bat
21/09/2018  02:15             5.273 logo.jpg
23/09/2018  10:51            39.936 main.exe
23/09/2018  10:51           397.148 main.ilk
23/09/2018  10:51           102.833 main.obj
23/09/2018  10:51         1.282.048 main.pdb
22/09/2018  00:13             1.869 monsterbat-full.bat
08/05/2018  22:40           630.784 openal32.dll
22/09/2018  06:46               810 README.md
08/05/2018  22:43         1.383.424 sfml-audio-d-2.dll
08/05/2018  22:43         1.434.112 sfml-graphics-d-2.dll
08/05/2018  22:43           338.944 sfml-network-d-2.dll
08/05/2018  22:42           188.416 sfml-system-d-2.dll
08/05/2018  22:43           339.968 sfml-window-d-2.dll
23/09/2018  10:51           757.760 vc140.pdb
              15 archivos      6.903.851 bytes
               2 dirs  128.710.004.736 bytes libres

im using 32 bits library, anyway here is my compile code:

Quote
cl /nologo /Zi /GR- /EHs /MD %2 -I %1\%base_route%\include %1\%base_route%\lib\sfml-window-d.lib  %1\%base_route%\lib\sfml-main.lib %1\%base_route%\lib\sfml-system-d.lib  %1\%base_route%\lib\sfml-graphics-d.lib opengl32.lib user32.lib gdi32.lib shell32.lib Ws2_32.lib

what im doing wrong?

Thanks for any help

« Last Edit: September 23, 2018, 11:09:11 am by LearningC++ »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10823
    • View Profile
    • development blog
    • Email
Re: Problem to load a texture
« Reply #1 on: September 23, 2018, 12:12:29 pm »
You link debug libraries in release mode.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

LearningC++

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Problem to load a texture
« Reply #2 on: September 23, 2018, 12:47:21 pm »
Finally i solve it.

Change /MD for /MDd or /MTd both work.
Quote
cl /nologo /Zi /O2 /GR- /EHs /MDd %2 -I %1\%base_route%\include %1\%base_route%\lib\sfml-window-d.lib  %1\%base_route%\lib\sfml-main-d.lib %1\%base_route%\lib\sfml-system-d.lib  %1\%base_route%\lib\sfml-graphics-d.lib opengl32.lib user32.lib gdi32.lib shell32.lib Ws2_32.lib

Thanks for ur reply

Regarts!

 

anything