make texed resizable

isolation_bkp/dynres
Dominik Madarász 2021-05-15 20:00:57 +02:00
parent 5863d6c746
commit 7090a8601d
4 changed files with 1187 additions and 718 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

@ -19,6 +19,9 @@
static uint16_t screenWidth = 1280;
static uint16_t screenHeight = 720;
static float zoom = 4.0f;
static Texture2D checker_tex;
static uint16_t old_screen_w;
static uint16_t old_screen_h;
#define TD_DEFAULT_IMG_WIDTH 64
#define TD_DEFAULT_IMG_HEIGHT 64
@ -128,15 +131,17 @@ Rectangle aabb2_ray(zpl_aabb2 r) {
void texed_run(void) {
InitWindow(screenWidth, screenHeight, "eco2d - texture editor");
SetWindowState(FLAG_WINDOW_RESIZABLE);
SetTargetFPS(60);
texed_new(TD_DEFAULT_IMG_WIDTH, TD_DEFAULT_IMG_HEIGHT);
GuiSetStyle(TEXTBOX, TEXT_COLOR_NORMAL, ColorToInt(RAYWHITE));
while (!WindowShouldClose()) {
zpl_aabb2 screen = {
.min = (zpl_vec2) {.x = 0.0f, .y = 0.0f},
.max = (zpl_vec2) {.x = screenWidth, .y = screenHeight},
.max = (zpl_vec2) {.x = GetScreenWidth(), .y = GetScreenHeight()},
};
zpl_aabb2 topbar = zpl_aabb2_cut_top(&screen, 25.0f);
@ -150,11 +155,15 @@ void texed_run(void) {
property_pane = zpl_aabb2_contract(&property_pane, TD_UI_PADDING);
Rectangle preview_rect = aabb2_ray(preview_window);
Image checkerboard = GenImageChecked(preview_rect.width, preview_rect.height, 16, 16, BLACK, ColorAlpha(GRAY, 0.2f));
Texture2D checker_tex = LoadTextureFromImage(checkerboard);
UnloadImage(checkerboard);
while (!WindowShouldClose()) {
if (old_screen_w != GetScreenWidth() || old_screen_h != GetScreenHeight()) {
old_screen_w = GetScreenWidth();
old_screen_h = GetScreenHeight();
Image checkerboard = GenImageChecked(preview_rect.width, preview_rect.height, 16, 16, BLACK, ColorAlpha(GRAY, 0.2f));
checker_tex = LoadTextureFromImage(checkerboard);
UnloadImage(checkerboard);
}
BeginDrawing();
ClearBackground(GetColor(0x222034));
{