adapt 2D view on window resolution changes

isolation_bkp/dynres
Dominik Madarász 2021-11-29 09:23:08 +01:00
parent cf173f3d50
commit 80fbb030bd
10 changed files with 18475 additions and 18471 deletions

34
.gitignore vendored
View File

@ -1,18 +1,18 @@
build
build_rel
screenshots
build.bat
run.bat
clean.bat
work
.vscode
.ds_store
GPATH
GRTAGS
GTAGS
/run_release.bat
/package.bat
pkg
pkg.zip
build
build_rel
screenshots
build.bat
run.bat
clean.bat
work
.vscode
.ds_store
GPATH
GRTAGS
GTAGS
/run_release.bat
/package.bat
pkg
pkg.zip
eco2d.zip

View File

@ -1,22 +1,22 @@
cmake_minimum_required(VERSION 3.0)
project(eco2d)
include(cmake/utils.cmake)
set(CMAKE_C_STANDARD 11)
set(CMAKE_RUNTIME_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_RELEASE ${CMAKE_BINARY_DIR})
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
include_directories(code/common code/vendors code/vendors/flecs)
include(cmake/FindRaylib.cmake)
add_subdirectory(code/modules)
add_subdirectory(code/vendors)
add_subdirectory(code/game)
cmake_minimum_required(VERSION 3.0)
project(eco2d)
include(cmake/utils.cmake)
set(CMAKE_C_STANDARD 11)
set(CMAKE_RUNTIME_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_RELEASE ${CMAKE_BINARY_DIR})
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
include_directories(code/common code/vendors code/vendors/flecs)
include(cmake/FindRaylib.cmake)
add_subdirectory(code/modules)
add_subdirectory(code/vendors)
add_subdirectory(code/game)

View File

@ -27,7 +27,7 @@ static bool request_shutdown;
void platform_init() {
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();
screenHeight = (uint16_t)GetScreenHeight();
@ -169,6 +169,9 @@ void platform_input() {
}
void platform_render() {
screenWidth = (uint16_t)GetScreenWidth();
screenHeight = (uint16_t)GetScreenHeight();
profile(PROF_ENTITY_LERP) {
game_world_view_active_entity_map(lerp_entity_positions);
game_world_view_active_entity_map(do_entity_fadeinout);

View File

@ -119,6 +119,7 @@ void DEBUG_draw_entities_low(uint64_t key, entity_view * data) {
}
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);
camera_update();

View File

@ -1,137 +1,137 @@
#include "flecs_os_api_stdcpp.h"
#include <thread>
#include <mutex>
#include <condition_variable>
#include "flecs/flecs.h"
#ifdef _WIN32
#include <Windows.h>
#endif
static
ecs_os_thread_t stdcpp_thread_new(
ecs_os_thread_callback_t callback,
void *arg)
{
std::thread *thread = new std::thread{callback,arg};
return reinterpret_cast<ecs_os_thread_t>(thread);
}
static
void* stdcpp_thread_join(
ecs_os_thread_t thread)
{
void *arg = nullptr;
std::thread *thr = reinterpret_cast<std::thread*>(thread);
thr->join();
delete thr;
return arg;
}
static
int32_t stdcpp_ainc(int32_t *count) {
int value;
#ifdef __GNUC__
value = __sync_add_and_fetch (count, 1);
return value;
#else
(void)value;
return InterlockedIncrement(reinterpret_cast<long*>(count));
#endif
}
static
int32_t stdcpp_adec(int32_t *count) {
int value;
#ifdef __GNUC__
value = __sync_sub_and_fetch (count, 1);
return value;
#else
(void)value;
return InterlockedDecrement(reinterpret_cast<long*>(count));
#endif
}
static
ecs_os_mutex_t stdcpp_mutex_new(void) {
std::mutex *mutex = new std::mutex;
return reinterpret_cast<ecs_os_mutex_t>(mutex);
}
static
void stdcpp_mutex_free(ecs_os_mutex_t m) {
std::mutex*mutex = reinterpret_cast<std::mutex*>(m);
delete mutex;
}
static
void stdcpp_mutex_lock(ecs_os_mutex_t m) {
std::mutex*mutex = reinterpret_cast<std::mutex*>(m);
mutex->lock();
}
static
void stdcpp_mutex_unlock(ecs_os_mutex_t m) {
std::mutex *mutex = reinterpret_cast<std::mutex*>(m);
mutex->unlock();
}
static
ecs_os_cond_t stdcpp_cond_new(void) {
std::condition_variable_any* cond = new std::condition_variable_any{};
return (ecs_os_cond_t)cond;
}
static
void stdcpp_cond_free(ecs_os_cond_t c) {
std::condition_variable_any *cond = reinterpret_cast<std::condition_variable_any*>(c);
delete cond;
}
static
void stdcpp_cond_signal(ecs_os_cond_t c) {
std::condition_variable_any *cond = reinterpret_cast<std::condition_variable_any*>(c);
cond->notify_one();
}
static
void stdcpp_cond_broadcast(ecs_os_cond_t c) {
std::condition_variable_any*cond = reinterpret_cast<std::condition_variable_any*>(c);
cond->notify_all();
}
static
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::mutex* mutex = reinterpret_cast<std::mutex*>(m);
cond->wait(*mutex);
}
#ifdef __cplusplus
extern "C" {
#endif
void stdcpp_set_os_api(void) {
ecs_os_set_api_defaults();
ecs_os_api_t api = ecs_os_api;
api.thread_new_ = stdcpp_thread_new;
api.thread_join_ = stdcpp_thread_join;
api.ainc_ = stdcpp_ainc;
api.adec_ = stdcpp_adec;
api.mutex_new_ = stdcpp_mutex_new;
api.mutex_free_ = stdcpp_mutex_free;
api.mutex_lock_ = stdcpp_mutex_lock;
api.mutex_unlock_ = stdcpp_mutex_unlock;
api.cond_new_ = stdcpp_cond_new;
api.cond_free_ = stdcpp_cond_free;
api.cond_signal_ = stdcpp_cond_signal;
api.cond_broadcast_ = stdcpp_cond_broadcast;
api.cond_wait_ = stdcpp_cond_wait;
ecs_os_set_api(&api);
}
#ifdef __cplusplus
}
#endif
#include "flecs_os_api_stdcpp.h"
#include <thread>
#include <mutex>
#include <condition_variable>
#include "flecs/flecs.h"
#ifdef _WIN32
#include <Windows.h>
#endif
static
ecs_os_thread_t stdcpp_thread_new(
ecs_os_thread_callback_t callback,
void *arg)
{
std::thread *thread = new std::thread{callback,arg};
return reinterpret_cast<ecs_os_thread_t>(thread);
}
static
void* stdcpp_thread_join(
ecs_os_thread_t thread)
{
void *arg = nullptr;
std::thread *thr = reinterpret_cast<std::thread*>(thread);
thr->join();
delete thr;
return arg;
}
static
int32_t stdcpp_ainc(int32_t *count) {
int value;
#ifdef __GNUC__
value = __sync_add_and_fetch (count, 1);
return value;
#else
(void)value;
return InterlockedIncrement(reinterpret_cast<long*>(count));
#endif
}
static
int32_t stdcpp_adec(int32_t *count) {
int value;
#ifdef __GNUC__
value = __sync_sub_and_fetch (count, 1);
return value;
#else
(void)value;
return InterlockedDecrement(reinterpret_cast<long*>(count));
#endif
}
static
ecs_os_mutex_t stdcpp_mutex_new(void) {
std::mutex *mutex = new std::mutex;
return reinterpret_cast<ecs_os_mutex_t>(mutex);
}
static
void stdcpp_mutex_free(ecs_os_mutex_t m) {
std::mutex*mutex = reinterpret_cast<std::mutex*>(m);
delete mutex;
}
static
void stdcpp_mutex_lock(ecs_os_mutex_t m) {
std::mutex*mutex = reinterpret_cast<std::mutex*>(m);
mutex->lock();
}
static
void stdcpp_mutex_unlock(ecs_os_mutex_t m) {
std::mutex *mutex = reinterpret_cast<std::mutex*>(m);
mutex->unlock();
}
static
ecs_os_cond_t stdcpp_cond_new(void) {
std::condition_variable_any* cond = new std::condition_variable_any{};
return (ecs_os_cond_t)cond;
}
static
void stdcpp_cond_free(ecs_os_cond_t c) {
std::condition_variable_any *cond = reinterpret_cast<std::condition_variable_any*>(c);
delete cond;
}
static
void stdcpp_cond_signal(ecs_os_cond_t c) {
std::condition_variable_any *cond = reinterpret_cast<std::condition_variable_any*>(c);
cond->notify_one();
}
static
void stdcpp_cond_broadcast(ecs_os_cond_t c) {
std::condition_variable_any*cond = reinterpret_cast<std::condition_variable_any*>(c);
cond->notify_all();
}
static
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::mutex* mutex = reinterpret_cast<std::mutex*>(m);
cond->wait(*mutex);
}
#ifdef __cplusplus
extern "C" {
#endif
void stdcpp_set_os_api(void) {
ecs_os_set_api_defaults();
ecs_os_api_t api = ecs_os_api;
api.thread_new_ = stdcpp_thread_new;
api.thread_join_ = stdcpp_thread_join;
api.ainc_ = stdcpp_ainc;
api.adec_ = stdcpp_adec;
api.mutex_new_ = stdcpp_mutex_new;
api.mutex_free_ = stdcpp_mutex_free;
api.mutex_lock_ = stdcpp_mutex_lock;
api.mutex_unlock_ = stdcpp_mutex_unlock;
api.cond_new_ = stdcpp_cond_new;
api.cond_free_ = stdcpp_cond_free;
api.cond_signal_ = stdcpp_cond_signal;
api.cond_broadcast_ = stdcpp_cond_broadcast;
api.cond_wait_ = stdcpp_cond_wait;
ecs_os_set_api(&api);
}
#ifdef __cplusplus
}
#endif

View File

@ -1,14 +1,14 @@
#ifndef FLECS_OS_API_STDCPP_H
#define FLECS_OS_API_STDCPP_H
#ifdef __cplusplus
extern "C" {
#endif
extern void stdcpp_set_os_api(void);
#ifdef __cplusplus
}
#endif
#ifndef FLECS_OS_API_STDCPP_H
#define FLECS_OS_API_STDCPP_H
#ifdef __cplusplus
extern "C" {
#endif
extern void stdcpp_set_os_api(void);
#ifdef __cplusplus
}
#endif
#endif

36354
code/vendors/zpl.h vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,70 +1,70 @@
version(1);
project_name = "eco2d";
patterns =
{
"*.c",
"*.cpp",
"*.jai",
"*.odin",
"*.zig",
"*.h",
"*.inc",
"*.bat",
"*.sh",
"*.4coder",
"*.txt",
"*.cmake",
"*.md",
};
blacklist_patterns =
{
".*",
};
load_paths =
{
{{
{ ".", .recursive = false, .relative = true },
{ "code/game", .recursive = true, .relative = true },
{ "code/common", .recursive = true, .relative = true },
{ "code/modules", .recursive = true, .relative = true },
{ "code/vendors", .recursive = true, .relative = true },
{ "cmake", .recursive = true, .relative = true },
{ "build/_deps/raylib-src/src", .recursive = true, .relative = true }
}, .os = "win"}
};
command_list =
{
{
.name = "build",
.out = "*compilation*",
.footer_panel = true,
.save_dirty_files = true,
.cursor_at_end = false,
.cmd =
{
{ "cmake --build build", .os = "win" },
},
},
{
.name = "run",
.out = "*console*",
.footer_panel = false,
.save_dirty_files = true,
.cursor_at_end = true,
.cmd =
{
{ "run.bat", .os = "win" },
},
},
};
fkey_command[1] = "build";
fkey_command[2] = "run";
version(1);
project_name = "eco2d";
patterns =
{
"*.c",
"*.cpp",
"*.jai",
"*.odin",
"*.zig",
"*.h",
"*.inc",
"*.bat",
"*.sh",
"*.4coder",
"*.txt",
"*.cmake",
"*.md",
};
blacklist_patterns =
{
".*",
};
load_paths =
{
{{
{ ".", .recursive = false, .relative = true },
{ "code/game", .recursive = true, .relative = true },
{ "code/common", .recursive = true, .relative = true },
{ "code/modules", .recursive = true, .relative = true },
{ "code/vendors", .recursive = true, .relative = true },
{ "cmake", .recursive = true, .relative = true },
{ "build/_deps/raylib-src/src", .recursive = true, .relative = true }
}, .os = "win"}
};
command_list =
{
{
.name = "build",
.out = "*compilation*",
.footer_panel = true,
.save_dirty_files = true,
.cursor_at_end = false,
.cmd =
{
{ "cmake --build build", .os = "win" },
},
},
{
.name = "run",
.out = "*console*",
.footer_panel = false,
.save_dirty_files = true,
.cursor_at_end = true,
.cmd =
{
{ "run.bat", .os = "win" },
},
},
};
fkey_command[1] = "build";
fkey_command[2] = "run";

View File

@ -1,31 +1,31 @@
7-Zip Extra
~~~~~~~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copyright (C) 1999-2019 Igor Pavlov.
7-Zip Extra files are under the GNU LGPL license.
Notes:
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.
GNU LGPL information
--------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
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,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/
7-Zip Extra
~~~~~~~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copyright (C) 1999-2019 Igor Pavlov.
7-Zip Extra files are under the GNU LGPL license.
Notes:
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.
GNU LGPL information
--------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
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,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/

View File

@ -1,4 +1,4 @@
;!@Install@!UTF-8!
Title="eco2d"
RunProgram="eco2d.exe"
;!@Install@!UTF-8!
Title="eco2d"
RunProgram="eco2d.exe"
;!@InstallEnd@!