Demos big update
-Added some more math functions -fixed many memory leaks -added AABB and BVHTree support to collision.d *BVHTree has only incrementally adding entities implemented by now (and bad BottomUp algorithm) *ECS Systems use two trees, one for static and one for dynamic entities, dynamic BVH is builded every frame from scratch by now -BrickBreaker now uses BVHTree to collision detection *balls only use tree for checks (they aren't adding to tree) -fixed bug leading to crash
This commit is contained in:
parent
96bbcb9956
commit
64dc099e0a
9 changed files with 973 additions and 70 deletions
|
|
@ -55,6 +55,7 @@ struct Texture
|
|||
data.bpp = surf.format.BytesPerPixel;
|
||||
data.data = Mallocator.makeArray!ubyte(surf.w*surf.h*surf.format.BytesPerPixel);
|
||||
data.data[0..$] = (cast(ubyte*)surf.pixels)[0..data.data.length];
|
||||
data.size = ivec2(surf.w, surf.h);
|
||||
|
||||
SDL_FreeSurface(surf);
|
||||
|
||||
|
|
@ -67,8 +68,8 @@ struct Texture
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
if(data.bpp == 3)glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,surf.w,surf.h,0,GL_RGB,GL_UNSIGNED_BYTE,data.data.ptr);
|
||||
else if(data.bpp == 4)glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,surf.w,surf.h,0,GL_RGBA,GL_UNSIGNED_BYTE,data.data.ptr);
|
||||
if(data.bpp == 3)glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,data.size.x,data.size.y,0,GL_RGB,GL_UNSIGNED_BYTE,data.data.ptr);
|
||||
else if(data.bpp == 4)glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,data.size.x,data.size.y,0,GL_RGBA,GL_UNSIGNED_BYTE,data.data.ptr);
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +83,7 @@ struct Texture
|
|||
glBindTexture(GL_TEXTURE_2D, data.gl_handle);
|
||||
}
|
||||
|
||||
void destory() @nogc nothrow
|
||||
void destroy() @nogc nothrow
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue