Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
luboslenco committed Feb 15, 2025
1 parent 8c61bf2 commit 984b234
Show file tree
Hide file tree
Showing 53 changed files with 736 additions and 964 deletions.
20 changes: 9 additions & 11 deletions armorcore/sources/backends/android/kinc/backend/system.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static bool activityJustResized = false;
#include <vulkan/vulkan_android.h>
#include <vulkan/vulkan_core.h>

VkResult kinc_vulkan_create_surface(VkInstance instance, int window_index, VkSurfaceKHR *surface) {
VkResult kinc_vulkan_create_surface(VkInstance instance, VkSurfaceKHR *surface) {
assert(app->window != NULL);
VkAndroidSurfaceCreateInfoKHR createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
Expand All @@ -66,7 +66,7 @@ VkBool32 kinc_vulkan_get_physical_device_presentation_support(VkPhysicalDevice p
return true;
}

void kinc_vulkan_init_window(int window);
void kinc_vulkan_init_window();

static void initDisplay() {
kinc_vulkan_init_window(0);
Expand Down Expand Up @@ -981,7 +981,7 @@ double kinc_time() {
return (double)(now.tv_sec - start_sec) + (now.tv_usec / 1000000.0);
}

void kinc_internal_resize(int window, int width, int height);
void kinc_internal_resize(int width, int height);

bool kinc_internal_handle_messages(void) {
kinc_mutex_lock(&unicode_mutex);
Expand Down Expand Up @@ -1028,7 +1028,7 @@ bool kinc_internal_handle_messages(void) {
#ifdef KINC_VULKAN
kinc_internal_resize(0, width, height);
#endif
kinc_internal_call_resize_callback(0, width, height);
kinc_internal_call_resize_callback(width, height);
}

// Get screen rotation
Expand All @@ -1052,13 +1052,13 @@ void kinc_mouse_show() {}

void kinc_mouse_hide() {}

void kinc_mouse_set_position(int window, int x, int y) {}
void kinc_mouse_set_position(int x, int y) {}

void kinc_internal_mouse_lock(int window) {}
void kinc_internal_mouse_lock() {}

void kinc_internal_mouse_unlock(void) {}

void kinc_mouse_get_position(int window, int *x, int *y) {
void kinc_mouse_get_position(int *x, int *y) {
x = 0;
y = 0;
}
Expand Down Expand Up @@ -1114,7 +1114,7 @@ void android_main(struct android_app *application) {
(*activity->vm)->DetachCurrentThread(activity->vm);
}

int kinc_init(const char *name, int width, int height, struct kinc_window_options *win, struct kinc_framebuffer_options *frame) {
void kinc_init(const char *name, int width, int height, struct kinc_window_options *win, struct kinc_framebuffer_options *frame) {
kinc_mutex_init(&unicode_mutex);

kinc_window_options_t default_win;
Expand All @@ -1132,11 +1132,9 @@ int kinc_init(const char *name, int width, int height, struct kinc_window_option
}

kinc_g4_internal_init();
kinc_g4_internal_init_window(0, frame->depth_bits, true);
kinc_g4_internal_init_window(frame->depth_bits, true);

kinc_internal_gamepad_trigger_connect(0);

return 0;
}

void kinc_internal_shutdown(void) {
Expand Down
46 changes: 18 additions & 28 deletions armorcore/sources/backends/android/kinc/backend/window.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,73 +5,63 @@
static void (*resizeCallback)(int x, int y, void *data) = NULL;
static void *resizeCallbackData = NULL;

int kinc_count_windows(void) {
return 1;
}

int kinc_window_x(int window_index) {
int kinc_window_x() {
return 0;
}

int kinc_window_y(int window_index) {
int kinc_window_y() {
return 0;
}

int kinc_android_width();

int kinc_window_width(int window_index) {
int kinc_window_width() {
return kinc_android_width();
}

int kinc_android_height();

int kinc_window_height(int window_index) {
int kinc_window_height() {
return kinc_android_height();
}

void kinc_window_resize(int window_index, int width, int height) {}
void kinc_window_resize(int width, int height) {}

void kinc_window_move(int window_index, int x, int y) {}
void kinc_window_move(int x, int y) {}

void kinc_internal_change_framebuffer(int window, struct kinc_framebuffer_options *frame);
void kinc_window_change_features(int features) {}

void kinc_window_change_framebuffer(int window_index, kinc_framebuffer_options_t *frame) {
kinc_internal_change_framebuffer(0, frame);
}
void kinc_window_change_mode(kinc_window_mode_t mode) {}

void kinc_window_change_features(int window_index, int features) {}
void kinc_window_destroy() {}

void kinc_window_change_mode(int window_index, kinc_window_mode_t mode) {}
void kinc_window_show() {}

void kinc_window_destroy(int window_index) {}
void kinc_window_hide() {}

void kinc_window_show(int window_index) {}
void kinc_window_set_title(const char *title) {}

void kinc_window_hide(int window_index) {}
void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {

void kinc_window_set_title(int window_index, const char *title) {}

int kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {
return 0;
}

void kinc_window_set_resize_callback(int window_index, void (*callback)(int x, int y, void *data), void *data) {
void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) {
resizeCallback = callback;
resizeCallbackData = data;
}

void kinc_internal_call_resize_callback(int window_index, int width, int height) {
void kinc_internal_call_resize_callback(int width, int height) {
if (resizeCallback != NULL) {
resizeCallback(width, height, resizeCallbackData);
}
}

void kinc_window_set_close_callback(int window, bool (*callback)(void *), void *data) {}
void kinc_window_set_close_callback(bool (*callback)(void *), void *data) {}

kinc_window_mode_t kinc_window_get_mode(int window_index) {
kinc_window_mode_t kinc_window_get_mode() {
return KINC_WINDOW_MODE_FULLSCREEN;
}

int kinc_window_display(int window) {
int kinc_window_display() {
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ void kinc_g5_command_list_disable_scissor(struct kinc_g5_command_list *list) {
D3D12_RECT scissor;
scissor.left = 0;
scissor.top = 0;
scissor.right = kinc_window_width(0);
scissor.bottom = kinc_window_height(0);
scissor.right = kinc_window_width();
scissor.bottom = kinc_window_height();
list->impl._commandList->lpVtbl->RSSetScissorRects(list->impl._commandList, 1, &scissor);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ struct dx_window {
int new_height;
int current_backbuffer;
bool vsync;
int window_index;
};
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,13 @@ static ID3D12RootSignature *globalComputeRootSignature = NULL;
#define MAXIMUM_WINDOWS 16

struct dx_ctx {
int current_window;
struct dx_window windows[MAXIMUM_WINDOWS];
};

static struct dx_ctx dx_ctx = {0};

inline struct dx_window *kinc_dx_current_window() {
return &dx_ctx.windows[dx_ctx.current_window];
return &dx_ctx.windows[0];
}

static bool compute_pipeline_set = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static void createDeviceAndSwapChain(struct dx_window *window) {
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferDesc.Width = window->width;
swapChainDesc.BufferDesc.Height = window->height;
swapChainDesc.OutputWindow = kinc_windows_window_handle(window->window_index);
swapChainDesc.OutputWindow = kinc_windows_window_handle();
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
swapChainDesc.Windowed = true;
Expand Down Expand Up @@ -324,17 +324,17 @@ static void shutdown() {
}
}

static void initWindow(struct dx_window *window, int windowIndex) {
HWND hwnd = kinc_windows_window_handle(windowIndex);
static void initWindow(struct dx_window *window) {
HWND hwnd = kinc_windows_window_handle();

DXGI_SWAP_CHAIN_DESC swapChainDesc;
ZeroMemory(&swapChainDesc, sizeof(swapChainDesc));

swapChainDesc.BufferCount = QUEUE_SLOT_COUNT;
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferDesc.Width = kinc_window_width(windowIndex);
swapChainDesc.BufferDesc.Height = kinc_window_height(windowIndex);
swapChainDesc.BufferDesc.Width = kinc_window_width();
swapChainDesc.BufferDesc.Height = kinc_window_height();
swapChainDesc.OutputWindow = hwnd;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
Expand All @@ -348,7 +348,7 @@ static void initWindow(struct dx_window *window, int windowIndex) {
setupSwapChain(window);
}

void kinc_g5_internal_destroy_window(int window) {}
void kinc_g5_internal_destroy_window() {}

void kinc_g5_internal_destroy() {
if (device) {
Expand Down Expand Up @@ -396,13 +396,12 @@ void kinc_g5_internal_init() {
CloseHandle(waitEvent);
}

void kinc_g5_internal_init_window(int windowIndex, int depthBufferBits, bool verticalSync) {
struct dx_window *window = &dx_ctx.windows[windowIndex];
window->window_index = windowIndex;
void kinc_g5_internal_init_window(int depthBufferBits, bool verticalSync) {
struct dx_window *window = &dx_ctx.windows[0];
window->vsync = verticalSync;
window->width = window->new_width = kinc_window_width(windowIndex);
window->height = window->new_height = kinc_window_height(windowIndex);
initWindow(window, windowIndex);
window->width = window->new_width = kinc_window_width();
window->height = window->new_height = kinc_window_height();
initWindow(window);
}

int kinc_g5_max_bound_textures(void) {
Expand All @@ -411,13 +410,12 @@ int kinc_g5_max_bound_textures(void) {

static bool began = false;

void kinc_g5_begin(kinc_g5_render_target_t *renderTarget, int windowId) {
void kinc_g5_begin(kinc_g5_render_target_t *renderTarget) {
if (began)
return;
began = true;

struct dx_window *window = &dx_ctx.windows[windowId];
dx_ctx.current_window = windowId;
struct dx_window *window = &dx_ctx.windows[0];

window->current_backbuffer = (window->current_backbuffer + 1) % QUEUE_SLOT_COUNT;

Expand Down Expand Up @@ -446,23 +444,21 @@ void kinc_g5_begin(kinc_g5_render_target_t *renderTarget, int windowId) {
// commandList->ClearDepthStencilView(GetCPUDescriptorHandle(depthStencilDescriptorHeap), D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr);
}

void kinc_g5_end(int window) {
void kinc_g5_end() {
began = false;
}

void kinc_g4_on_g5_internal_resize(int, int, int);
void kinc_g4_on_g5_internal_resize(int, int);

void kinc_internal_resize(int windowId, int width, int height) {
void kinc_internal_resize(int width, int height) {
if (width == 0 || height == 0)
return;
struct dx_window *window = &dx_ctx.windows[windowId];
struct dx_window *window = &dx_ctx.windows[0];
window->new_width = width;
window->new_height = height;
kinc_g4_on_g5_internal_resize(windowId, width, height);
kinc_g4_on_g5_internal_resize(width, height);
}

void kinc_internal_change_framebuffer(int window, kinc_framebuffer_options_t *frame) {}

bool kinc_g5_swap_buffers() {
for (int i = 0; i < MAXIMUM_WINDOWS; i++) {
struct dx_window *window = &dx_ctx.windows[i];
Expand Down
8 changes: 4 additions & 4 deletions armorcore/sources/backends/ios/kinc/backend/GLView.m.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ static int removeTouch(void *touch) {

static GLint backingWidth, backingHeight;

int kinc_window_width(int window) {
int kinc_window_width() {
return backingWidth;
}

int kinc_window_height(int window) {
int kinc_window_height() {
return backingHeight;
}

Expand Down Expand Up @@ -105,7 +105,7 @@ int kinc_window_height(int window) {
- (void)end {
}

void kinc_internal_call_resize_callback(int window, int width, int height);
void kinc_internal_call_resize_callback(int width, int height);

- (void)layoutSubviews {
backingWidth = self.frame.size.width * self.contentScaleFactor;
Expand All @@ -114,7 +114,7 @@ void kinc_internal_call_resize_callback(int window, int width, int height);
CAMetalLayer *metalLayer = (CAMetalLayer *)self.layer;
metalLayer.drawableSize = CGSizeMake(backingWidth, backingHeight);

kinc_internal_call_resize_callback(0, backingWidth, backingHeight);
kinc_internal_call_resize_callback(backingWidth, backingHeight);
}

- (void)dealloc {
Expand Down
8 changes: 4 additions & 4 deletions armorcore/sources/backends/ios/kinc/backend/display.m.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ void kinc_display_init(void) {}

kinc_display_mode_t kinc_display_available_mode(int display, int mode) {
kinc_display_mode_t dm;
dm.width = kinc_window_width(0);
dm.height = kinc_window_height(0);
dm.width = kinc_window_width();
dm.height = kinc_window_height();
dm.frequency = 60;
dm.bits_per_pixel = 32;
return dm;
Expand All @@ -27,8 +27,8 @@ const char *kinc_display_name(int display) {

kinc_display_mode_t kinc_display_current_mode(int display) {
kinc_display_mode_t dm;
dm.width = kinc_window_width(0);
dm.height = kinc_window_height(0);
dm.width = kinc_window_width();
dm.height = kinc_window_height();
dm.frequency = (int)[[UIScreen mainScreen] maximumFramesPerSecond];
dm.bits_per_pixel = 32;
return dm;
Expand Down
6 changes: 3 additions & 3 deletions armorcore/sources/backends/ios/kinc/backend/mouse.c.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <kinc/input/mouse.h>

void kinc_internal_mouse_lock(int window) {}
void kinc_internal_mouse_lock(void) {}

void kinc_internal_mouse_unlock(void) {}

Expand All @@ -12,8 +12,8 @@ void kinc_mouse_show(void) {}

void kinc_mouse_hide(void) {}

void kinc_mouse_set_position(int window, int x, int y) {}
void kinc_mouse_set_position(int x, int y) {}

void kinc_mouse_get_position(int window, int *x, int *y) {}
void kinc_mouse_get_position(int *x, int *y) {}

void kinc_mouse_set_cursor(int cursor_index) {}
6 changes: 2 additions & 4 deletions armorcore/sources/backends/ios/kinc/backend/system.m.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void KoreUpdateKeyboard(void) {

void kinc_internal_shutdown(void) {}

int kinc_init(const char *name, int width, int height, struct kinc_window_options *win, struct kinc_framebuffer_options *frame) {
void kinc_init(const char *name, int width, int height, struct kinc_window_options *win, struct kinc_framebuffer_options *frame) {
kinc_window_options_t defaultWin;
if (win == NULL) {
kinc_window_options_set_defaults(&defaultWin);
Expand All @@ -88,9 +88,7 @@ int kinc_init(const char *name, int width, int height, struct kinc_window_option
frame = &defaultFrame;
}
kinc_g4_internal_init();
kinc_g4_internal_init_window(0, frame->depth_bits, true);

return 0;
kinc_g4_internal_init_window(frame->depth_bits, true);
}

void endGL(void);
Expand Down
Loading

0 comments on commit 984b234

Please sign in to comment.