adapt 2D view on window resolution changes
parent
cf173f3d50
commit
80fbb030bd
|
@ -1,18 +1,18 @@
|
||||||
build
|
build
|
||||||
build_rel
|
build_rel
|
||||||
screenshots
|
screenshots
|
||||||
build.bat
|
build.bat
|
||||||
run.bat
|
run.bat
|
||||||
clean.bat
|
clean.bat
|
||||||
work
|
work
|
||||||
.vscode
|
.vscode
|
||||||
.ds_store
|
.ds_store
|
||||||
|
|
||||||
GPATH
|
GPATH
|
||||||
GRTAGS
|
GRTAGS
|
||||||
GTAGS
|
GTAGS
|
||||||
/run_release.bat
|
/run_release.bat
|
||||||
/package.bat
|
/package.bat
|
||||||
pkg
|
pkg
|
||||||
pkg.zip
|
pkg.zip
|
||||||
eco2d.zip
|
eco2d.zip
|
|
@ -1,22 +1,22 @@
|
||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
project(eco2d)
|
project(eco2d)
|
||||||
include(cmake/utils.cmake)
|
include(cmake/utils.cmake)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/)
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/)
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/)
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(code/common code/vendors code/vendors/flecs)
|
include_directories(code/common code/vendors code/vendors/flecs)
|
||||||
|
|
||||||
include(cmake/FindRaylib.cmake)
|
include(cmake/FindRaylib.cmake)
|
||||||
|
|
||||||
add_subdirectory(code/modules)
|
add_subdirectory(code/modules)
|
||||||
add_subdirectory(code/vendors)
|
add_subdirectory(code/vendors)
|
||||||
|
|
||||||
add_subdirectory(code/game)
|
add_subdirectory(code/game)
|
||||||
|
|
|
@ -27,7 +27,7 @@ static bool request_shutdown;
|
||||||
|
|
||||||
void platform_init() {
|
void platform_init() {
|
||||||
InitWindow(screenWidth, screenHeight, "eco2d");
|
InitWindow(screenWidth, screenHeight, "eco2d");
|
||||||
SetWindowState(FLAG_WINDOW_UNDECORATED|FLAG_WINDOW_MAXIMIZED|FLAG_WINDOW_RESIZABLE|FLAG_MSAA_4X_HINT);
|
SetWindowState(/*FLAG_WINDOW_UNDECORATED|*/FLAG_WINDOW_MAXIMIZED|FLAG_WINDOW_RESIZABLE|FLAG_MSAA_4X_HINT);
|
||||||
|
|
||||||
screenWidth = (uint16_t)GetScreenWidth();
|
screenWidth = (uint16_t)GetScreenWidth();
|
||||||
screenHeight = (uint16_t)GetScreenHeight();
|
screenHeight = (uint16_t)GetScreenHeight();
|
||||||
|
@ -169,6 +169,9 @@ void platform_input() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_render() {
|
void platform_render() {
|
||||||
|
screenWidth = (uint16_t)GetScreenWidth();
|
||||||
|
screenHeight = (uint16_t)GetScreenHeight();
|
||||||
|
|
||||||
profile(PROF_ENTITY_LERP) {
|
profile(PROF_ENTITY_LERP) {
|
||||||
game_world_view_active_entity_map(lerp_entity_positions);
|
game_world_view_active_entity_map(lerp_entity_positions);
|
||||||
game_world_view_active_entity_map(do_entity_fadeinout);
|
game_world_view_active_entity_map(do_entity_fadeinout);
|
||||||
|
|
|
@ -119,6 +119,7 @@ void DEBUG_draw_entities_low(uint64_t key, entity_view * data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderer_draw_v0(void) {
|
void renderer_draw_v0(void) {
|
||||||
|
render_camera.offset = (Vector2){(float)(screenWidth >> 1), (float)(screenHeight >> 1)};
|
||||||
render_camera.zoom = zpl_lerp(render_camera.zoom, target_zoom, GetFrameTime()*2.9978f);
|
render_camera.zoom = zpl_lerp(render_camera.zoom, target_zoom, GetFrameTime()*2.9978f);
|
||||||
camera_update();
|
camera_update();
|
||||||
|
|
||||||
|
|
|
@ -1,137 +1,137 @@
|
||||||
#include "flecs_os_api_stdcpp.h"
|
#include "flecs_os_api_stdcpp.h"
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
|
||||||
#include "flecs/flecs.h"
|
#include "flecs/flecs.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static
|
static
|
||||||
ecs_os_thread_t stdcpp_thread_new(
|
ecs_os_thread_t stdcpp_thread_new(
|
||||||
ecs_os_thread_callback_t callback,
|
ecs_os_thread_callback_t callback,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
std::thread *thread = new std::thread{callback,arg};
|
std::thread *thread = new std::thread{callback,arg};
|
||||||
return reinterpret_cast<ecs_os_thread_t>(thread);
|
return reinterpret_cast<ecs_os_thread_t>(thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void* stdcpp_thread_join(
|
void* stdcpp_thread_join(
|
||||||
ecs_os_thread_t thread)
|
ecs_os_thread_t thread)
|
||||||
{
|
{
|
||||||
void *arg = nullptr;
|
void *arg = nullptr;
|
||||||
std::thread *thr = reinterpret_cast<std::thread*>(thread);
|
std::thread *thr = reinterpret_cast<std::thread*>(thread);
|
||||||
thr->join();
|
thr->join();
|
||||||
delete thr;
|
delete thr;
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int32_t stdcpp_ainc(int32_t *count) {
|
int32_t stdcpp_ainc(int32_t *count) {
|
||||||
int value;
|
int value;
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
value = __sync_add_and_fetch (count, 1);
|
value = __sync_add_and_fetch (count, 1);
|
||||||
return value;
|
return value;
|
||||||
#else
|
#else
|
||||||
(void)value;
|
(void)value;
|
||||||
return InterlockedIncrement(reinterpret_cast<long*>(count));
|
return InterlockedIncrement(reinterpret_cast<long*>(count));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int32_t stdcpp_adec(int32_t *count) {
|
int32_t stdcpp_adec(int32_t *count) {
|
||||||
int value;
|
int value;
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
value = __sync_sub_and_fetch (count, 1);
|
value = __sync_sub_and_fetch (count, 1);
|
||||||
return value;
|
return value;
|
||||||
#else
|
#else
|
||||||
(void)value;
|
(void)value;
|
||||||
return InterlockedDecrement(reinterpret_cast<long*>(count));
|
return InterlockedDecrement(reinterpret_cast<long*>(count));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
ecs_os_mutex_t stdcpp_mutex_new(void) {
|
ecs_os_mutex_t stdcpp_mutex_new(void) {
|
||||||
std::mutex *mutex = new std::mutex;
|
std::mutex *mutex = new std::mutex;
|
||||||
return reinterpret_cast<ecs_os_mutex_t>(mutex);
|
return reinterpret_cast<ecs_os_mutex_t>(mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void stdcpp_mutex_free(ecs_os_mutex_t m) {
|
void stdcpp_mutex_free(ecs_os_mutex_t m) {
|
||||||
std::mutex*mutex = reinterpret_cast<std::mutex*>(m);
|
std::mutex*mutex = reinterpret_cast<std::mutex*>(m);
|
||||||
delete mutex;
|
delete mutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void stdcpp_mutex_lock(ecs_os_mutex_t m) {
|
void stdcpp_mutex_lock(ecs_os_mutex_t m) {
|
||||||
std::mutex*mutex = reinterpret_cast<std::mutex*>(m);
|
std::mutex*mutex = reinterpret_cast<std::mutex*>(m);
|
||||||
mutex->lock();
|
mutex->lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void stdcpp_mutex_unlock(ecs_os_mutex_t m) {
|
void stdcpp_mutex_unlock(ecs_os_mutex_t m) {
|
||||||
std::mutex *mutex = reinterpret_cast<std::mutex*>(m);
|
std::mutex *mutex = reinterpret_cast<std::mutex*>(m);
|
||||||
mutex->unlock();
|
mutex->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
ecs_os_cond_t stdcpp_cond_new(void) {
|
ecs_os_cond_t stdcpp_cond_new(void) {
|
||||||
std::condition_variable_any* cond = new std::condition_variable_any{};
|
std::condition_variable_any* cond = new std::condition_variable_any{};
|
||||||
return (ecs_os_cond_t)cond;
|
return (ecs_os_cond_t)cond;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void stdcpp_cond_free(ecs_os_cond_t c) {
|
void stdcpp_cond_free(ecs_os_cond_t c) {
|
||||||
std::condition_variable_any *cond = reinterpret_cast<std::condition_variable_any*>(c);
|
std::condition_variable_any *cond = reinterpret_cast<std::condition_variable_any*>(c);
|
||||||
delete cond;
|
delete cond;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void stdcpp_cond_signal(ecs_os_cond_t c) {
|
void stdcpp_cond_signal(ecs_os_cond_t c) {
|
||||||
std::condition_variable_any *cond = reinterpret_cast<std::condition_variable_any*>(c);
|
std::condition_variable_any *cond = reinterpret_cast<std::condition_variable_any*>(c);
|
||||||
cond->notify_one();
|
cond->notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void stdcpp_cond_broadcast(ecs_os_cond_t c) {
|
void stdcpp_cond_broadcast(ecs_os_cond_t c) {
|
||||||
std::condition_variable_any*cond = reinterpret_cast<std::condition_variable_any*>(c);
|
std::condition_variable_any*cond = reinterpret_cast<std::condition_variable_any*>(c);
|
||||||
cond->notify_all();
|
cond->notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void stdcpp_cond_wait(ecs_os_cond_t c, ecs_os_mutex_t m) {
|
void stdcpp_cond_wait(ecs_os_cond_t c, ecs_os_mutex_t m) {
|
||||||
std::condition_variable_any* cond = reinterpret_cast<std::condition_variable_any*>(c);
|
std::condition_variable_any* cond = reinterpret_cast<std::condition_variable_any*>(c);
|
||||||
std::mutex* mutex = reinterpret_cast<std::mutex*>(m);
|
std::mutex* mutex = reinterpret_cast<std::mutex*>(m);
|
||||||
cond->wait(*mutex);
|
cond->wait(*mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
void stdcpp_set_os_api(void) {
|
void stdcpp_set_os_api(void) {
|
||||||
ecs_os_set_api_defaults();
|
ecs_os_set_api_defaults();
|
||||||
|
|
||||||
ecs_os_api_t api = ecs_os_api;
|
ecs_os_api_t api = ecs_os_api;
|
||||||
|
|
||||||
api.thread_new_ = stdcpp_thread_new;
|
api.thread_new_ = stdcpp_thread_new;
|
||||||
api.thread_join_ = stdcpp_thread_join;
|
api.thread_join_ = stdcpp_thread_join;
|
||||||
api.ainc_ = stdcpp_ainc;
|
api.ainc_ = stdcpp_ainc;
|
||||||
api.adec_ = stdcpp_adec;
|
api.adec_ = stdcpp_adec;
|
||||||
api.mutex_new_ = stdcpp_mutex_new;
|
api.mutex_new_ = stdcpp_mutex_new;
|
||||||
api.mutex_free_ = stdcpp_mutex_free;
|
api.mutex_free_ = stdcpp_mutex_free;
|
||||||
api.mutex_lock_ = stdcpp_mutex_lock;
|
api.mutex_lock_ = stdcpp_mutex_lock;
|
||||||
api.mutex_unlock_ = stdcpp_mutex_unlock;
|
api.mutex_unlock_ = stdcpp_mutex_unlock;
|
||||||
api.cond_new_ = stdcpp_cond_new;
|
api.cond_new_ = stdcpp_cond_new;
|
||||||
api.cond_free_ = stdcpp_cond_free;
|
api.cond_free_ = stdcpp_cond_free;
|
||||||
api.cond_signal_ = stdcpp_cond_signal;
|
api.cond_signal_ = stdcpp_cond_signal;
|
||||||
api.cond_broadcast_ = stdcpp_cond_broadcast;
|
api.cond_broadcast_ = stdcpp_cond_broadcast;
|
||||||
api.cond_wait_ = stdcpp_cond_wait;
|
api.cond_wait_ = stdcpp_cond_wait;
|
||||||
|
|
||||||
ecs_os_set_api(&api);
|
ecs_os_set_api(&api);
|
||||||
}
|
}
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#ifndef FLECS_OS_API_STDCPP_H
|
#ifndef FLECS_OS_API_STDCPP_H
|
||||||
#define FLECS_OS_API_STDCPP_H
|
#define FLECS_OS_API_STDCPP_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void stdcpp_set_os_api(void);
|
extern void stdcpp_set_os_api(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
File diff suppressed because it is too large
Load Diff
140
project.4coder
140
project.4coder
|
@ -1,70 +1,70 @@
|
||||||
version(1);
|
version(1);
|
||||||
|
|
||||||
project_name = "eco2d";
|
project_name = "eco2d";
|
||||||
|
|
||||||
patterns =
|
patterns =
|
||||||
{
|
{
|
||||||
"*.c",
|
"*.c",
|
||||||
"*.cpp",
|
"*.cpp",
|
||||||
"*.jai",
|
"*.jai",
|
||||||
"*.odin",
|
"*.odin",
|
||||||
"*.zig",
|
"*.zig",
|
||||||
"*.h",
|
"*.h",
|
||||||
"*.inc",
|
"*.inc",
|
||||||
"*.bat",
|
"*.bat",
|
||||||
"*.sh",
|
"*.sh",
|
||||||
"*.4coder",
|
"*.4coder",
|
||||||
"*.txt",
|
"*.txt",
|
||||||
"*.cmake",
|
"*.cmake",
|
||||||
"*.md",
|
"*.md",
|
||||||
};
|
};
|
||||||
|
|
||||||
blacklist_patterns =
|
blacklist_patterns =
|
||||||
{
|
{
|
||||||
".*",
|
".*",
|
||||||
};
|
};
|
||||||
|
|
||||||
load_paths =
|
load_paths =
|
||||||
{
|
{
|
||||||
{{
|
{{
|
||||||
{ ".", .recursive = false, .relative = true },
|
{ ".", .recursive = false, .relative = true },
|
||||||
{ "code/game", .recursive = true, .relative = true },
|
{ "code/game", .recursive = true, .relative = true },
|
||||||
{ "code/common", .recursive = true, .relative = true },
|
{ "code/common", .recursive = true, .relative = true },
|
||||||
{ "code/modules", .recursive = true, .relative = true },
|
{ "code/modules", .recursive = true, .relative = true },
|
||||||
{ "code/vendors", .recursive = true, .relative = true },
|
{ "code/vendors", .recursive = true, .relative = true },
|
||||||
{ "cmake", .recursive = true, .relative = true },
|
{ "cmake", .recursive = true, .relative = true },
|
||||||
{ "build/_deps/raylib-src/src", .recursive = true, .relative = true }
|
{ "build/_deps/raylib-src/src", .recursive = true, .relative = true }
|
||||||
}, .os = "win"}
|
}, .os = "win"}
|
||||||
};
|
};
|
||||||
|
|
||||||
command_list =
|
command_list =
|
||||||
{
|
{
|
||||||
|
|
||||||
{
|
{
|
||||||
.name = "build",
|
.name = "build",
|
||||||
.out = "*compilation*",
|
.out = "*compilation*",
|
||||||
.footer_panel = true,
|
.footer_panel = true,
|
||||||
.save_dirty_files = true,
|
.save_dirty_files = true,
|
||||||
.cursor_at_end = false,
|
.cursor_at_end = false,
|
||||||
.cmd =
|
.cmd =
|
||||||
{
|
{
|
||||||
{ "cmake --build build", .os = "win" },
|
{ "cmake --build build", .os = "win" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
.name = "run",
|
.name = "run",
|
||||||
.out = "*console*",
|
.out = "*console*",
|
||||||
.footer_panel = false,
|
.footer_panel = false,
|
||||||
.save_dirty_files = true,
|
.save_dirty_files = true,
|
||||||
.cursor_at_end = true,
|
.cursor_at_end = true,
|
||||||
.cmd =
|
.cmd =
|
||||||
{
|
{
|
||||||
{ "run.bat", .os = "win" },
|
{ "run.bat", .os = "win" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fkey_command[1] = "build";
|
fkey_command[1] = "build";
|
||||||
fkey_command[2] = "run";
|
fkey_command[2] = "run";
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
7-Zip Extra
|
7-Zip Extra
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
License for use and distribution
|
License for use and distribution
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Copyright (C) 1999-2019 Igor Pavlov.
|
Copyright (C) 1999-2019 Igor Pavlov.
|
||||||
|
|
||||||
7-Zip Extra files are under the GNU LGPL license.
|
7-Zip Extra files are under the GNU LGPL license.
|
||||||
|
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
You can use 7-Zip Extra on any computer, including a computer in a commercial
|
You can use 7-Zip Extra on any computer, including a computer in a commercial
|
||||||
organization. You don't need to register or pay for 7-Zip.
|
organization. You don't need to register or pay for 7-Zip.
|
||||||
|
|
||||||
|
|
||||||
GNU LGPL information
|
GNU LGPL information
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
This library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Lesser General Public License for more details.
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
You can receive a copy of the GNU Lesser General Public License from
|
You can receive a copy of the GNU Lesser General Public License from
|
||||||
http://www.gnu.org/
|
http://www.gnu.org/
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
;!@Install@!UTF-8!
|
;!@Install@!UTF-8!
|
||||||
Title="eco2d"
|
Title="eco2d"
|
||||||
RunProgram="eco2d.exe"
|
RunProgram="eco2d.exe"
|
||||||
;!@InstallEnd@!
|
;!@InstallEnd@!
|
Loading…
Reference in New Issue