mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-10 16:03:15 -04:00
Fix isometric rendered blocks being slightly misaligned on OpenGL/Direct3D 11 (Thanks 123DMWM), fix sometimes not compiling on recent macOS due to CGDisplayBitsPerPixel no longer being defined
This commit is contained in:
parent
d453eb3d97
commit
cca8ff64a3
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -126,8 +126,6 @@ jobs:
|
|||||||
if: matrix.config.plat == 'Mac' && matrix.config.bits == 64
|
if: matrix.config.plat == 'Mac' && matrix.config.bits == 64
|
||||||
run: |
|
run: |
|
||||||
cd src
|
cd src
|
||||||
# fix for "error: implicit declaration of function 'CGDisplayBitsPerPixel'"
|
|
||||||
sed -i '' 's|#include <Cocoa/Cocoa.h>|&\'$'\nextern size_t CGDisplayBitsPerPixel(CGDirectDisplayID display);|' interop_cocoa.m
|
|
||||||
make mac_x64
|
make mac_x64
|
||||||
|
|
||||||
- name: Build for ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit)
|
- name: Build for ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit)
|
||||||
|
@ -6,35 +6,41 @@ TODO introduction (explaining platform specific modules, and how classicube has
|
|||||||
|
|
||||||
Two ways
|
Two ways
|
||||||
1) Changing the defines in `Core.h`
|
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. <br>
|
||||||
|
For automated scripts compiling every single commit, 2) is the recommended approach
|
||||||
|
|
||||||
|
|
||||||
|
### 3D Graphics backends
|
||||||
* CC_BUILD_D3D9 - Direct3D 9
|
* CC_BUILD_D3D9 - Direct3D 9
|
||||||
* CC_BUILD_D3D11 - Direct3D 11
|
* CC_BUILD_D3D11 - Direct3D 11
|
||||||
* CC_BUILD_GL - OpenGL
|
* 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_GLMODERN - (must also have CC_BUILD_GL defined)
|
||||||
* CC_BUILD_GLES (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_EGL
|
||||||
* CC_BUILD_WGL
|
* CC_BUILD_WGL
|
||||||
|
|
||||||
HTTP backends
|
### HTTP backends
|
||||||
* CC_BUILD_CURL
|
* CC_BUILD_CURL
|
||||||
* CC_BUILD_HTTPCLIENT - custom HTTP client
|
* CC_BUILD_HTTPCLIENT - custom HTTP client
|
||||||
* CC_BUILD_WININET
|
* CC_BUILD_WININET
|
||||||
* CC_BUILD_CFNETWORK
|
* CC_BUILD_CFNETWORK
|
||||||
|
|
||||||
SSL backends
|
### SSL backends
|
||||||
* CC_BUILD_SCHANNEL
|
* CC_BUILD_SCHANNEL
|
||||||
|
|
||||||
Window backends
|
### Window backends
|
||||||
* CC_BUILD_SDL
|
* CC_BUILD_SDL
|
||||||
* CC_BUILD_X11
|
* CC_BUILD_X11
|
||||||
* CC_BUILD_WINGUI
|
* CC_BUILD_WINGUI
|
||||||
|
|
||||||
Platform backends
|
### Platform backends
|
||||||
* CC_BUILD_POSIX
|
* CC_BUILD_POSIX
|
||||||
* CC_BUILD_WIN
|
* CC_BUILD_WIN
|
||||||
|
|
||||||
|
@ -128,10 +128,12 @@ void IsometricDrawer_AddBatch(BlockID block, float size, float x, float y) {
|
|||||||
struct VertexTextured* beg = iso_vertices;
|
struct VertexTextured* beg = iso_vertices;
|
||||||
if (Blocks.Draw[block] == DRAW_GAS) return;
|
if (Blocks.Draw[block] == DRAW_GAS) return;
|
||||||
|
|
||||||
/* See comment in GfxCommon_Draw2DTexture() for why 0.5 is subtracted */
|
iso_posX = x; iso_posY = y;
|
||||||
/* TODO only for Direct3D 9?? pass in registers? */
|
/* See comment in Gfx_Make2DQuad() for why 0.5 is subtracted in D3D9 */
|
||||||
iso_posX = x - 0.5f;
|
/* TODO pass as arguments? test diff */
|
||||||
iso_posY = y - 0.5f;
|
#ifdef CC_BUILD_D3D9
|
||||||
|
iso_posX -= 0.5f; iso_posY -= 0.5f;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (Blocks.Draw[block] == DRAW_SPRITE) {
|
if (Blocks.Draw[block] == DRAW_SPRITE) {
|
||||||
IsometricDrawer_Flat(block, size);
|
IsometricDrawer_Flat(block, size);
|
||||||
|
@ -9,10 +9,10 @@ struct VertexTextured;
|
|||||||
/* Maximum number of vertices used to draw a block in isometric way. */
|
/* Maximum number of vertices used to draw a block in isometric way. */
|
||||||
#define ISOMETRICDRAWER_MAXVERTICES 12
|
#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);
|
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);
|
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);
|
void IsometricDrawer_EndBatch(GfxResourceID vb);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1461,6 +1461,7 @@ static void InventoryScreen_UpdateTitle(struct InventoryScreen* s, BlockID block
|
|||||||
String_InitArray(desc, descBuffer);
|
String_InitArray(desc, descBuffer);
|
||||||
InventoryScreen_GetTitleText(&desc, block);
|
InventoryScreen_GetTitleText(&desc, block);
|
||||||
TextWidget_Set(&s->title, &desc, &s->font);
|
TextWidget_Set(&s->title, &desc, &s->font);
|
||||||
|
s->dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InventoryScreen_OnUpdateTitle(BlockID block) {
|
static void InventoryScreen_OnUpdateTitle(BlockID block) {
|
||||||
@ -1475,6 +1476,9 @@ static void InventoryScreen_OnBlockChanged(void* screen) {
|
|||||||
|
|
||||||
static void InventoryScreen_ContextLost(void* screen) {
|
static void InventoryScreen_ContextLost(void* screen) {
|
||||||
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
||||||
|
Gfx_DeleteDynamicVb(&s->vb);
|
||||||
|
s->table.vb = 0;
|
||||||
|
|
||||||
Font_Free(&s->font);
|
Font_Free(&s->font);
|
||||||
Elem_Free(&s->table);
|
Elem_Free(&s->table);
|
||||||
Elem_Free(&s->title);
|
Elem_Free(&s->title);
|
||||||
@ -1482,11 +1486,15 @@ static void InventoryScreen_ContextLost(void* screen) {
|
|||||||
|
|
||||||
static void InventoryScreen_ContextRecreated(void* screen) {
|
static void InventoryScreen_ContextRecreated(void* screen) {
|
||||||
struct InventoryScreen* s = (struct InventoryScreen*)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);
|
Gui_MakeBodyFont(&s->font);
|
||||||
TableWidget_Recreate(&s->table);
|
TableWidget_Recreate(&s->table);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InventoryScreen_BuildMesh(void* screen) { }
|
static void InventoryScreen_BuildMesh(void* screen) {
|
||||||
|
}
|
||||||
|
|
||||||
static void InventoryScreen_MoveToSelected(struct InventoryScreen* s) {
|
static void InventoryScreen_MoveToSelected(struct InventoryScreen* s) {
|
||||||
struct TableWidget* table = &s->table;
|
struct TableWidget* table = &s->table;
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
#include "ExtMath.h"
|
#include "ExtMath.h"
|
||||||
#include "Funcs.h"
|
#include "Funcs.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "Inventory.h"
|
|
||||||
#include "IsometricDrawer.h"
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
#include "Screens.h"
|
#include "Screens.h"
|
||||||
@ -639,8 +637,6 @@ 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; }
|
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) {
|
static cc_bool TableWidget_GetCoords(struct TableWidget* w, int i, int* cellX, int* cellY) {
|
||||||
int x, y;
|
int x, y;
|
||||||
x = i % w->blocksPerRow;
|
x = i % w->blocksPerRow;
|
||||||
@ -756,15 +752,10 @@ static void TableWidget_Render(void* widget, double delta) {
|
|||||||
IsometricDrawer_EndBatch(w->vb);
|
IsometricDrawer_EndBatch(w->vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TableWidget_Free(void* widget) {
|
static void TableWidget_Free(void* widget) { }
|
||||||
struct TableWidget* w = (struct TableWidget*)widget;
|
|
||||||
Gfx_DeleteDynamicVb(&w->vb);
|
|
||||||
w->lastCreatedIndex = -1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TableWidget_Recreate(struct TableWidget* w) {
|
void TableWidget_Recreate(struct TableWidget* w) {
|
||||||
Elem_Free(w);
|
w->lastCreatedIndex = -1000;
|
||||||
Gfx_RecreateDynamicVb(&w->vb, VERTEX_FORMAT_TEXTURED, TABLE_MAX_VERTICES);
|
|
||||||
TableWidget_RecreateTitle(w);
|
TableWidget_RecreateTitle(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "Inventory.h"
|
#include "Inventory.h"
|
||||||
|
#include "IsometricDrawer.h"
|
||||||
/* Contains all 2D widget implementations.
|
/* Contains all 2D widget implementations.
|
||||||
Copyright 2014-2022 ClassiCube | Licensed under BSD-3
|
Copyright 2014-2022 ClassiCube | Licensed under BSD-3
|
||||||
*/
|
*/
|
||||||
@ -99,6 +100,7 @@ struct TableWidget {
|
|||||||
int paddingL, paddingR, paddingT, paddingB;
|
int paddingL, paddingR, paddingT, paddingB;
|
||||||
void (*UpdateTitle)(BlockID block);
|
void (*UpdateTitle)(BlockID block);
|
||||||
};
|
};
|
||||||
|
#define TABLE_MAX_VERTICES (8 * 10 * ISOMETRICDRAWER_MAXVERTICES)
|
||||||
|
|
||||||
CC_NOINLINE void TableWidget_Create(struct TableWidget* w);
|
CC_NOINLINE void TableWidget_Create(struct TableWidget* w);
|
||||||
/* Sets the selected block in the table to the given block. */
|
/* Sets the selected block in the table to the given block. */
|
||||||
|
@ -18,6 +18,9 @@ static cc_bool scroll_debugging;
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------Shared with Carbon----------------------------------------------------*
|
*---------------------------------------------------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
|
// NOTE: If code here is changed, don't forget to update corresponding code in Window_Carbon.c
|
||||||
static void Window_CommonInit(void) {
|
static void Window_CommonInit(void) {
|
||||||
CGDirectDisplayID display = CGMainDisplayID();
|
CGDirectDisplayID display = CGMainDisplayID();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user