MCPcopy Create free account
hub / github.com/MyGUI/mygui / updateTexture

Method updateTexture

Demos/Demo_Colour/ColourPanel.cpp:83–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81 }
82
83 void ColourPanel::updateTexture(const MyGUI::Colour& _colour)
84 {
85 size_t size = 32;
86
87 MyGUI::uint8* pDest = static_cast<MyGUI::uint8*>(mTexture->lock(MyGUI::TextureUsage::Write));
88
89 for (size_t j = 0; j < size; j++)
90 for (size_t i = 0; i < size; i++)
91 {
92 float x = (float)i / size;
93 float y = (float)j / size;
94 *pDest++ = MyGUI::uint8((1.0f - y) * (_colour.blue * x + (1.0f - x)) * 255); // B
95 *pDest++ = MyGUI::uint8((1.0f - y) * (_colour.green * x + (1.0f - x)) * 255); // G
96 *pDest++ = MyGUI::uint8((1.0f - y) * (_colour.red * x + (1.0f - x)) * 255); // R
97 *pDest++ = 255; // A
98 }
99
100 // Unlock the pixel buffer
101 mTexture->unlock();
102 }
103
104 void ColourPanel::notifyMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
105 {

Callers

nothing calls this directly

Calls 2

lockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected