no message
This commit is contained in:
parent
11bf2568f4
commit
7fe1da4e74
|
@ -131,8 +131,11 @@ target_include_directories(tic80lib PRIVATE 3rd-party/fennel)
|
||||||
add_dependencies(tic80lib lua lpeg wren giflib)
|
add_dependencies(tic80lib lua lpeg wren giflib)
|
||||||
target_link_libraries(tic80lib lua lpeg wren giflib)
|
target_link_libraries(tic80lib lua lpeg wren giflib)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(HAVE_LIBC TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(SDL_STATIC ON)
|
set(SDL_STATIC ON)
|
||||||
set(HAVE_LIBC TRUE)
|
|
||||||
add_subdirectory(3rd-party/SDL2-2.0.7)
|
add_subdirectory(3rd-party/SDL2-2.0.7)
|
||||||
|
|
||||||
set(EXAMPLE_DIR examples)
|
set(EXAMPLE_DIR examples)
|
||||||
|
@ -141,14 +144,14 @@ set(EXAMPLE_SRC
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_executable(example WIN32 ${EXAMPLE_SRC})
|
add_executable(sdl-renderer WIN32 ${EXAMPLE_SRC})
|
||||||
else()
|
else()
|
||||||
add_executable(example ${EXAMPLE_SRC})
|
add_executable(sdl-renderer ${EXAMPLE_SRC})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(example PRIVATE 3rd-party/SDL2-2.0.7/include)
|
target_include_directories(sdl-renderer PRIVATE 3rd-party/SDL2-2.0.7/include)
|
||||||
target_include_directories(example PRIVATE include)
|
target_include_directories(sdl-renderer PRIVATE include)
|
||||||
target_include_directories(example PRIVATE src)
|
target_include_directories(sdl-renderer PRIVATE src)
|
||||||
|
|
||||||
add_dependencies(example tic80lib SDL2-static SDL2main)
|
add_dependencies(sdl-renderer tic80lib SDL2-static SDL2main)
|
||||||
target_link_libraries(example tic80lib SDL2-static SDL2main)
|
target_link_libraries(sdl-renderer tic80lib SDL2-static SDL2main)
|
||||||
|
|
|
@ -60,7 +60,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
{
|
{
|
||||||
SDL_Window* window = SDL_CreateWindow("TIC-80 SDL demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, TIC80_FULLWIDTH, TIC80_FULLHEIGHT, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
|
SDL_Window* window = SDL_CreateWindow("TIC-80 SDL demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, TIC80_FULLWIDTH, TIC80_FULLHEIGHT, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
|
||||||
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);// TODO: disable vsync
|
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
||||||
SDL_Texture* texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, TIC80_FULLWIDTH, TIC80_FULLHEIGHT);
|
SDL_Texture* texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, TIC80_FULLWIDTH, TIC80_FULLHEIGHT);
|
||||||
|
|
||||||
SDL_AudioDeviceID audioDevice = 0;
|
SDL_AudioDeviceID audioDevice = 0;
|
||||||
|
@ -99,6 +99,9 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
if(tic)
|
if(tic)
|
||||||
{
|
{
|
||||||
|
u64 nextTick = SDL_GetPerformanceCounter();
|
||||||
|
const u64 Delta = SDL_GetPerformanceFrequency() / TIC_FRAMERATE;
|
||||||
|
|
||||||
while(!state.quit)
|
while(!state.quit)
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
@ -139,6 +142,8 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nextTick += Delta;
|
||||||
|
|
||||||
tic80_tick(tic, input);
|
tic80_tick(tic, input);
|
||||||
|
|
||||||
if (!audioStarted && audioDevice)
|
if (!audioStarted && audioDevice)
|
||||||
|
@ -172,6 +177,15 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
|
|
||||||
|
{
|
||||||
|
s64 delay = nextTick - SDL_GetPerformanceCounter();
|
||||||
|
|
||||||
|
if (delay < 0)
|
||||||
|
nextTick -= delay;
|
||||||
|
else SDL_Delay((u32)(delay * 1000 / SDL_GetPerformanceFrequency()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tic80_delete(tic);
|
tic80_delete(tic);
|
||||||
|
|
Loading…
Reference in New Issue