29 #define _unused(x) ((void)(x))    31 #include "SUAPI-CppWrapper/model/Texture.hpp"    36 #include "SUAPI-CppWrapper/model/ImageRep.hpp"    37 #include "SUAPI-CppWrapper/String.hpp"    44 SUTextureRef Texture::create_texture(ImageRep& image_rep) {
    45   SUImageRepRef image = image_rep.ref();
    46   SUTextureRef texture = SU_INVALID;
    47   SUResult res = SUTextureCreateFromImageRep(&texture, image);
    48   assert(res == SU_ERROR_NONE); _unused(res);
    52 SUTextureRef Texture::create_texture(
const std::string file_path, 
double s_scale, 
double t_scale) {
    53   SUTextureRef texture = SU_INVALID;
    54   SUResult res = SUTextureCreateFromFile(&texture, file_path.c_str(), 
s_scale,
t_scale);
    55   if (res != SU_ERROR_NONE) {
    62 SUTextureRef Texture::copy_reference(
const Texture& other) {
    75   Entity(SUTextureToEntity(texture), attached)
    80   Entity(other, SUTextureToEntity(copy_reference(other)))
    85   Texture(create_texture(file_path, s_scale, t_scale), false)
    90   Texture(create_texture(image), false)
   100   m_entity = SUTextureToEntity(other.ref());
   106 SUTextureRef Texture::ref()
 const {
   107   return SUTextureFromEntity(
m_entity);
   111 Texture::operator SUTextureRef()
 const {
   118   std::string file_path = 
"/tmp/tmptexture";
   119   SUResult res = this->
save(file_path);
   120   assert(res == SU_ERROR_NONE); _unused(res);
   123   const char *file_path_c = file_path.c_str();
   124   int ret = std::remove(file_path_c);
   125   assert(ret == 0); _unused(ret);
   141     throw std::logic_error(
"CW::Texture::alpha_used(): Texture is null");
   143   bool alpha_channel_used;
   144   SUResult res = SUTextureGetUseAlphaChannel(this->ref(), &alpha_channel_used);
   145   assert(res == SU_ERROR_NONE); _unused(res);
   146   return alpha_channel_used;
   152     throw std::logic_error(
"CW::Texture::alpha_used(): Texture is null");
   154   SUImageRepRef image_rep = SU_INVALID;
   155   SUResult res = SUImageRepCreate(&image_rep);
   156   assert(res == SU_ERROR_NONE);
   157   res = SUTextureGetImageRep(this->ref(), &image_rep);
   158   assert(res == SU_ERROR_NONE); _unused(res);
   165   SUStringRef file_ref = name.ref();
   166   SUResult res = SUTextureGetFileName(this->ref(), &file_ref);
   167   assert(res == SU_ERROR_NONE); _unused(res);
   173   const char* chars = 
string.std_string().c_str();
   174   SUResult res = SUTextureSetFileName(this->ref(), chars);
   175   assert(res == SU_ERROR_NONE); _unused(res);
   181     throw std::logic_error(
"CW::Texture::width(): Texture is null");
   187   SUResult res = SUTextureGetDimensions(this->ref(), &width, &height, &s_scale, &t_scale);
   188   assert(res == SU_ERROR_NONE); _unused(res);
   195     throw std::logic_error(
"CW::Texture::height(): Texture is null");
   201   SUResult res = SUTextureGetDimensions(this->ref(), &width, &height, &s_scale, &t_scale);
   202   assert(res == SU_ERROR_NONE); _unused(res);
   209     throw std::logic_error(
"CW::Texture::s_scale(): Texture is null");
   215   SUResult res = SUTextureGetDimensions(this->ref(), &width, &height, &s_scale, &t_scale);
   216   assert(res == SU_ERROR_NONE); _unused(res);
   223     throw std::logic_error(
"CW::Texture::t_scale(): Texture is null");
   229   SUResult res = SUTextureGetDimensions(this->ref(), &width, &height, &s_scale, &t_scale);
   230   assert(res == SU_ERROR_NONE); _unused(res);
   236   const char *cstr = file_path.c_str();
   237   SUResult res = SUTextureWriteToFile(this->ref(), cstr);
 
bool attached() const 
Returns true if the entity is attached to another object. 
SUEntityRef m_entity
The C SUEntityRef that this class wraps. 
ImageRep image_rep() const 
Texture & operator=(const Texture &other)
SUResult save(const std::string &file_path) const 
Entity & operator=(const Entity &other)
Copy assignment operator.