Skip to content

Commit 2ff8607

Browse files
authored
[Graphics] Implement Meshes & Buffers (#273)
* mesh work * make sure to track depth write info * Update Mesh.hpp * setDepthMode works * clamp depth clear value * SpriteBatchL use Buffers TextBatch: use Buffers (WIP) * fix bottom screen projection * fix drawQuads * minor changes * ParticleSystem: use Buffer * switch: attempt Buffers * switch: depth writes * cafe: attempt meshes * cafe: more shader rework * cafe: use GX2RBuffer for UniformBlock * shader variables renamed, more fixes * changes from LÖVE about batched drawing * meshes work
1 parent 1c6eae1 commit 2ff8607

116 files changed

Lines changed: 4981 additions & 1151 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ build
55
*.3dsx
66
*.nro
77
*.wuhb
8+
.clangd
9+
10+
.DS_Store
11+
__cmake_systeminformation

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,15 @@ target_sources(${PROJECT_NAME} PRIVATE
199199
source/common/debug.cpp
200200
source/common/float.cpp
201201
source/common/luax.cpp
202+
source/common/memory.cpp
202203
source/common/Matrix.cpp
203204
source/common/Message.cpp
204205
source/common/Module.cpp
205206
source/common/Object.cpp
206207
source/common/pixelformat.cpp
207208
source/common/Reference.cpp
208209
source/common/screen.cpp
210+
source/common/delay.cpp
209211
source/common/Stream.cpp
210212
source/common/types.cpp
211213
source/common/Variant.cpp
@@ -255,6 +257,7 @@ target_sources(${PROJECT_NAME} PRIVATE
255257
source/modules/graphics/Buffer.cpp
256258
source/modules/graphics/Graphics.cpp
257259
source/modules/graphics/FontBase.cpp
260+
source/modules/graphics/Mesh.cpp
258261
source/modules/graphics/ParticleSystem.cpp
259262
source/modules/graphics/Polyline.cpp
260263
source/modules/graphics/TextBatch.cpp
@@ -266,7 +269,9 @@ target_sources(${PROJECT_NAME} PRIVATE
266269
source/modules/graphics/Quad.cpp
267270
source/modules/graphics/Volatile.cpp
268271
source/modules/graphics/vertex.cpp
272+
source/modules/graphics/wrap_Buffer.cpp
269273
source/modules/graphics/wrap_Graphics.cpp
274+
source/modules/graphics/wrap_Mesh.cpp
270275
source/modules/graphics/wrap_ParticleSystem.cpp
271276
source/modules/graphics/wrap_Texture.cpp
272277
source/modules/graphics/wrap_TextBatch.cpp

include/common/Map.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ using EnumMap = Map<Key, Value, Size>;
7373
#define STRINGMAP_DECLARE(name, enum_t, ...) \
7474
static inline constexpr auto name = StringMap { std::to_array<std::pair<std::string_view, enum_t>>({ __VA_ARGS__ }) }; \
7575
static inline constexpr bool getConstant(const char* key, enum_t& out) { return name.getValue(key, out); } \
76-
static inline constexpr bool getConstant(enum_t value, std::string_view& out) { return name.getKey(value, out); } \
77-
static inline constexpr const char* getConstant(enum_t value) { std::string_view out {}; return name.getKey(value, out) ? out.data() : nullptr; }
76+
static inline constexpr bool getConstant(enum_t value, std::string_view& out) { return name.getKey(value, out); }
77+
7878

7979
#define ENUMMAP_DECLARE(name, enum_t_a, enum_t_b, ...) \
8080
static inline constexpr auto name = EnumMap { std::to_array<std::pair<enum_t_a, enum_t_b>>({ __VA_ARGS__ }) }; \

include/common/Matrix.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ namespace love
8787
**/
8888
const float* getElements() const;
8989

90+
/**
91+
* Gets a pointer to the 9 array elements.
92+
**/
93+
float* getElements();
94+
9095
void setRow(int r, const Vector4& v);
9196
Vector4 getRow(int r) const;
9297

@@ -230,6 +235,11 @@ namespace love
230235
**/
231236
static Matrix4 ortho(float left, float right, float bottom, float top, float near, float far);
232237

238+
/**
239+
* Creates a new orthographic projection matrix, tilted 90° CCW.
240+
**/
241+
static Matrix4 orthoTilt(float left, float right, float bottom, float top, float near, float far);
242+
233243
/**
234244
* Creates a new perspective projection matrix.
235245
**/

include/common/Variant.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include "common/Object.hpp"
4-
#include "common/int.hpp"
54

65
#include <cstring>
76
#include <string>

include/common/debug.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <arpa/inet.h>
44
#include <fcntl.h>
55
#include <netinet/in.h>
6-
#include <signal.h>
76
#include <sys/select.h>
87
#include <sys/socket.h>
98
#include <unistd.h>
@@ -69,11 +68,9 @@ namespace love
6968
// clang-format off
7069
#if defined(__DEBUG__)
7170
#include <cstdio>
72-
#define LOG(format, ...) \
73-
do { std::printf("[C++] " format "\n", ##__VA_ARGS__); } while (0)
71+
#define LOG(format, ...) do { std::printf("[C++] " format "\n", ##__VA_ARGS__); } while (0)
7472
#else
75-
#define LOG(format, ...) \
76-
do {} while (0)
73+
#define LOG(format, ...) do {} while (0)
7774
#endif
7875
//clang-format on
7976
} // namespace love

include/common/delay.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
namespace love
4+
{
5+
static constexpr int NS_TO_MS = 1000000;
6+
void sleep(double ms);
7+
} // namespace love

include/common/luax.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ namespace love
132132

133133
std::string luax_checkstring(lua_State* L, int index);
134134

135+
int luax_checkint(lua_State* L, int index);
136+
135137
int luax_checkintflag(lua_State* L, int tableIndex, const char* key);
136138

137139
int luax_intflag(lua_State* L, int index, const char* name, int default_value);

include/common/pixelformat.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ namespace love
273273
**/
274274
int getPixelFormatColorComponents(PixelFormat format);
275275

276+
const char* getConstant(PixelFormat format);
277+
276278
// clang-format off
277279
STRINGMAP_DECLARE(PixelFormats, PixelFormat,
278280
{ "unknown", PIXELFORMAT_UNKNOWN },

include/common/screen.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#pragma once
22

3+
#include <algorithm>
34
#include <span>
45
#include <string_view>
56

6-
#include <algorithm>
7-
87
#include <stdint.h>
98

109
namespace love
@@ -24,7 +23,7 @@ namespace love
2423
static constexpr inline Screen DEFAULT_SCREEN = (Screen)0;
2524
inline Screen currentScreen = DEFAULT_SCREEN;
2625

27-
std::span<ScreenInfo> getScreenInfo();
26+
std::span<const ScreenInfo> getScreenInfo();
2827

2928
const ScreenInfo& getScreenInfo(Screen id);
3029

0 commit comments

Comments
 (0)