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

Pages: [1]
1
Graphics / Re: Cant load texture from file.
« on: February 08, 2018, 07:59:10 pm »
You can't just change file extensions and expect things to miraculously work. Changing a file extension doesn't change the format. I wouldn't know what paint does, but maybe it realized it was a BMP before and saved it in the same format.

Not sure why or how that would happen, but if you get no error on the cli, then the either sf::err() or std::cerr has been redirected.

I did it so because I was too lazy to search pain in the start menu (I formatted this PC like 1 month ago so I had not shortcut)... as I said, I "Save as" method which should reformat the image...

now this becomes even more weird, because after I tried the SFML logo, which worked, now the original image giving me problems works fine... so I have no idea what happened, I changed absolutely nothing in the configuration, and now it works... 

so... magic.

2
Graphics / Re: Cant load texture from file.
« on: February 07, 2018, 08:04:43 am »
That file is a BMP file renamed to have a png extension. It also loads for me without a problem, which is interesting.
What I did to create it was, created a new bitmap image, then rename it to PNG, edit it in paint and save is as  PNG... so when I saved it to PNG I should have had no problems with the image, unless I missed something weird.

3
Graphics / Re: Cant load texture from file.
« on: February 06, 2018, 07:17:22 pm »
It'd help if you provided such an image that fails. You can PM it to me to let me check if you don't want it out in the public.

And yes, failure to load an image should result in a message to terminal, it's interesting it doesn't.

SFML interally uses STB image, you can see what it supports in the comments in the header itself: https://github.com/SFML/SFML/blob/master/extlibs/headers/stb_image/stb_image.h

Additionally in your commented out code you use "img\test.png" as a path but that should be "img\\test.png" or "img/test.png" since \ is an escape character so \t is a tab and \\ is a \.

Sent...

Yes I also was expecting  a error message, in fact if I had an error code that would had helped me searching for a solution to my problem online.

4
Graphics / Re: Cant load texture from file.
« on: February 06, 2018, 08:20:54 am »
If it doesn't successfully load when using an absolute path that is sure to be correct, the problem then must be with the image.
Have you tried a different image? If you need one to test, you could always use the SFML logo from here: https://www.sfml-dev.org/download/goodies/ :)
(not the SVG, of course)

Well that worked. I actually tried before with 3 other png I found online and had the same problem. Like I said before I made the png I was testing in the first post in paint which as 2 square one inside the other, so... what was I missing? is there some particular limitations to the type of image we can use? i mean something in terms of compression, or other saving parameters?


5
Graphics / Re: Cant load texture from file.
« on: February 05, 2018, 06:49:04 pm »
I see now that your project is actually inside that very directory so a working directory of $(ProjectDir) should indeed point to that directory.

I think the first thing to try should be using an absolute path to see if the image is really the problem.
Also you might try a different image and/or allow others to test your image.


I have tried using an absolute path and still nothing happens. Additionally, I have changed $(ProjectDir) accordingly.

6
Graphics / Re: Cant load texture from file.
« on: February 05, 2018, 08:33:41 am »
When Visual Studio uses local paths for programs run from within the IDE, it uses its Current Working Directory; this can be set separately to the actual location of the executable or the source code. However, its default location is usually the project's source code so placing the image in the same folder/directory as the cpp file should help.
If you run the executable directly - outside of the IDE - then it should use the executable's location as its CWD. This means that you may need to duplicate resources for different targets as well as IDE execution (if referenced by local paths).


One other thing to note is that it is often simpler to start with an empty project instead of a Console Application project. This removes the added stuff that you probably don't need (most notably the stdafx bit). Being used to Linux, I expect you'd probably appreciate this approach anyway :)

To the first point I assume that something like this should be the issue,  if u see in the image, the solution and the project files are in the same folder, and I have set the working directory to $(ProjectDir), is there anything else I should be changing for setting this correctly?.

I will try with an empty project later, thanks A lot.



7
Graphics / Cant load texture from file.
« on: February 04, 2018, 11:02:34 pm »
Hello, I have just started using SFML, and also Visual studio...

So I was following a guide to load a single texture and create an sprite from a file... Probably the most simple tutorial ever... but I am having problems nonetheless.

My code based in the tutorial just bellow, I am currently using the C++14 and x64 libraries:

Code: [Select]
#include "stdafx.h"
#include <iostream>
#include <SFML/Graphics.hpp>

int main()
{

sf::Event event;
//window creation
sf::RenderWindow MainWindow(sf::VideoMode(400, 300), "Window");


//texture creation
sf::Texture textureTest1;
system("dir");
//if (!textureTest1.loadFromFile("img\test.png")) {
if (!textureTest1.loadFromFile("test.png")) {
std::cout << "the texture does not load" << std::endl;
}
else {
std::cout << "the texture does load" << std::endl;
}

//Sprite creation
sf::Sprite sprtTest1(textureTest1);

while (MainWindow.isOpen()) {
while (MainWindow.pollEvent(event)) {
if (event.type == sf::Event::EventType::Closed)
MainWindow.close();
}

MainWindow.clear();
MainWindow.draw(sprtTest1);
MainWindow.display();
}

return 0;
}

For some reason loadFromFile() is unable to load the texture from the file, even when I am in the correct working directory. From what I have been able to read online the most likely issue seems to be that the picture cant be open for some reason, but if that was the case I should be getting an error message in the console, which I am not getting. I saw in another topic that u have to set the target subsystem to console in order to be able to see the messages, and I have done this (Image bellow) but it is still likely that I am missing something because I dont see any error message... in any case, "test.png" is a simple image I made in paint, which is a red square inside a green square.




For most of my life I have been using Linux, but now for work reasons I must use windows, so that also could be an issue.

Please let me know if u have any insights to my predicament, I would really appreciate the help.
Thank you.

Pages: [1]
anything