Hello again, I come here with another problem - the renderimage doesn't seem to draw anything.
In this minimal example we're supposed to see black window, with green rectangle (renderimage clear) with a red rectangle in it (renderimage draw).
But all I see is black screen...
Spec:
Linux with Arch Distribution
Msi wind u120 - intel integrated graphics
Sfml2
Drivers updated daily
RenderImage::IsAvailable() returns 1
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow Window(sf::VideoMode(100,100), "");
sf::RenderImage Image;
Image.Create(50,50);
while (true)
{
sf::Event Event;
while (Window.GetEvent(Event)) {}
Image.Clear(sf::Color(0,255,0));
Image.Draw(sf::Shape::Rectangle(0,0,25,25,sf::Color(255,0,0)));
Image.Display();
Window.Clear();
sf::Sprite Temp;
Temp.SetImage(Image.GetImage());
Window.Draw(Temp);
Window.Display();
}
}
Probably important edit:
I played a bit with valgrind (profiler, memory check etc.)
And it found that there are a few uninitialized variables used at this line:
Image.Draw(sf::Shape::Rectangle(0,0,25,25,sf::Color(255,0,0)));
errors profiler returned are:
==12276== Conditional jump or move depends on uninitialised value(s)
==12276== at 0x4071948: sf::Renderer::SetShader(sf::Shader const*) (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x40729B4: sf::RenderTarget::Draw(sf::Drawable const&) (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x8049476: main (Temp.cpp:15)
==12276==
==12276== Conditional jump or move depends on uninitialised value(s)
==12276== at 0x4071786: sf::Renderer::SetBlendMode(sf::Blend::Mode) (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x4057AD1: sf::Drawable::Draw(sf::RenderTarget&, sf::Renderer&) const (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x40729C7: sf::RenderTarget::Draw(sf::Drawable const&) (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x8049476: main (Temp.cpp:15)
==12276==
==12276== Conditional jump or move depends on uninitialised value(s)
==12276== at 0x4071898: sf::Renderer::SetTexture(sf::Image const*) (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x4075994: sf::Shape::Render(sf::RenderTarget&, sf::Renderer&) const (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x4057AE4: sf::Drawable::Draw(sf::RenderTarget&, sf::Renderer&) const (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x40729C7: sf::RenderTarget::Draw(sf::Drawable const&) (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x8049476: main (Temp.cpp:15)
==12276==
==12276== Conditional jump or move depends on uninitialised value(s)
==12276== at 0x40718D2: sf::Renderer::SetTexture(sf::Image const*) (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x4075994: sf::Shape::Render(sf::RenderTarget&, sf::Renderer&) const (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x4057AE4: sf::Drawable::Draw(sf::RenderTarget&, sf::Renderer&) const (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x40729C7: sf::RenderTarget::Draw(sf::Drawable const&) (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x8049476: main (Temp.cpp:15)
==12276==
==12276== Conditional jump or move depends on uninitialised value(s)
==12276== at 0x4071948: sf::Renderer::SetShader(sf::Shader const*) (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x40729B4: sf::RenderTarget::Draw(sf::Drawable const&) (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x804952A: main (Temp.cpp:21)
==12276==
==12276== Conditional jump or move depends on uninitialised value(s)
==12276== at 0x4071786: sf::Renderer::SetBlendMode(sf::Blend::Mode) (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x4057AD1: sf::Drawable::Draw(sf::RenderTarget&, sf::Renderer&) const (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x40729C7: sf::RenderTarget::Draw(sf::Drawable const&) (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x804952A: main (Temp.cpp:21)
==12276==
==12276== Conditional jump or move depends on uninitialised value(s)
==12276== at 0x4071898: sf::Renderer::SetTexture(sf::Image const*) (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x40768C7: sf::Sprite::Render(sf::RenderTarget&, sf::Renderer&) const (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x4057AE4: sf::Drawable::Draw(sf::RenderTarget&, sf::Renderer&) const (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x40729C7: sf::RenderTarget::Draw(sf::Drawable const&) (in /usr/lib/libsfml-graphics.so.2.0.0)
==12276== by 0x804952A: main (Temp.cpp:21)
==12276== is a process number, so you shouldn't worry about that.
As you can probably see the rest are callstacks.
I hope it helps you somehow