update dlib to include vulkan
This commit is contained in:
parent
1a71c3235d
commit
8690e93b41
67
assets.d
67
assets.d
@ -1,6 +1,38 @@
|
|||||||
module dlib.assets;
|
module dlib.assets;
|
||||||
|
|
||||||
import dlibincludes;
|
import dlibincludes : cgltf_result,
|
||||||
|
cgltf_memory_options,
|
||||||
|
cgltf_file_options,
|
||||||
|
cgltf_size,
|
||||||
|
cgltf_image,
|
||||||
|
cgltf_accessor,
|
||||||
|
cgltf_result_success,
|
||||||
|
cgltf_result_io_error,
|
||||||
|
cgltf_free,
|
||||||
|
cgltf_options,
|
||||||
|
cgltf_node,
|
||||||
|
cgltf_load_buffers,
|
||||||
|
cgltf_data,
|
||||||
|
cgltf_load_buffer_base64,
|
||||||
|
stbi_image_free,
|
||||||
|
stbi_load_from_memory,
|
||||||
|
cgltf_primitive_type_triangles,
|
||||||
|
cgltf_node_transform_world,
|
||||||
|
cgltf_float,
|
||||||
|
cgltf_mesh,
|
||||||
|
cgltf_parse,
|
||||||
|
cgltf_attribute_type_position,
|
||||||
|
cgltf_type_vec3,
|
||||||
|
cgltf_component_type_r_32f,
|
||||||
|
cgltf_attribute_type_normal,
|
||||||
|
cgltf_attribute_type_tangent,
|
||||||
|
cgltf_type_vec4,
|
||||||
|
cgltf_attribute_type_texcoord,
|
||||||
|
cgltf_type_vec2,
|
||||||
|
cgltf_component_type_r_8u,
|
||||||
|
cgltf_component_type_r_16u,
|
||||||
|
cgltf_attribute_type_color,
|
||||||
|
cgltf_component_type_r_32u;
|
||||||
import dlib.aliases;
|
import dlib.aliases;
|
||||||
import dlib.util;
|
import dlib.util;
|
||||||
import dlib.alloc;
|
import dlib.alloc;
|
||||||
@ -10,7 +42,8 @@ import std.file;
|
|||||||
import std.path;
|
import std.path;
|
||||||
import std.format;
|
import std.format;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import std.exception;
|
import core.stdc.string : strlen;
|
||||||
|
import core.stdc.stdio : File = FILE, FOpen = fopen, FSeek = fseek, FTell = ftell, FClose = fclose, FRead = fread, SeekSet = SEEK_SET, SeekEnd = SEEK_END;
|
||||||
|
|
||||||
__gshared ImageData DEFAULT_IMAGE = GenerateDefaultTexture(32, 32);
|
__gshared ImageData DEFAULT_IMAGE = GenerateDefaultTexture(32, 32);
|
||||||
__gshared Material DEFAULT_MATERIAL = GenerateDefaultMaterial();
|
__gshared Material DEFAULT_MATERIAL = GenerateDefaultMaterial();
|
||||||
@ -148,29 +181,30 @@ U32ColToVec4(u32 col, Vec4* vec)
|
|||||||
|
|
||||||
// TODO: make better
|
// TODO: make better
|
||||||
u8[]
|
u8[]
|
||||||
OpenFile(string file_name)
|
OpenFile(string file_name) nothrow @nogc
|
||||||
{
|
{
|
||||||
File f;
|
File* f;
|
||||||
u8[] data;
|
u8[] data;
|
||||||
|
|
||||||
try
|
f = FOpen(file_name.ptr, "rb");
|
||||||
|
if(f)
|
||||||
{
|
{
|
||||||
f = File(file_name, "rb");
|
FSeek(f, 0, SeekEnd);
|
||||||
data = Alloc!(u8)(f.size());
|
u64 size = FTell(f);
|
||||||
f.rawRead(data);
|
FSeek(f, 0, SeekSet);
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
data = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
f.close();
|
data = Alloc!(u8)(size);
|
||||||
|
|
||||||
|
FRead(data.ptr, 1, size, f);
|
||||||
|
|
||||||
|
FClose(f);
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern (C) cgltf_result
|
extern (C) cgltf_result
|
||||||
GLTFLoadCallback(cgltf_memory_options* memory_opts, cgltf_file_options* file_opts, const(char)* path, cgltf_size* size, void** data)
|
GLTFLoadCallback(cgltf_memory_options* memory_opts, cgltf_file_options* file_opts, const(char)* path, cgltf_size* size, void** data) nothrow @nogc
|
||||||
{
|
{
|
||||||
u8[] file_data = OpenFile(ConvToStr(path[0 .. strlen(path)]));
|
u8[] file_data = OpenFile(ConvToStr(path[0 .. strlen(path)]));
|
||||||
|
|
||||||
@ -183,7 +217,7 @@ GLTFLoadCallback(cgltf_memory_options* memory_opts, cgltf_file_options* file_opt
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern (C) void
|
extern (C) void
|
||||||
GLTFFreeCallback(cgltf_memory_options* memory_opts, cgltf_file_options* file_opts, void* data, cgltf_size size)
|
GLTFFreeCallback(cgltf_memory_options* memory_opts, cgltf_file_options* file_opts, void* data, cgltf_size size) nothrow @nogc
|
||||||
{
|
{
|
||||||
Free(data);
|
Free(data);
|
||||||
}
|
}
|
||||||
@ -779,3 +813,4 @@ GenerateDefaultMaterial()
|
|||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import std.exception;
|
||||||
|
|||||||
@ -21,7 +21,11 @@
|
|||||||
# include "external/stb/stb_image.h"
|
# include "external/stb/stb_image.h"
|
||||||
# include "external/stb/stb_image_write.h"
|
# include "external/stb/stb_image_write.h"
|
||||||
# include "external/stb/stb_truetype.h"
|
# include "external/stb/stb_truetype.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef DLIB_INCLUDE_VULKAN
|
||||||
|
# include "../VulkanRenderer/vulkan_includes.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CGLM_FORCE_DEPTH_ZERO_TO_ONE
|
#define CGLM_FORCE_DEPTH_ZERO_TO_ONE
|
||||||
#include "external/cglm/cglm.h"
|
#include "external/cglm/cglm.h"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user