Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questions/suggestions about ZL_Surface #16

Open
tobybear opened this issue Feb 12, 2022 · 0 comments
Open

Questions/suggestions about ZL_Surface #16

tobybear opened this issue Feb 12, 2022 · 0 comments

Comments

@tobybear
Copy link

  1. ZL_Surface does not seem to free the allocated memory for the texture if it gets reassigned.
    I know this is probably a not very common use case, but consider this:
	srfBuffer = ZL_Surface(pixelsA, w, h, 3);
	srfBuffer = ZL_Surface(pixelsB, w, h, 3);
	srfBuffer = ZL_Surface(pixelsC, w, h, 3);

The texture resources for the first two calls are not freed and eat up memory (the pixelsA/B/C buffer remain constant).
Even when doing a default constructor assign inbetween the calls, it doesn't change:
srfBuffer = ZL_Surface();
I haven't looked further into this, but as a quick fix, added my own clearing function, although I had to make the imp structures public:

void ZL_Surface::Clear()
{
	if (impl->tex) {
		delete impl->tex;
	}
	delete impl;
	impl = NULL;
}
  1. In ZL_Texture_Impl::CreateFromBitmap(), is it necessary to do a memcpy of the whole provided buffer? I know the pixel buffer parameter pixels is const, but the memcpy introduces a bit of overhead.

  2. Is there an easy way to update an existing ZL_Surface (created from a pixel buffer) with a new/modified buffer without re-creating everything? Maybe if dimensions are identical, just calling the glTexImage2D/glTexSubImage2D again.
    I guess LoadBitmapIntoTexture() would already do this, but I can't access the implementation easily, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant