sokol demo wip

This commit is contained in:
nesbox 2018-09-21 17:32:02 +03:00
parent cd4db83725
commit c1fee278f3
3 changed files with 4 additions and 16 deletions

@ -1 +1 @@
Subproject commit 746dd7ec6a6f4d142db9e01aaca9459d0154e9e9 Subproject commit f4349bec5a48b3a1261a10888edccd15aa649c4f

View File

@ -255,7 +255,7 @@ if(APPLE)
endif() endif()
target_include_directories(sokol PRIVATE include) target_include_directories(sokol PRIVATE include)
target_include_directories(sokol PRIVATE ../sokol) target_include_directories(sokol PRIVATE 3rd-party/sokol)
target_include_directories(sokol PRIVATE src) target_include_directories(sokol PRIVATE src)
if(MINGW) if(MINGW)

View File

@ -8,8 +8,7 @@
#include <string.h> #include <string.h>
#include <tic80.h> #include <tic80.h>
#define GFX_MAX_FB_WIDTH (TIC80_FULLWIDTH) static tic80* tic = NULL;
#define GFX_MAX_FB_HEIGHT (TIC80_FULLWIDTH)
#if defined(SOKOL_GLCORE33) #if defined(SOKOL_GLCORE33)
static const char* gfx_vs_src = static const char* gfx_vs_src =
@ -104,7 +103,6 @@ typedef struct {
int fb_height; int fb_height;
int fb_aspect_scale_x; int fb_aspect_scale_x;
int fb_aspect_scale_y; int fb_aspect_scale_y;
uint32_t rgba8_buffer[GFX_MAX_FB_WIDTH * GFX_MAX_FB_HEIGHT];
} gfx_state; } gfx_state;
static gfx_state gfx; static gfx_state gfx;
@ -233,7 +231,7 @@ void gfx_draw() {
/* copy emulator pixel data into upscaling source texture */ /* copy emulator pixel data into upscaling source texture */
sg_update_image(gfx.upscale_draw_state.fs_images[0], &(sg_image_content){ sg_update_image(gfx.upscale_draw_state.fs_images[0], &(sg_image_content){
.subimage[0][0] = { .subimage[0][0] = {
.ptr = gfx.rgba8_buffer, .ptr = tic->screen,
.size = gfx.fb_width*gfx.fb_height*sizeof(uint32_t) .size = gfx.fb_width*gfx.fb_height*sizeof(uint32_t)
} }
}); });
@ -253,19 +251,12 @@ void gfx_draw() {
sg_commit(); sg_commit();
} }
////////////////////////////////////////////////////////////////////////////////////////////
static tic80* tic = NULL;
static void app_init(void) static void app_init(void)
{ {
saudio_desc desc = {0}; saudio_desc desc = {0};
saudio_setup(&desc); saudio_setup(&desc);
printf("channels %i\n", saudio_channels());
printf("samplerate %i\n", saudio_sample_rate());
FILE* file = fopen("cart.tic", "rb"); FILE* file = fopen("cart.tic", "rb");
if(file) if(file)
@ -299,10 +290,7 @@ static tic80_input tic_input;
static void app_frame(void) static void app_frame(void)
{ {
if(tic) if(tic)
{
tic80_tick(tic, tic_input); tic80_tick(tic, tic_input);
memcpy(gfx.rgba8_buffer, tic->screen, sizeof gfx.rgba8_buffer);
}
gfx_draw(); gfx_draw();