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.


Topics - ritave

Pages: [1]
1
Graphics / RenderImage doesn't work
« on: December 19, 2010, 05:29:17 pm »
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

Code: [Select]

#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:
Code: [Select]

Image.Draw(sf::Shape::Rectangle(0,0,25,25,sf::Color(255,0,0)));

errors profiler returned are:
Code: [Select]

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

2
Graphics / Arch Linux, SFML2, Drawing sprites through static class
« on: December 12, 2010, 02:48:54 pm »
When drawing sprites on window which is in static class, you get really weird artifacts. Here's the download to minimal example which has a png and somewhat minimal code.
http://www.mediafire.com/?5gk2434jg3w2oo4

I'm working on a MSI Wind u120 with Arch Linux, and myself compiled and updated sfml2, no changes made to the source. The distro is up to date

If you want to have a quick glance at code:
Code: [Select]
#include <SFML/Graphics.hpp>

class CWindow
{
private:
static sf::RenderWindow Window;
public:
static void Init(unsigned int Width, unsigned int Height, int Style=sf::Style::Default)
{
Window.Create(sf::VideoMode(Width,Height), "", Style);
}
static bool IsOpened()
{
return Window.IsOpened();
}
static void Clear(sf::Color Color=sf::Color(0,0,0))
{
Window.Clear(Color);
}
static void Draw(const sf::Drawable &Drawable)
{
Window.Draw(Drawable);
}
static void Display()
{
Window.Display();
sf::Sleep(0);
}
static bool GetEvent(sf::Event& Event)
{
return Window.GetEvent(Event);
}
static void Close()
{
Window.Close();
}
};

sf::RenderWindow CWindow::Window;

int main()
{
sf::Image CornerImage;
CornerImage.LoadFromFile("Corner.png");
sf::Sprite Corner;
Corner.SetImage(CornerImage);

CWindow::Init(100,100);

while (CWindow::IsOpened())
{
sf::Event Event;
while (CWindow::GetEvent(Event))
{
if (Event.Type==sf::Event::Closed)
CWindow::Close();
}

CWindow::Clear(sf::Color(255,255,0));
CWindow::Draw(Corner);
CWindow::Display();
}
}

3
General / Linux segmentation fault on app start
« on: January 24, 2010, 10:28:05 pm »
I've compiled sfml and samples smoothly on ubuntu 9/fedora 12 on MSI Wind u120, but when I try to run any app containing something from sfml it quits and "Segmentation Fault (Core Dumped)" gets written on stdout. Is it something with sfml, or my bad on linux side, since I'm new to compiling on linux?

4
Graphics / SFML Accessing null pointer
« on: January 14, 2010, 04:48:10 pm »
Since yesterday's revisions, it's not possible to do graphical applications, it's probably somewhere in RenderWindow initialization. When debugging the MVS says it's something accessing pointer 0x00000000. Narrowing the problem, my server application (only system and network parts of SFML) still works fine on the same libs. And MVS log points to sfml-graphics.dll
Code: [Select]

Some more library loading
'Client.exe': Loaded 'C:\WINDOWS\system32\mcd32.dll'
'Client.exe': Unloaded 'C:\WINDOWS\system32\mcd32.dll'
First-chance exception at 0x0046c246 (sfml-graphics.dll) in Client.exe: 0xC0000005: Access violation writing location 0x00130008.
First-chance exception at 0x00000000 in Client.exe: 0xC0000005: Access violation reading location 0x00000000.
The last one repeating a lot.


Now why in intialization of window? Since I've made a breakpoint in init function of my app, and it never got reached, neither in debug noir release version, also I don't have any other classes used anywhere from sfml-graphics.dll

Also can't be fault on my part - it worked with older libs, and I have no pointers anywhere in my code.

5
Network / Packets and vector?
« on: December 30, 2009, 02:10:09 pm »
So I wanted to make packets able to receive and send vectors, but I've encountered some problems with templates.
The problem is, how to make overloading vectors without knowing vectors template, I'm using something like this
Code: [Select]

template<class T>
sf::Packet& operator <<(sf::Packet& Packet, const std::vector<T>& A)
{
Packet << A.size();
for (int i=0;i<A.size();i++)
{
Packet << A[i];
}
return Packet;
}

template<class T>
sf::Packet& operator >>(sf::Packet& Packet, std::vector<T>& A)
{
unsigned int size;
Packet >> size;
A.reserve(size);
for (int i=0;i<size;i++)
{
T temp;
Packet >> temp;
A.push_back(temp);
}
return Packet;
}


and calling it

Code: [Select]

sf::Packet& operator <<(sf::Packet& Packet, const Welcome_Accept& A)
{
return Packet << A.UserId << A.UserList;
}
sf::Packet& operator >>(sf::Packet& Packet, Welcome_Accept& A)
{
return Packet >> A.UserId >> A.UserList;
}


But that doesn't quite work, the error says that no such overloaded operator found

Ps. Forgot, UserList is std::vector<New_User>
and yes, New_User has overloaded operators

Pages: [1]
anything