diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1668d6ebb..bad97ac30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -126,8 +126,6 @@ jobs: if: matrix.config.plat == 'Mac' && matrix.config.bits == 64 run: | cd src - # fix for "error: implicit declaration of function 'CGDisplayBitsPerPixel'" - sed -i '' 's|#include |&\'$'\nextern size_t CGDisplayBitsPerPixel(CGDirectDisplayID display);|' interop_cocoa.m make mac_x64 - name: Build for ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) diff --git a/doc/overriding-defaults.md b/doc/overriding-defaults.md index b50808d21..9021267da 100644 --- a/doc/overriding-defaults.md +++ b/doc/overriding-defaults.md @@ -6,35 +6,41 @@ TODO introduction (explaining platform specific modules, and how classicube has Two ways 1) Changing the defines in `Core.h` -2) Adding `-DCC_BUILD_MANUAL` to compilation flags and manually defining module backends +2) Adding `-DCC_BUILD_MANUAL` to compilation flags and then manually defining module backends via additional compilation flags -Graphics backends +When manually compiling the source code, 1) is usually the easiest.
+For automated scripts compiling every single commit, 2) is the recommended approach + + +### 3D Graphics backends * CC_BUILD_D3D9 - Direct3D 9 * CC_BUILD_D3D11 - Direct3D 11 * CC_BUILD_GL - OpenGL + +The OpenGL backend can be further customised: +* CC_BUILD_GL11 - (must also have CC_BUILD_GL defined) * CC_BUILD_GLMODERN - (must also have CC_BUILD_GL defined) * CC_BUILD_GLES (must also have CC_BUILD_GL defined) -* CC_BUILD_GL11 - (must also have CC_BUILD_GL defined) -OpenGL context backends +### OpenGL context backends * CC_BUILD_EGL * CC_BUILD_WGL -HTTP backends +### HTTP backends * CC_BUILD_CURL * CC_BUILD_HTTPCLIENT - custom HTTP client * CC_BUILD_WININET * CC_BUILD_CFNETWORK -SSL backends +### SSL backends * CC_BUILD_SCHANNEL -Window backends +### Window backends * CC_BUILD_SDL * CC_BUILD_X11 * CC_BUILD_WINGUI -Platform backends +### Platform backends * CC_BUILD_POSIX * CC_BUILD_WIN diff --git a/src/IsometricDrawer.c b/src/IsometricDrawer.c index af77751fb..f070f9ddf 100644 --- a/src/IsometricDrawer.c +++ b/src/IsometricDrawer.c @@ -127,11 +127,13 @@ void IsometricDrawer_BeginBatch(struct VertexTextured* vertices, int* state) { void IsometricDrawer_AddBatch(BlockID block, float size, float x, float y) { struct VertexTextured* beg = iso_vertices; if (Blocks.Draw[block] == DRAW_GAS) return; - - /* See comment in GfxCommon_Draw2DTexture() for why 0.5 is subtracted */ - /* TODO only for Direct3D 9?? pass in registers? */ - iso_posX = x - 0.5f; - iso_posY = y - 0.5f; + + iso_posX = x; iso_posY = y; + /* See comment in Gfx_Make2DQuad() for why 0.5 is subtracted in D3D9 */ + /* TODO pass as arguments? test diff */ +#ifdef CC_BUILD_D3D9 + iso_posX -= 0.5f; iso_posY -= 0.5f; +#endif if (Blocks.Draw[block] == DRAW_SPRITE) { IsometricDrawer_Flat(block, size); diff --git a/src/IsometricDrawer.h b/src/IsometricDrawer.h index de97baadd..8f5cf04c6 100644 --- a/src/IsometricDrawer.h +++ b/src/IsometricDrawer.h @@ -9,10 +9,10 @@ struct VertexTextured; /* Maximum number of vertices used to draw a block in isometric way. */ #define ISOMETRICDRAWER_MAXVERTICES 12 -/* Sets up state to begin drawing blocks isometrically. */ +/* Sets up state to begin drawing blocks isometrically */ void IsometricDrawer_BeginBatch(struct VertexTextured* vertices, int* state); -/* Buffers the vertices needed to draw the given block at the given position. */ +/* Buffers the vertices needed to draw the given block at the given position */ void IsometricDrawer_AddBatch(BlockID block, float size, float x, float y); -/* Flushes buffered vertices to the GPU, then restores state. */ +/* Flushes buffered vertices to the GPU */ void IsometricDrawer_EndBatch(GfxResourceID vb); #endif diff --git a/src/Screens.c b/src/Screens.c index b15c92f1b..c96ca9957 100644 --- a/src/Screens.c +++ b/src/Screens.c @@ -1461,6 +1461,7 @@ static void InventoryScreen_UpdateTitle(struct InventoryScreen* s, BlockID block String_InitArray(desc, descBuffer); InventoryScreen_GetTitleText(&desc, block); TextWidget_Set(&s->title, &desc, &s->font); + s->dirty = true; } static void InventoryScreen_OnUpdateTitle(BlockID block) { @@ -1475,6 +1476,9 @@ static void InventoryScreen_OnBlockChanged(void* screen) { static void InventoryScreen_ContextLost(void* screen) { struct InventoryScreen* s = (struct InventoryScreen*)screen; + Gfx_DeleteDynamicVb(&s->vb); + s->table.vb = 0; + Font_Free(&s->font); Elem_Free(&s->table); Elem_Free(&s->title); @@ -1482,11 +1486,15 @@ static void InventoryScreen_ContextLost(void* screen) { static void InventoryScreen_ContextRecreated(void* screen) { struct InventoryScreen* s = (struct InventoryScreen*)screen; + Gfx_RecreateDynamicVb(&s->vb, VERTEX_FORMAT_TEXTURED, TEXTWIDGET_MAX + TABLE_MAX_VERTICES); + s->table.vb = s->vb; + Gui_MakeBodyFont(&s->font); TableWidget_Recreate(&s->table); } -static void InventoryScreen_BuildMesh(void* screen) { } +static void InventoryScreen_BuildMesh(void* screen) { +} static void InventoryScreen_MoveToSelected(struct InventoryScreen* s) { struct TableWidget* table = &s->table; diff --git a/src/Widgets.c b/src/Widgets.c index 65e6c1291..07a73c0a8 100644 --- a/src/Widgets.c +++ b/src/Widgets.c @@ -4,8 +4,6 @@ #include "ExtMath.h" #include "Funcs.h" #include "Window.h" -#include "Inventory.h" -#include "IsometricDrawer.h" #include "Utils.h" #include "Model.h" #include "Screens.h" @@ -636,11 +634,9 @@ void HotbarWidget_SetFont(struct HotbarWidget* w, struct FontDesc* font) { *#########################################################################################################################*/ static int Table_X(struct TableWidget* w) { return w->x - w->paddingL; } static int Table_Y(struct TableWidget* w) { return w->y - w->paddingT; } -static int Table_Width(struct TableWidget* w) { return w->width + w->paddingL + w->paddingR; } +static int Table_Width(struct TableWidget* w) { return w->width + w->paddingL + w->paddingR; } static int Table_Height(struct TableWidget* w) { return w->height + w->paddingT + w->paddingB; } -#define TABLE_MAX_VERTICES (8 * 10 * ISOMETRICDRAWER_MAXVERTICES) - static cc_bool TableWidget_GetCoords(struct TableWidget* w, int i, int* cellX, int* cellY) { int x, y; x = i % w->blocksPerRow; @@ -756,15 +752,10 @@ static void TableWidget_Render(void* widget, double delta) { IsometricDrawer_EndBatch(w->vb); } -static void TableWidget_Free(void* widget) { - struct TableWidget* w = (struct TableWidget*)widget; - Gfx_DeleteDynamicVb(&w->vb); - w->lastCreatedIndex = -1000; -} +static void TableWidget_Free(void* widget) { } void TableWidget_Recreate(struct TableWidget* w) { - Elem_Free(w); - Gfx_RecreateDynamicVb(&w->vb, VERTEX_FORMAT_TEXTURED, TABLE_MAX_VERTICES); + w->lastCreatedIndex = -1000; TableWidget_RecreateTitle(w); } diff --git a/src/Widgets.h b/src/Widgets.h index dfa980e20..89c33f2f2 100644 --- a/src/Widgets.h +++ b/src/Widgets.h @@ -5,6 +5,7 @@ #include "Constants.h" #include "Entity.h" #include "Inventory.h" +#include "IsometricDrawer.h" /* Contains all 2D widget implementations. Copyright 2014-2022 ClassiCube | Licensed under BSD-3 */ @@ -99,6 +100,7 @@ struct TableWidget { int paddingL, paddingR, paddingT, paddingB; void (*UpdateTitle)(BlockID block); }; +#define TABLE_MAX_VERTICES (8 * 10 * ISOMETRICDRAWER_MAXVERTICES) CC_NOINLINE void TableWidget_Create(struct TableWidget* w); /* Sets the selected block in the table to the given block. */ diff --git a/src/interop_cocoa.m b/src/interop_cocoa.m index 33208842b..831bcae93 100644 --- a/src/interop_cocoa.m +++ b/src/interop_cocoa.m @@ -18,6 +18,9 @@ static cc_bool scroll_debugging; /*########################################################################################################################* *---------------------------------------------------Shared with Carbon----------------------------------------------------* *#########################################################################################################################*/ +extern size_t CGDisplayBitsPerPixel(CGDirectDisplayID display); +// TODO: Try NSBitsPerPixelFromDepth([NSScreen mainScreen].depth) instead + // NOTE: If code here is changed, don't forget to update corresponding code in Window_Carbon.c static void Window_CommonInit(void) { CGDirectDisplayID display = CGMainDisplayID();