class CTextureBuffer {
public:
int m_width;
int m_height;
void* m_data;
CTextureBuffer (int width = 0, int height = 0, void * data = nullptr)
: m_width (width), m_height (height), m_data (data) {}
CTextureBuffer (CTextureBuffer& other)
: m_width (other.m_width), m_height (other.m_height), m_data (other.m_data) {}
CTextureBuffer operator= (CTextureBuffer other) {
m_width = other.m_width;
m_height = other.m_height;
m_data = other.m_data;
return *this;
}
};
void InitTexBuf (SDL_Surface* image) {
CTextureBuffer texBuf;
texBuf = CTextureBuffer (image->w, image->h, image->pixels);
}
Error C2679 binary '=': no operator found which takes a right-hand operand
of type 'CTextureBuffer' (or there is no acceptable conversion)
SDL_Surface::w, ::h are ints. SDL_Surface::pixels is void *. Just so nobody complains about my not explaining the parameters.
I am clueless how I would need to write a proper copy constructor here. For me it looks like there's everything in CTextureBuffer the compiler needs.
Btw, what I am actually doing is this (wip):
// read a bunch of textures for a cubemap
// omitting a filename means "reuse the previous texture for the current cubemap face"
// first filename must not be empty
bool CTexture::Load (CArray<CString>& fileNames, bool flipVertically) {
// load texture from file
m_fileNames = fileNames;
CTextureBuffer texBuf;
for (auto const& fileName : fileNames) {
if (fileName->Length ()) {
SDL_Surface * image = IMG_Load ((char*) (*fileName));
if (!image) {
fprintf (stderr, "Couldn't find '%s'\n", (char*) (*fileName));
return false;
}
texBuf = CTextureBuffer (image->w, image->h, image->pixels);
}
m_buffers.Append (texBuf);
}
return true;
}