mirror of
https://github.com/NoelFB/blah.git
synced 2025-04-11 01:26:05 +08:00
added Texture::get/set data for Color*
This commit is contained in:
parent
1caa31032b
commit
d559f1c8ee
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <blah/common.h>
|
#include <blah/common.h>
|
||||||
#include <blah/filesystem.h>
|
#include <blah/filesystem.h>
|
||||||
|
#include <blah/math/color.h>
|
||||||
|
|
||||||
namespace Blah
|
namespace Blah
|
||||||
{
|
{
|
||||||
@ -74,12 +75,20 @@ namespace Blah
|
|||||||
|
|
||||||
// Sets the data of the Texture.
|
// Sets the data of the Texture.
|
||||||
// Note that the data should be the same format and size as the Texture. There is no row padding.
|
// Note that the data should be the same format and size as the Texture. There is no row padding.
|
||||||
virtual void set_data(unsigned char* data) = 0;
|
virtual void set_data(const u8* data) = 0;
|
||||||
|
|
||||||
|
// Sets the data of the Texture to the provided Color buffer.
|
||||||
|
// If the Texture Format is not RGBA, this won't do anything.
|
||||||
|
void set_data(const Color* data);
|
||||||
|
|
||||||
// Gets the data of the Texture.
|
// Gets the data of the Texture.
|
||||||
// Note that the data will be written to in the same format as the Texture,
|
// Note that the data will be written to in the same format as the Texture,
|
||||||
// and you should allocate enough space for the full texture. There is no row padding.
|
// and you should allocate enough space for the full texture. There is no row padding.
|
||||||
virtual void get_data(unsigned char* data) = 0;
|
virtual void get_data(u8* data) = 0;
|
||||||
|
|
||||||
|
// Gets the data of the Texture.
|
||||||
|
// If the Texture Format is not RGBA, this won't do anything.
|
||||||
|
void get_data(Color* data);
|
||||||
|
|
||||||
// Returns true if the Texture is part of a FrameBuffer
|
// Returns true if the Texture is part of a FrameBuffer
|
||||||
virtual bool is_framebuffer() const = 0;
|
virtual bool is_framebuffer() const = 0;
|
||||||
|
@ -39,3 +39,15 @@ TextureRef Texture::create(const FilePath& file)
|
|||||||
{
|
{
|
||||||
return create(Image(file));
|
return create(Image(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Texture::set_data(const Color* data)
|
||||||
|
{
|
||||||
|
if (format() == TextureFormat::RGBA)
|
||||||
|
set_data((u8*)data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Texture::get_data(Color* data)
|
||||||
|
{
|
||||||
|
if (format() == TextureFormat::RGBA)
|
||||||
|
get_data((u8*)data);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user