SFML community forums

Help => Graphics => Topic started by: JollyGent on January 13, 2015, 11:41:40 pm

Title: Basic rendering crashing
Post by: JollyGent on January 13, 2015, 11:41:40 pm
(http://s4.postimg.org/dg6xib2nt/rendering.jpg) (http://postimg.org/image/dg6xib2nt/)

I have followed all the tutorial and I have linked to every dependant files like the tutorial asked me to just like opengl32 and etc, and the creating the window works, but when I try to render a basic shape similar to the one in the tutorial my window crashes with no error, and this seems strange because nobody else seems to be having the same problem or if they do, they don't have the same complaints on debugging mode(shown above).
What could be the problem? I thoroughly apologise if this is a stupid question

Oh, also, my first post :D nice to meet you all
Title: AW: Basic rendering crashing
Post by: eXpl0it3r on January 14, 2015, 04:12:25 am
Do you older headers lying around? If you upgarded to SFML 2.2 make sure to fully replace your headers, libraries and DLLs.

Also provide the full build command: http://www.sfml-dev.org/faq.php#tr-grl-verbose-ide
Title: Re: Basic rendering crashing
Post by: JollyGent on January 14, 2015, 11:08:17 pm
Checking for existence: C:\Users\family\Desktop\C++ programming studies\January 2015\Hello World!\bin\Debug\Hello World!.exe
Executing: "C:\Program Files (x86)\CodeBlocks/cb_console_runner.exe" "C:\Users\family\Desktop\C++ programming studies\January 2015\Hello World!\bin\Debug\Hello World!.exe"  (in C:\Users\family\Desktop\C++ programming studies\January 2015\Hello World!\.)

I just got this hard drive from my friend because my old hard drive broke. It seems that the program builds perfectly fine and runs fine, but it keeps crashing. If I remove code and just try to create a window, the window opens up fine. It's just when I try to render the graphics.
Title: Re: Basic rendering crashing
Post by: eXpl0it3r on January 14, 2015, 11:14:51 pm
Is your graphics driver uptodate?
Title: Re: Basic rendering crashing
Post by: Jesper Juhl on January 14, 2015, 11:25:40 pm
Could you provide a simple self-contained minimal example program that causes the crash (just a main() function with the minimum required to cause the problem)?
That would make it easier for others to check it for correctness/bugs and test on their own machine.
Title: Re: Basic rendering crashing
Post by: JollyGent on January 14, 2015, 11:55:22 pm

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

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

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

    return 0;
}


 

That's literally all I need to do. To render. The example code in the tutorial alone is enough to cause problem. The graphic driver I updated, re-downloaded, tried everything. I guess this just doesn't work for me haha  :P
Title: Re: Basic rendering crashing
Post by: Jesper Juhl on January 15, 2015, 12:02:59 am
I just tried the exact code you posted on my system (CentOS 7 with clang 3.5 and GCC 4.8.2) and it works just fine - no crashes.

Could you run that simple program in a debugger and provide us with a backtrace from when it crashes?
Title: Re: Basic rendering crashing
Post by: JollyGent on January 15, 2015, 12:12:34 am
If you look at the image in the OP that is all I'm getting in the debugger

D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderTarget.cpp: No such file or directory.
#1  0x00404c18 in sf::RenderTarget::applyBlendMode (this=0x28fce8, mode=...) at D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderTarget.cpp:445

Apparently RenderTarget doesn't exist?!
Title: Re: Basic rendering crashing
Post by: JollyGent on January 17, 2015, 03:17:39 pm
(http://s17.postimg.org/cmo1a2ma3/linking.jpg) (http://postimg.org/image/cmo1a2ma3/)

this is how I linked it. Perhaps this is what's causing the problem?

As soon as I add

window.draw(shape);

it crashes. I know where the problem is coming from, I just have no idea how to fix it
Title: AW: Basic rendering crashing
Post by: eXpl0it3r on January 17, 2015, 03:58:29 pm
The BlendMode API changed with SFML 2.2, so if you use the SFML 2.2 headers and import libraries but when you run it use the old SFML 2.1 DLLs it won't find the new BlendMode bits.

Have you made certain that the headers, the import libraries AND the used DLLs are using SFML 2.2? Also did you remove ALL the old SFML 2.1 files? ;)
Title: Re: Basic rendering crashing
Post by: JollyGent on January 17, 2015, 04:15:10 pm
I didn't have any 2.1 files in first place so I don't think I can have 2.1 DLLS I kept deleting and re-downloading over and over again D:
Title: Re: Basic rendering crashing
Post by: eXpl0it3r on January 17, 2015, 06:56:28 pm
Well then lets start from the beginning:


If you got codeblocks-13.12mingw-setup.exe, then you need GCC 4.7.1 TDM (SJLJ) - 32-bit (http://www.sfml-dev.org/files/SFML-2.2-windows-gcc-4.7.1-tdm-32-bit.zip) package.
If you got codeblocks-13.12mingw-setup-TDM-GCC-481.exe, then you need GCC 4.8.1 TDM (SJLJ) - 32-bit (http://www.sfml-dev.org/files/SFML-2.2-windows-gcc-4.8.1-tdm-32-bit.zip)
If you got i686-4.9.2-release-posix-dwarf-rt_v3-rev0 (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-posix/dwarf/i686-4.9.2-release-posix-dwarf-rt_v3-rev0.7z/download), then you need GCC 4.9.2 MinGW (DW2) - 32-bit (http://www.sfml-dev.org/files/SFML-2.2-windows-gcc-4.9.2-mingw-32-bit.zip) package.

If you got another compiler, then you most likely have to build from source.
Title: Re: Basic rendering crashing
Post by: JollyGent on January 18, 2015, 01:20:14 am
I have checked and I am sure that I am using the correct versions and compilers.

Since the window.draw(shape) is what's causing the problem, I wondered if it's the driver that is causing the problem, so I tried to open a random steam game and here was the result:

(http://s10.postimg.org/f63jgcjr9/graphic_card_not_found.jpg) (http://postimg.org/image/f63jgcjr9/)

I have checked the device manager and:

(http://s21.postimg.org/k82g522nn/graphic_card_disabled.jpg) (http://postimg.org/image/k82g522nn/)

Apparently I need to disable a graphics driver in order for my actual driver to work, however as you can see from the device manager I only have one graphics driver(Intel graphics HD) available. Maybe it's due to the fact that this hard drive is not mine but my friend's, so I deleted his AMD catalyst graphics driver, but that doesn't seem to cut it.

It seems like it's the driver. In which case, I don't think there is a resolve to. :(
Title: Re: Basic rendering crashing
Post by: Ivan on January 18, 2015, 07:00:16 pm
Hi, sorry for not open a new thread, I don't see the need because I think I have the same problem with SFML 2.2 in my Desktop PC.

Normally I work on my laptop and SFML 2.2 works perfect. Yesterday I tried to run my project in my Desktop PC and doesn't work.
If I compile with SFML 2.1 runs OK, but if I try to SFML 2.2, compiles fine but crash on run.

Desktop info:

Windows XP Home Edition SP3
CPU Intel Pentium 4 2.53 GHz
RAM 1.5 GB
ATI radeon 9000 Pro graphics card (driver update at least version, I think)

I use: Codeblocks 13.12 (codeblocks-13.12mingw-setup.exe) with GCC 4.7.1 TDM (SJLJ) 32-bit
         SFML 2.2 version GCC 4.7.1 TDM (SJLJ) 32-bit (SFML-2.2-windows-gcc-4.7.1-tdm-32-bit)

For example if I try with this simple code:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

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

        window.clear(sf::Color::Red);
        window.draw(shape);
        window.display();
    }

    return EXIT_SUCCESS;
}


Compiles fine but doesn't run. If I comment the drawing call ( window.draw(shape)), works perfect and show a red window. So the problem it's on rendering.

I debugged a simple code and crashes on render function. I get this error messages:

Quote
Error while reading shared library symbols for C:\Archivos de programa\CodeBlocks\MinGW\bin\libstdc++-6.dll
Process terminated with status -1073741510
Process terminated with status -1073741819

Screenshot with error message and output verbose build information:

(http://i.imgur.com/r2zNh1xl.png?1) (http://imgur.com/r2zNh1x)

(http://i.imgur.com/Za1hGwul.png?1) (http://imgur.com/Za1hGwu)

Any idea what I'm doing wrong? Thanks!

Title: AW: Re: Basic rendering crashing
Post by: eXpl0it3r on January 18, 2015, 07:27:44 pm
ATI radeon 9000 Pro graphics card (driver update at least version, I think)
Don't think, make sure! ;)

You've added -static-libstdc++ to thd compiler flags. This a) does not work with the TDM compiler and b) SFML's CMake script explicitly disallows using static runtime libs with dynamic SFML and thus you shouldn't try to mix things.
However since the default behavior of TDM compilers is to link the runtime libs statically, you'll have to add -shared-libstdc++ and -shared-libgcc (or similar).

Additionally the window module depends on gdi32 and winmm, as such they need to be a least on after the window module, better yet put them after all the SFML libs.
Title: Re: Basic rendering crashing
Post by: Ivan on January 18, 2015, 08:39:52 pm
Thanks eXpl0it3r. Yes I'm sure  ;)

I tried that you say but doesn't work. Anyway i don't understand why the same project and configuration works on my laptop and not in desktop. Specially when with SFML 2.1 all works fine.

(http://i.imgur.com/k5Juvqhl.png?1) (http://imgur.com/k5Juvqh)

Additionally the window module depends on gdi32 and winmm, as such they need to be a least on after the window module, better yet put them after all the SFML libs.

You mean this way:

(http://i.imgur.com/hEgvSLml.png?1) (http://imgur.com/hEgvSLm)

The problem still here  >:(

Thanks for your answers.
Title: Re: Basic rendering crashing
Post by: Nybble on February 11, 2015, 02:12:38 am
Same here... My project works fine in 2.1 but made the switch and when I try to render anything it crashes... everything works fine except when I try to render...

I tried out your example Ivan and it does crash me, I'm guessing it's the graphics card... I do know I have an old graphics card:

radeon hd 4350:

Graphics Engine: Radeon HD 4350
Video Memory: 512MB memory
Memory Interface: 64-bit
DirectX® Support: 10.1
CrossFireX Support: Yes, (software mode)
Bus Standard: PCI Express x1 (works in x4, x8 and x16 PCIe slots)
Core Speed: 600MHz
Memory Speed: 400MHz x2 (800MHz effective)
Ports: 2 x DVI-I, 2 x VGA (with adapter), 1 TV Out
Output Ports: DMS59, TV Out
Number of Monitors Supported: Two DVI
Form Factor: Small Form Factor (SFF) Single Slot
Dimensions: 2.4" H x 6.7" D
Warranty: 3 year limited warranty8
Title: Re: Basic rendering crashing
Post by: Ivan on February 20, 2015, 10:14:43 pm
Nobody knows how to fix it? Only crash with the SFML 2.2, 2.1 works fine.  :-[ 
Title: Re: Basic rendering crashing
Post by: binary1248 on February 22, 2015, 01:40:21 am
Download the gl_dev_new branch archive (https://github.com/SFML/SFML/archive/feature/gl_dev_new.zip), build it and test whether it still crashes when you use it instead of the official 2.2 release.
Title: Re: Basic rendering crashing
Post by: miki151 on April 16, 2015, 02:32:16 pm
It seems I'm getting similar crashes. They come in crash reports from users, so I can't reproduce it or check with other SFML versions than 2.2.

Here's the stacktrace. It also looks very similar to this one: https://github.com/SFML/SFML/issues/618

Quote
#0  0x00000000 in ?? ()
#1  0x66998d6e in sf::RenderTarget::applyBlendMode(sf::BlendMode const&) () from C:\Program Files (x86)\Steam\steamapps\common\KeeperRL\sfml-graphics-2.dll
#2  0x66998f0d in sf::RenderTarget::resetGLStates() () from C:\Program Files (x86)\Steam\steamapps\common\KeeperRL\sfml-graphics-2.dll
#3  0x66999297 in sf::RenderTarget::draw(sf::Vertex const*, unsigned int, sf::PrimitiveType, sf::RenderStates const&) () from C:\Program Files (x86)\Steam\steamapps\common\KeeperRL\sfml-graphics-2.dll
#4  0x669a2a68 in sf::VertexArray::draw(sf::RenderTarget&, sf::RenderStates) const () from C:\Program Files (x86)\Steam\steamapps\common\KeeperRL\sfml-graphics-2.dll
#5  0x669989bd in sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&) () from C:\Program Files (x86)\Steam\steamapps\common\KeeperRL\sfml-graphics-2.dll
#6  0x6699f8a6 in sf::Shape::draw(sf::RenderTarget&, sf::RenderStates) const () from C:\Program Files (x86)\Steam\steamapps\common\KeeperRL\sfml-graphics-2.dll
#7  0x669989bd in sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&) () from

Here's the code that crashes:
  RectangleShape r(Vector2f(t.getW(), t.getH()));
  r.setPosition(t.getPX(), t.getPY());
  r.setFillColor(color);
  if (outline) {
    r.setOutlineThickness(-2);
    r.setOutlineColor(*outline);
  }
  addRenderElem([this, r] { display->draw(r); });
 
Title: Re: Basic rendering crashing
Post by: eXpl0it3r on April 16, 2015, 02:34:41 pm
It's most likely fixed in the master branch. Rebuild SFML and relink your application.
Title: Re: Basic rendering crashing
Post by: binary1248 on April 16, 2015, 02:51:32 pm
I've told you in the other thread (http://en.sfml-dev.org/forums/index.php?topic=17905.0) already, the user is probably running the game on a graphics processor for which there is no acceleration.

To tell for sure whether that is really the case, after you create your sf::Window or sf::RenderWindow, use window.getSettings() to get the settings of the created context and check the OpenGL version, like this:
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
sf::ContextSettings settings = window.getSettings();
std::cout << "Major: " << settings.majorVersion << " Minor: " << settings.minorVersion << std::endl;
In addition to that you can check the vendor and renderer strings that OpenGL returns:
#include <SFML/OpenGL.hpp>

std::string vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
std::string renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
std::cout << "Vendor: " << vendor << " Renderer: " << renderer << std::endl;
This was also what I said just a few days ago here (http://en.sfml-dev.org/forums/index.php?topic=17914.msg128829#msg128829), and mentioned a few weeks ago here (http://en.sfml-dev.org/forums/index.php?topic=17793.0).

Provide us with that information, and we'll tell you whether it is a problem with SFML, or your users' systems.
Title: Re: Basic rendering crashing
Post by: miki151 on April 16, 2015, 05:10:08 pm
It's most likely fixed in the master branch. Rebuild SFML and relink your application.

How stable is the master branch? This goes out to thousands of users, so I don't want to gamble with old vs new bugs.

Provide us with that information, and we'll tell you whether it is a problem with SFML, or your users' systems.

I will, thanks.
Title: Re: Basic rendering crashing
Post by: Jesper Juhl on April 20, 2015, 07:09:44 pm
I usually update my development systems with a fresh rebuild of master a few times a week and I've yet to discover any major breakage for my own projects - seems quite stable for me.