Demos update

-added functionality to detect host CPU threads count
-fixed some memory leaks
-now textures free memory corectly
-added support for up to 32 threads
This commit is contained in:
Mergul 2020-05-13 15:34:24 +02:00
parent dd491302af
commit 3647fa4b86
6 changed files with 98 additions and 16 deletions

View file

@ -54,6 +54,8 @@ struct Texture
data.data = Mallocator.makeArray!ubyte(surf.w*surf.h*surf.format.BytesPerPixel);
data.data[0..$] = (cast(ubyte*)surf.pixels)[0..data.data.length];
SDL_FreeSurface(surf);
glGenTextures(1, &data.gl_handle);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D,data.gl_handle);
@ -78,11 +80,12 @@ struct Texture
glBindTexture(GL_TEXTURE_2D, data.gl_handle);
}
void destory()
void destory() @nogc nothrow
{
if(data)
{
glDeleteTextures(1, &data.gl_handle);
if(data.data)Mallocator.dispose(data.data);
Mallocator.dispose(data);
data = null;
}