mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 17:06:43 +00:00
Remove manual allocation for images
This commit is contained in:
parent
8817f44d63
commit
1b78acc2c0
2 changed files with 11 additions and 9 deletions
|
@ -277,9 +277,10 @@ namespace Gui
|
||||||
|
|
||||||
osg::ref_ptr<osg::Image> image = new osg::Image;
|
osg::ref_ptr<osg::Image> image = new osg::Image;
|
||||||
|
|
||||||
unsigned char* bytes = (unsigned char*)calloc(width*height*4, sizeof(unsigned char));
|
image->allocateImage(width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE);
|
||||||
memcpy(bytes, &textureData[0], textureData.size());
|
assert (image->isDataContiguous());
|
||||||
image->setImage(width, height, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, bytes, osg::Image::USE_MALLOC_FREE);
|
|
||||||
|
memcpy(image->data(), &textureData[0], textureData.size());
|
||||||
|
|
||||||
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
|
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
|
||||||
texture->setImage(image);
|
texture->setImage(image);
|
||||||
|
|
|
@ -13,15 +13,16 @@ namespace
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Image> warningImage = new osg::Image;
|
osg::ref_ptr<osg::Image> warningImage = new osg::Image;
|
||||||
|
|
||||||
int width=8, height=8;
|
int width = 8, height = 8;
|
||||||
unsigned char* bytes = (unsigned char*)calloc(width*height*3, sizeof(unsigned char));
|
warningImage->allocateImage(width, height, 1, GL_RGB, GL_UNSIGNED_BYTE);
|
||||||
|
assert (warningImage->isDataContiguous());
|
||||||
|
unsigned char* data = warningImage->data();
|
||||||
for (int i=0;i<width*height;++i)
|
for (int i=0;i<width*height;++i)
|
||||||
{
|
{
|
||||||
bytes[3*i] = (255);
|
data[3*i] = (255);
|
||||||
bytes[3*i+1] = (0);
|
data[3*i+1] = (0);
|
||||||
bytes[3*i+2] = (255);
|
data[3*i+2] = (255);
|
||||||
}
|
}
|
||||||
warningImage->setImage(width, height, 1, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, bytes, osg::Image::USE_MALLOC_FREE);
|
|
||||||
|
|
||||||
osg::ref_ptr<osg::Texture2D> warningTexture = new osg::Texture2D;
|
osg::ref_ptr<osg::Texture2D> warningTexture = new osg::Texture2D;
|
||||||
warningTexture->setImage(warningImage);
|
warningTexture->setImage(warningImage);
|
||||||
|
|
Loading…
Reference in a new issue