D3D11 build for windows; gif making works everywhere & gif names are now dates
This commit is contained in:
parent
d52b15e1be
commit
3c43a1fad8
31
Makefile
31
Makefile
|
@ -75,7 +75,6 @@ ifeq ($(OS), Windows_NT)
|
|||
LDFLAGS += -mwin32 -static
|
||||
CFLAGS += -mwin32
|
||||
LDLIBS += mingw32 kernel32 d3d11 user32 shell32 dxgi gdi32 ws2_32 ole32 winmm setupapi m
|
||||
# LDLIBS += mingw32 kernel32 gdi32 user32 shell32 ws2_32 ole32 winmm setupapi m
|
||||
EXT = .exe
|
||||
PLAT = w64
|
||||
PKGCMD = cd $(BIN); zip -q -r $(MAKEDIR)/$(DISTDIR)/$(DIST) . -x \*.a ./obj/\*
|
||||
|
@ -98,8 +97,7 @@ else
|
|||
|
||||
ifeq ($(UNAME), Darwin)
|
||||
CFLAGS += -x objective-c
|
||||
LDFLAGS += -framework Cocoa -framework QuartzCore -framework AudioToolbox
|
||||
LDFLAGS += -framework Metal -framework MetalKit
|
||||
LDFLAGS += -framework Cocoa -framework QuartzCore -framework AudioToolbox -framework Metal -framework MetalKit
|
||||
PLAT = osx-$(ARCH)$(INFO)
|
||||
endif
|
||||
endif
|
||||
|
@ -159,7 +157,7 @@ $(DISTDIR)/$(DIST): $(BIN)/$(NAME)
|
|||
@mkdir -p $(DISTDIR)
|
||||
@$(PKGCMD)
|
||||
|
||||
$(BIN)/libengine.a: $(SHADERS) source/engine/core.cdb.h $(OBJS)
|
||||
$(BIN)/libengine.a: source/engine/core.cdb.h $(OBJS)
|
||||
@$(AR) rcs $@ $(OBJS)
|
||||
|
||||
$(BIN)/libcdb.a:
|
||||
|
@ -168,6 +166,10 @@ $(BIN)/libcdb.a:
|
|||
make -C $(CDB) CC=$(CC) AR=$(AR) libcdb.a
|
||||
cp $(CDB)/libcdb.a $(BIN)
|
||||
|
||||
tools/libcdb.a:
|
||||
make -C $(CDB) libcdb.a
|
||||
mv $(CDB)/libcdb.a tools
|
||||
|
||||
$(BIN)/libquickjs.a:
|
||||
make -C quickjs clean
|
||||
make -C quickjs OPT=$(OPT) HOST_CC=$(CC) AR=$(AR) libquickjs.a libquickjs.lto.a CC=$(CC)
|
||||
|
@ -186,8 +188,8 @@ shaders: $(SHADERS)
|
|||
@echo Creating shader $^
|
||||
@./sokol-shdc --ifdef -i $^ --slang=glsl330:hlsl5:metal_macos:glsl300es -o $@
|
||||
|
||||
cdb: tools/cdb.c $(BIN)/libcdb.a
|
||||
$(CC) $< -lcdb -L$(BIN) -I$(CDB) -o cdb
|
||||
cdb: tools/cdb.c tools/libcdb.a
|
||||
cc $^ -I$(CDB) -o cdb
|
||||
|
||||
source/engine/core.cdb.h: core.cdb
|
||||
xxd -i $< > $@
|
||||
|
@ -202,11 +204,17 @@ core.cdb: packer $(CORE)
|
|||
chmod 644 out.cdb
|
||||
mv out.cdb core.cdb
|
||||
|
||||
packer: tools/packer.c $(BIN)/libcdb.a
|
||||
cc $^ -Isource/engine/thirdparty/tinycdb -o packer
|
||||
CDB_C != find $(CDB) -name *.c
|
||||
packer: tools/packer.c tools/libcdb.a
|
||||
cc $^ -I$(CDB) -o packer
|
||||
|
||||
jso: tools/jso.c $(BIN)/libquickjs.a
|
||||
$(CC) $< -lquickjs -lm -L$(BIN) -Iquickjs -o $@
|
||||
jso: tools/jso.c tools/libquickjs.a
|
||||
$(CC) $^ -lm -Iquickjs -o $@
|
||||
|
||||
tools/libquickjs.a:
|
||||
make -C quickjs clean
|
||||
make -C quickjs OPT=$(OPT) AR=$(AR) libquickjs.a
|
||||
cp -f quickjs/libquickjs.a tools
|
||||
|
||||
%.jso: %.js jso
|
||||
@echo Making $@ from $<
|
||||
|
@ -215,13 +223,12 @@ jso: tools/jso.c $(BIN)/libquickjs.a
|
|||
WINCC = x86_64-w64-mingw32-gcc
|
||||
.PHONY: crosswin
|
||||
crosswin:
|
||||
gmake CC=$(WINCC) OS=Windows_NT
|
||||
make CC=$(WINCC) OS=Windows_NT
|
||||
|
||||
clean:
|
||||
@echo Cleaning project
|
||||
@rm -rf bin dist
|
||||
@rm -f shaders/*.sglsl.h shaders/*.metal core.cdb jso cdb packer TAGS scripts/*.jso
|
||||
@make -C $(CDB) clean
|
||||
@make -C quickjs clean
|
||||
|
||||
TAGINC != find . -name "*.[chj]"
|
||||
|
|
|
@ -285,8 +285,14 @@ Debug.Options.gif = {
|
|||
},
|
||||
};
|
||||
|
||||
DebugControls.inputs.f8 = Debug.Options.gif.start.bind(Debug.Options.gif);
|
||||
DebugControls.inputs.f9 = Debug.Options.gif.stop.bind(Debug.Options.gif);
|
||||
DebugControls.inputs.f8 = function() {
|
||||
var now = new Date();
|
||||
Debug.Options.gif.file = now.toISOString() + ".gif";
|
||||
Debug.Options.gif.start();
|
||||
};
|
||||
DebugControls.inputs.f9 = function() {
|
||||
Debug.Options.gif.stop();
|
||||
}
|
||||
|
||||
DebugControls.inputs.f10 = function() { Time.timescale = 0.1; };
|
||||
DebugControls.inputs.f10.doc = "Toggle timescale to 1/10.";
|
||||
|
|
|
@ -194,7 +194,8 @@ void debugdraw_init()
|
|||
}
|
||||
},
|
||||
.primitive_type = SG_PRIMITIVETYPE_POINTS,
|
||||
.colors[0].blend = blend_trans
|
||||
.colors[0].blend = blend_trans,
|
||||
.label = "dbg point",
|
||||
});
|
||||
|
||||
point_bind.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){
|
||||
|
@ -217,7 +218,8 @@ void debugdraw_init()
|
|||
},
|
||||
.primitive_type = SG_PRIMITIVETYPE_LINES,
|
||||
.index_type = SG_INDEXTYPE_UINT16,
|
||||
.colors[0].blend = blend_trans
|
||||
.colors[0].blend = blend_trans,
|
||||
.label = "dbg line",
|
||||
});
|
||||
|
||||
line_bind.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){
|
||||
|
@ -283,6 +285,7 @@ void debugdraw_init()
|
|||
// .cull_mode = sg_cullmode_back,
|
||||
.label = "grid pipeline",
|
||||
.colors[0].blend = blend_trans,
|
||||
.label = "dbg grid",
|
||||
});
|
||||
|
||||
grid_bind.vertex_buffers[0] = circle_bind.vertex_buffers[1];
|
||||
|
@ -298,6 +301,7 @@ void debugdraw_init()
|
|||
},
|
||||
.index_type = SG_INDEXTYPE_UINT32,
|
||||
.colors[0].blend = blend_trans,
|
||||
.label = "dbg poly",
|
||||
});
|
||||
poly_bind.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){
|
||||
.size = sizeof(struct poly_vertex)*v_amt,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include "yugine.h"
|
||||
|
||||
#include "script.h"
|
||||
|
||||
|
@ -60,6 +61,9 @@ void mYughLog(int category, int priority, int line, const char *file, const char
|
|||
// if (category == LOG_SCRIPT && priority >= 2)
|
||||
// js_stacktrace();
|
||||
}
|
||||
|
||||
if (priority >= 2)
|
||||
print_stacktrace();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -93,5 +97,6 @@ void log_cat(FILE *f) {
|
|||
}
|
||||
|
||||
void sg_logging(const char *tag, uint32_t lvl, uint32_t id, const char *msg, uint32_t line, const char *file, void *data) {
|
||||
mYughLog(lvl, 1, line, file, "tag: %s, msg: %s", tag, msg);
|
||||
lvl = 3-lvl;
|
||||
mYughLog(2, lvl, line, file, "tag: %s, msg: %s", tag, msg);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ void font_init() {
|
|||
},
|
||||
.primitive_type = SG_PRIMITIVETYPE_TRIANGLE_STRIP,
|
||||
.colors[0].blend = blend_trans,
|
||||
.label = "text",
|
||||
});
|
||||
|
||||
float text_verts[8] = {
|
||||
|
|
|
@ -69,7 +69,7 @@ void gif_rec_start(int w, int h, int cpf, int bitdepth)
|
|||
.render_target = true,
|
||||
.width = gif.w,
|
||||
.height = gif.h,
|
||||
// .pixel_format = SG_PIXELFORMAT_RGBA8
|
||||
.pixel_format = SG_PIXELFORMAT_RGBA8,
|
||||
.label = "gif rt",
|
||||
});
|
||||
|
||||
|
@ -180,8 +180,17 @@ static struct {
|
|||
sg_image depth_img;
|
||||
} crt_post;
|
||||
|
||||
void trace_make_image(const sg_image_desc *d, sg_image result, void *data)
|
||||
{
|
||||
YughInfo("Making image %s", d->label);
|
||||
}
|
||||
|
||||
void trace_make_shader(sg_shader_desc *d, sg_shader result, void *data)
|
||||
void trace_init_image(sg_image id, const sg_image_desc *d, void *data)
|
||||
{
|
||||
YughInfo("Init image %s", d->label);
|
||||
}
|
||||
|
||||
void trace_make_shader(const sg_shader_desc *d, sg_shader result, void *data)
|
||||
{
|
||||
if (sg_query_shader_state(result) == SG_RESOURCESTATE_FAILED)
|
||||
YughError("FAILED MAKING A SHADER: %s\n%s\n%s", d->label);
|
||||
|
@ -189,18 +198,42 @@ void trace_make_shader(sg_shader_desc *d, sg_shader result, void *data)
|
|||
|
||||
void trace_fail_shader(sg_shader id, void *data)
|
||||
{
|
||||
YughWarn("SHADER DID NOT COMPILE");
|
||||
YughError("SHADER DID NOT COMPILE");
|
||||
}
|
||||
|
||||
void trace_destroy_shader(sg_shader shd, void *data)
|
||||
{
|
||||
YughWarn("DESTROYED SHADER");
|
||||
YughInfo("DESTROYED SHADER");
|
||||
}
|
||||
|
||||
void trace_fail_image(sg_image id, void *data)
|
||||
{
|
||||
sg_image_desc desc = sg_query_image_desc(id);
|
||||
YughWarn("Failed to make image %s", desc.label);
|
||||
YughError("Failed to make image %s", desc.label);
|
||||
}
|
||||
|
||||
void trace_make_pipeline(const sg_pipeline_desc *d, sg_pipeline result, void *data)
|
||||
{
|
||||
YughInfo("Making pipeline %s, id %d", d->label, result);
|
||||
}
|
||||
|
||||
void trace_apply_pipeline(sg_pipeline pip, void *data)
|
||||
{
|
||||
YughInfo("Applying pipeline %d", pip);
|
||||
}
|
||||
|
||||
void trace_fail_pipeline(sg_pipeline pip, void *data)
|
||||
{
|
||||
YughError("Failed pipeline %s", sg_query_pipeline_desc(pip).label);
|
||||
}
|
||||
|
||||
void trace_make_pass(const sg_pass_desc *d, sg_pass result, void *data)
|
||||
{
|
||||
YughInfo("Making pass %s", d->label);
|
||||
}
|
||||
|
||||
void trace_begin_pass(sg_pass pass, const sg_pass_action *action, void *data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
@ -208,6 +241,14 @@ static sg_trace_hooks hooks = {
|
|||
.fail_shader = trace_fail_shader,
|
||||
.make_shader = trace_make_shader,
|
||||
.destroy_shader = trace_destroy_shader,
|
||||
.fail_image = trace_fail_image,
|
||||
.make_image = trace_make_image,
|
||||
.init_image = trace_init_image,
|
||||
.make_pipeline = trace_make_pipeline,
|
||||
.fail_pipeline = trace_fail_pipeline,
|
||||
.apply_pipeline = trace_apply_pipeline,
|
||||
.begin_pass = trace_begin_pass,
|
||||
.make_pass = trace_make_pass,
|
||||
};
|
||||
|
||||
void render_init() {
|
||||
|
@ -219,24 +260,21 @@ void render_init() {
|
|||
.context.d3d11.device_context = sapp_d3d11_get_device_context(),
|
||||
.context.d3d11.render_target_view_cb = sapp_d3d11_get_render_target_view,
|
||||
.context.d3d11.depth_stencil_view_cb = sapp_d3d11_get_depth_stencil_view,
|
||||
/* .context.metal.device = sapp_metal_get_device(),
|
||||
.context.metal.device = sapp_metal_get_device(),
|
||||
.context.metal.renderpass_descriptor_cb = sapp_metal_get_renderpass_descriptor,
|
||||
.context.metal.drawable_cb = sapp_metal_get_drawable,
|
||||
.context.color_format = (sg_pixel_format) sapp_color_format(),
|
||||
.context.depth_format = (sg_pixel_format) sapp_depth_format(),
|
||||
.context.color_format = sapp_color_format(),
|
||||
.context.depth_format = SG_PIXELFORMAT_DEPTH,
|
||||
.context.sample_count = sapp_sample_count(),
|
||||
.context.wgpu.device = sapp_wgpu_get_device(),
|
||||
.context.wgpu.render_view_cb = sapp_wgpu_get_render_view,
|
||||
.context.wgpu.resolve_view_cb = sapp_wgpu_get_resolve_view,
|
||||
.context.wgpu.depth_stencil_view_cb = sapp_wgpu_get_depth_stencil_view,
|
||||
.mtl_force_managed_storage_mode = 1,
|
||||
*/ .logger = {
|
||||
.logger = {
|
||||
.func = sg_logging,
|
||||
.user_data = NULL,
|
||||
},
|
||||
|
||||
.buffer_pool_size = 1024,
|
||||
.context.sample_count = 1,
|
||||
});
|
||||
|
||||
sg_trace_hooks hh = sg_install_trace_hooks(&hooks);
|
||||
|
@ -267,7 +305,8 @@ void render_init() {
|
|||
[1].format = SG_VERTEXFORMAT_FLOAT2
|
||||
}
|
||||
},
|
||||
.colors[0].pixel_format = SG_PIXELFORMAT_RGBA8
|
||||
.colors[0].pixel_format = SG_PIXELFORMAT_RGBA8,
|
||||
.label = "gif pipe",
|
||||
});
|
||||
|
||||
crt_post.pipe = sg_make_pipeline(&(sg_pipeline_desc){
|
||||
|
@ -277,7 +316,8 @@ void render_init() {
|
|||
[0].format = SG_VERTEXFORMAT_FLOAT2,
|
||||
[1].format = SG_VERTEXFORMAT_FLOAT2
|
||||
}
|
||||
}
|
||||
},
|
||||
.label = "crt post pipeline",
|
||||
});
|
||||
|
||||
crt_post.img = sg_make_image(&(sg_image_desc){
|
||||
|
@ -298,6 +338,7 @@ void render_init() {
|
|||
crt_post.pass = sg_make_pass(&(sg_pass_desc){
|
||||
.color_attachments[0].image = crt_post.img,
|
||||
.depth_stencil_attachment.image = crt_post.depth_img,
|
||||
.label = "crt post pass",
|
||||
});
|
||||
|
||||
#if defined SOKOL_GLCORE33 || defined SOKOL_GLES3
|
||||
|
@ -342,6 +383,7 @@ void render_init() {
|
|||
|
||||
crt_post.bind.fs.images[0] = crt_post.img;
|
||||
crt_post.bind.fs.samplers[0] = sg_make_sampler(&(sg_sampler_desc){});
|
||||
|
||||
/*
|
||||
sg_image_desc shadow_desc = {
|
||||
.render_target = true,
|
||||
|
@ -350,7 +392,7 @@ void render_init() {
|
|||
.pixel_format = SG_PIXELFORMAT_R32F,
|
||||
};
|
||||
sg_image depth_img = sg_make_image(&shadow_desc);
|
||||
shadow_desc.pixel_format = SG_PIXELFORMAT_DEPTH;
|
||||
shadow_desc.pixel_format = sapp_depth_format();
|
||||
ddimg = sg_make_image(&shadow_desc);
|
||||
|
||||
sg_shadow.pass = sg_make_pass(&(sg_pass_desc){
|
||||
|
@ -373,7 +415,7 @@ void render_init() {
|
|||
.depth = {
|
||||
.compare = SG_COMPAREFUNC_LESS_EQUAL,
|
||||
.write_enabled = true,
|
||||
.pixel_format = SG_PIXELFORMAT_DEPTH
|
||||
.pixel_format = sapp_depth_format()
|
||||
},
|
||||
.colors[0].pixel_format = SG_PIXELFORMAT_R32F,
|
||||
.index_type = SG_INDEXTYPE_UINT16,
|
||||
|
@ -394,6 +436,7 @@ void render_winsize()
|
|||
.render_target = true,
|
||||
.width = mainwin.width,
|
||||
.height = mainwin.height,
|
||||
.label = "crt img resize",
|
||||
});
|
||||
|
||||
crt_post.depth_img = sg_make_image(&(sg_image_desc){
|
||||
|
@ -401,11 +444,13 @@ void render_winsize()
|
|||
.width = mainwin.width,
|
||||
.height = mainwin.height,
|
||||
.pixel_format = SG_PIXELFORMAT_DEPTH,
|
||||
.label = "crt depth resize",
|
||||
});
|
||||
|
||||
crt_post.pass = sg_make_pass(&(sg_pass_desc){
|
||||
.color_attachments[0].image = crt_post.img,
|
||||
.depth_stencil_attachment.image = crt_post.depth_img,
|
||||
.label = "crt pass resize",
|
||||
});
|
||||
|
||||
crt_post.bind.fs.images[0] = crt_post.img;
|
||||
|
|
|
@ -117,7 +117,6 @@ void sprite_io(struct sprite *sprite, FILE *f, int read) {
|
|||
void sprite_draw_all() {
|
||||
sg_apply_pipeline(pip_sprite);
|
||||
sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, SG_RANGE_REF(projection));
|
||||
|
||||
static struct sprite **layers[5];
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
|
@ -154,11 +153,11 @@ void sprite_initialize() {
|
|||
[2].format = SG_VERTEXFORMAT_UBYTE4N}},
|
||||
.primitive_type = SG_PRIMITIVETYPE_TRIANGLE_STRIP,
|
||||
.label = "sprite pipeline",
|
||||
/* .depth = {
|
||||
.depth = {
|
||||
.write_enabled = true,
|
||||
.compare = SG_COMPAREFUNC_LESS_EQUAL
|
||||
.compare = SG_COMPAREFUNC_LESS_EQUAL,
|
||||
.pixel_format = SG_PIXELFORMAT_DEPTH
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
bind_sprite.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){
|
||||
|
|
22
source/engine/thirdparty/sokol/sokol_gfx_ext.h
vendored
22
source/engine/thirdparty/sokol/sokol_gfx_ext.h
vendored
|
@ -164,17 +164,8 @@ static void _sg_d3d11_query_image_pixels(_sg_image_t* img, void* pixels) {
|
|||
D3D11_MAPPED_SUBRESOURCE msr = {.pData = NULL};
|
||||
hr = _sg_d3d11_Map(_sg.d3d11.ctx, (ID3D11Resource*)staging_tex, 0, D3D11_MAP_READ, 0, &msr);
|
||||
SOKOL_ASSERT(SUCCEEDED(hr));
|
||||
memcpy(pixels, msr.pData, img->cmn.width * img->cmn.height * 4);
|
||||
|
||||
// copy the data into the desired buffer, converting pixels to the desired format at the same time
|
||||
/* int res = SDL_ConvertPixels(
|
||||
img->cmn.width, img->cmn.height,
|
||||
_sg_d3d11_dxgi_format_to_sdl_pixel_format(staging_desc.Format),
|
||||
msr.pData, msr.RowPitch,
|
||||
SDL_PIXELFORMAT_RGBA32,
|
||||
pixels, img->cmn.width * 4);
|
||||
SOKOL_ASSERT(res == 0);
|
||||
_SOKOL_UNUSED(res);
|
||||
*/
|
||||
// unmap the texture
|
||||
_sg_d3d11_Unmap(_sg.d3d11.ctx, (ID3D11Resource*)staging_tex, 0);
|
||||
|
||||
|
@ -231,16 +222,7 @@ static void _sg_d3d11_query_pixels(int x, int y, int w, int h, bool origin_top_l
|
|||
hr = _sg_d3d11_Map(_sg.d3d11.ctx, (ID3D11Resource*)staging_tex, 0, D3D11_MAP_READ, 0, &msr);
|
||||
SOKOL_ASSERT(SUCCEEDED(hr));
|
||||
|
||||
// copy the data into the desired buffer, converting pixels to the desired format at the same time
|
||||
/* int res = SDL_ConvertPixels(
|
||||
w, h,
|
||||
_sg_d3d11_dxgi_format_to_sdl_pixel_format(staging_desc.Format),
|
||||
msr.pData, msr.RowPitch,
|
||||
SDL_PIXELFORMAT_RGBA32,
|
||||
pixels, w * 4);
|
||||
SOKOL_ASSERT(res == 0);
|
||||
_SOKOL_UNUSED(res);
|
||||
*/
|
||||
memcpy(pixels, msr.pData, w * h * 4);
|
||||
// unmap the texture
|
||||
_sg_d3d11_Unmap(_sg.d3d11.ctx, (ID3D11Resource*)staging_tex, 0);
|
||||
|
||||
|
|
4479
source/engine/thirdparty/sokol/sokol_gfx_imgui.h
vendored
4479
source/engine/thirdparty/sokol/sokol_gfx_imgui.h
vendored
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue