[no bug]Attributes (String to Color)

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Steel Style
Posts: 168
Joined: Sun Feb 04, 2007 3:30 pm
Location: France

[no bug]Attributes (String to Color)

Post by Steel Style »

So seem that we have a problem converting String attribute to value Attributes.
Look at this, (did with the latest svn revision).
SColor test (255,255,125,25);
attrib->addColor("Color",test);

stringc strColor = attrib->getAttributeAsString("Color");

cout << strColor.c_str() << endl;
// For the we will add the String Color value that we just get
attrib->addString("ColorString",strColor.c_str());

SColor color = attrib->getAttributeAsColor("Color");
SColor color2 = attrib->getAttributeAsColor("ColorString");

// The two next line don't return the same thing
// The first one print "255, 125, 125"
// The 2nd one print "255, 255, 255"
// But that the same thing

cout << "Red: " << color.getRed();
cout << "; Green: " << color.getGreen();
cout << "; Blue: " << color.getBlue() << endl;

cout << "Red: " << color2.getRed();
cout << "; Green: " << color2.getGreen();
cout << "; Blue: " << color2.getBlue() << endl;
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

bug added, will investigate later.

Code: Select all

	IrrlichtDevice *device =
		createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16,
			false, false, false, 0);

	if (!device)
		return 1;


	io::IAttributes* attrib = device->getFileSystem()->createEmptyAttributes();

SColor test (255,255,125,25);
attrib->addColor("Color",test);

stringc strColor = attrib->getAttributeAsString("Color");

cout << strColor.c_str() << endl;
// For the we will add the String Color value that we just get
attrib->addString("ColorString",strColor.c_str());

SColor color = attrib->getAttributeAsColor("Color");
SColor color2 = attrib->getAttributeAsColor("ColorString");

// The two next line don't return the same thing
// The first one print "255, 125, 125"
// The 2nd one print "255, 255, 255"
// But that the same thing

cout << "Red: " << color.getRed();
cout << "; Green: " << color.getGreen();
cout << "; Blue: " << color.getBlue() << endl;

cout << "Red: " << color2.getRed();
cout << "; Green: " << color2.getGreen();
cout << "; Blue: " << color2.getBlue() << endl;

	device->drop();
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

This is not a bug. You can only get attributes for the same type which you did set. You cannot use the attribute system for conversions.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

However, the color conversion scheme is completely weird. Some values use hex values (with or without 0x prefix), some use color elements, some use strings, ... I don't think that all of these conversions used internally are really are coherent.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Don't know, in the tests I added yesterday SColor and SColorf both worked. And the problem described above will not work, but that is correct as attributes just don't do that. But I've only tested the IAttributes serialization so far which maybe doesn't use string-conversions (not sure). I will add xml-serialization using IAttributes to the tests the next days, that will enforce that also the string-conversions are tested.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply