Skip to content

Commit 242df2b

Browse files
committed
Create platform layer and implement Windows
1 parent 920a52f commit 242df2b

File tree

11 files changed

+404
-316
lines changed

11 files changed

+404
-316
lines changed

polymer/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ include_directories(polymer PRIVATE ..)
2727

2828
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
2929
# Ignore VMA nullability warnings
30-
set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -Wno-nullability-completeness -Wplacement-new=")
30+
set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -Wno-nullability-completeness")
3131
endif()
3232

3333
if (UNIX)

polymer/gamestate.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <polymer/asset/asset_system.h>
55
#include <polymer/camera.h>
66
#include <polymer/connection.h>
7+
#include <polymer/input.h>
78
#include <polymer/render/block_mesher.h>
89
#include <polymer/render/chunk_renderer.h>
910
#include <polymer/render/font_renderer.h>
@@ -17,18 +18,6 @@ namespace polymer {
1718

1819
struct MemoryArena;
1920

20-
// TODO: Make this more advanced
21-
struct InputState {
22-
bool forward;
23-
bool backward;
24-
bool left;
25-
bool right;
26-
bool climb;
27-
bool fall;
28-
bool sprint;
29-
bool display_players;
30-
};
31-
3221
struct Player {
3322
char name[17];
3423
char uuid[16];

polymer/input.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
namespace polymer {
4+
5+
// TODO: Make this more advanced
6+
struct InputState {
7+
bool forward;
8+
bool backward;
9+
bool left;
10+
bool right;
11+
bool climb;
12+
bool fall;
13+
bool sprint;
14+
bool display_players;
15+
};
16+
17+
} // namespace polymer

polymer/platform/args.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct ArgParser {
6262
static ArgParser Parse(int argc, char* argv[]) {
6363
ArgParser result = {};
6464

65-
for (int i = 0; i < argc; ++i) {
65+
for (int i = 0; i < argc && i < polymer_array_count(args); ++i) {
6666
char* current = argv[i];
6767

6868
if (current[0] == '-') {

polymer/platform/platform.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#pragma once
2+
3+
#include <polymer/math.h>
4+
#include <polymer/render/vulkan.h>
5+
6+
namespace polymer {
7+
8+
using PolymerWindow = void*;
9+
10+
struct ExtensionRequest {
11+
const char** extensions;
12+
u32 extension_count = 0;
13+
14+
const char** device_extensions;
15+
u32 device_extension_count = 0;
16+
17+
const char** validation_layers;
18+
u32 validation_layer_count = 0;
19+
};
20+
21+
using PlatformGetPlatformName = const char* (*)();
22+
23+
using PlatformWindowCreate = PolymerWindow (*)(int width, int height);
24+
using PlatformWindowCreateSurface = bool (*)(PolymerWindow window, VkSurfaceKHR* surface);
25+
using PlatformWindowGetRect = IntRect (*)(PolymerWindow window);
26+
using PlatformWindowPump = void (*)(PolymerWindow window);
27+
28+
using PlatformGetExtensionRequest = ExtensionRequest (*)();
29+
30+
struct Platform {
31+
PlatformGetPlatformName GetPlatformName;
32+
33+
PlatformWindowCreate WindowCreate;
34+
PlatformWindowCreateSurface WindowCreateSurface;
35+
PlatformWindowGetRect WindowGetRect;
36+
PlatformWindowPump WindowPump;
37+
38+
PlatformGetExtensionRequest GetExtensionRequest;
39+
};
40+
41+
} // namespace polymer

0 commit comments

Comments
 (0)