Skip to content

Commit

Permalink
minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtleP committed May 2, 2024
1 parent 0aced70 commit fc6cb88
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 239 deletions.
8 changes: 7 additions & 1 deletion include/common/math.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <climits> // for CHAR_BIT
#include <cstdio>
#include <cstdlib> // for rand() and RAND_MAX

#include <algorithm>
Expand Down Expand Up @@ -47,7 +48,7 @@ namespace love
{
struct Rect
{
static constexpr int EMPTY[4] = { 0, 0, 0, 0 };
static constexpr int EMPTY[4] = { -1, -1, -1, -1 };

int x, y, w, h;

Expand All @@ -71,6 +72,11 @@ namespace love
}
};

inline void DEBUG_RECT(const Rect& rectangle)
{
std::printf("x: %d, y: %d, w: %d, h: %d\n", rectangle.x, rectangle.y, rectangle.w, rectangle.h);
}

/*
** Clamps 3DS textures between min
** and max texture size to prevent
Expand Down
27 changes: 0 additions & 27 deletions include/driver/display/Renderer.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,6 @@ namespace love
RENDERER_INFO_DEVICE
};

struct BatchedVertexData
{
Vertex* stream;
};

struct BatchedDrawState
{
Vertex* vertices;
size_t verticesSize;

StreamBuffer::MapInfo vertexMap = StreamBuffer::MapInfo();

StreamBuffer* indexBuffer;
StreamBuffer::MapInfo indexMap = StreamBuffer::MapInfo();

PrimitiveType primitiveMode = PRIMITIVE_TRIANGLES;
ShaderBase::StandardShader shader = ShaderBase::STANDARD_DEFAULT;
CommonFormat format = CommonFormat::NONE;

StrongRef<TextureBase> texture;

int vertexCount = 0;
int indexCount = 0;

bool flushing = false;
};

RendererBase() : batchedDrawState {}
{
size_t size = sizeof(uint16_t) * LOVE_UINT16_MAX;
Expand Down
27 changes: 27 additions & 0 deletions include/driver/graphics/DrawCommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,31 @@ namespace love
TextureBase* texture;
CullMode cullMode = CULL_NONE;
};

struct BatchedVertexData
{
Vertex* stream;
};

struct BatchedDrawState
{
Vertex* vertices;
size_t verticesSize;

StreamBuffer::MapInfo vertexMap = StreamBuffer::MapInfo();

StreamBuffer* indexBuffer;
StreamBuffer::MapInfo indexMap = StreamBuffer::MapInfo();

PrimitiveType primitiveMode = PRIMITIVE_TRIANGLES;
ShaderBase::StandardShader shader = ShaderBase::STANDARD_DEFAULT;
CommonFormat format = CommonFormat::NONE;

StrongRef<TextureBase> texture;

int vertexCount = 0;
int indexCount = 0;

bool flushing = false;
};
} // namespace love
85 changes: 0 additions & 85 deletions include/modules/graphics/StreamBuffer.tcc

This file was deleted.

2 changes: 1 addition & 1 deletion include/modules/graphics/vertex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ namespace love

inline CommonFormat getSinglePositionFormat(bool is2D)
{
return is2D ? CommonFormat::XYf : CommonFormat::XYf;
return is2D ? CommonFormat::XYf : CommonFormat::XYZf;
}

struct DataFormatInfo
Expand Down
72 changes: 42 additions & 30 deletions include/modules/graphics/wrap_Graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,51 @@
#include "common/luax.hpp"
#include "modules/graphics/Graphics.hpp"

template<typename T>
static void luax_checkstandardtransform(lua_State* L, int index, const T& func)
{
/* TODO: check Transform type */

int nargs = lua_gettop(L);

float x = luaL_optnumber(L, index + 0, 0.0);
float y = luaL_optnumber(L, index + 1, 0.0);
float a = luaL_optnumber(L, index + 2, 0.0);
float sx = luaL_optnumber(L, index + 3, 1.0);
float sy = luaL_optnumber(L, index + 4, sx);

float ox = 0.0f;
float oy = 0.0f;

if (nargs >= index + 5)
{
ox = luaL_optnumber(L, index + 5, 0.0);
oy = luaL_optnumber(L, index + 6, 0.0);
}

float kx = 0.0f;
float ky = 0.0f;
#include "modules/math/Transform.hpp"

if (nargs >= index + 7)
namespace love
{
template<typename T>
static void luax_checkstandardtransform(lua_State* L, int index, const T& func)
{
kx = luaL_optnumber(L, index + 7, 0.0);
ky = luaL_optnumber(L, index + 8, 0.0);
/* TODO: check Transform type */

auto* transform = luax_totype<Transform>(L, index);

if (transform != nullptr)
func(transform->getMatrix());
else
{
int nargs = lua_gettop(L);

float x = luaL_optnumber(L, index + 0, 0.0);
float y = luaL_optnumber(L, index + 1, 0.0);
float a = luaL_optnumber(L, index + 2, 0.0);
float sx = luaL_optnumber(L, index + 3, 1.0);
float sy = luaL_optnumber(L, index + 4, sx);

float ox = 0.0f;
float oy = 0.0f;

if (nargs >= index + 5)
{
ox = luaL_optnumber(L, index + 5, 0.0);
oy = luaL_optnumber(L, index + 6, 0.0);
}

float kx = 0.0f;
float ky = 0.0f;

if (nargs >= index + 7)
{
kx = luaL_optnumber(L, index + 7, 0.0);
ky = luaL_optnumber(L, index + 8, 0.0);
}

func(love::Matrix4(x, y, a, sx, sy, ox, oy, kx, ky));
}
}

func(love::Matrix4(x, y, a, sx, sy, ox, oy, kx, ky));
}
} // namespace love

namespace Wrap_Graphics
{
Expand Down
5 changes: 4 additions & 1 deletion platform/ctr/include/driver/display/Framebuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ namespace love
return this->projection;
}

static void calculateBounds(const Rect& bounds, Rect& out, const int width, const int height);

private:
static constexpr auto FORMAT = GPU_RB_DEPTH16;
static constexpr auto DEPTH_FORMAT = GPU_RB_DEPTH16;
static constexpr auto COLOR_FORMAT = GPU_RB_RGBA8;

static constexpr auto DISPLAY_TRANSFER_FLAGS =
GX_TRANSFER_FLIP_VERT(0) | GX_TRANSFER_OUT_TILED(0) | GX_TRANSFER_RAW_COPY(0) |
Expand Down
3 changes: 0 additions & 3 deletions platform/ctr/include/driver/display/Renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ namespace love
private:
static GPU_TEXTURE_WRAP_PARAM getWrapMode(SamplerState::WrapMode mode);

static constexpr int MAX_OBJECTS = 0x1000;
static constexpr int VERTEX_BUFFER_SIZE = 6 * MAX_OBJECTS; // 6 vertices per object

void ensureInFrame();

void createFramebuffers();
Expand Down
66 changes: 0 additions & 66 deletions platform/ctr/include/driver/display/citro3d/VertexRing.hpp

This file was deleted.

14 changes: 7 additions & 7 deletions platform/ctr/source/common/screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ namespace love
// clang-format off
inline constinit ScreenInfo GFX_3D[0x03] =
{
{ GFX_TOP, 0, "left", 400, 240 },
{ GFX_TOP, 1, "right", 400, 240 },
{ GFX_BOTTOM, 2, "bottom", 320, 240 }
{ GFX_TOP, 0, "left", GSP_SCREEN_HEIGHT_TOP, GSP_SCREEN_WIDTH },
{ GFX_TOP, 1, "right", GSP_SCREEN_HEIGHT_TOP, GSP_SCREEN_WIDTH },
{ GFX_BOTTOM, 2, "bottom", GSP_SCREEN_HEIGHT_BOTTOM, GSP_SCREEN_WIDTH }
};

inline constinit ScreenInfo GFX_2D[0x02] =
{
{ GFX_TOP, 0, "top", 400, 240 },
{ GFX_BOTTOM, 1, "bottom", 320, 240 }
{ GFX_TOP, 0, "top", GSP_SCREEN_HEIGHT_TOP, GSP_SCREEN_WIDTH },
{ GFX_BOTTOM, 1, "bottom", GSP_SCREEN_HEIGHT_BOTTOM, GSP_SCREEN_WIDTH }
};

inline constinit ScreenInfo GFX_WIDE[0x02] =
{
{ GFX_TOP, 0, "top", 800, 240 },
{ GFX_BOTTOM, 1, "bottom", 320, 240 }
{ GFX_TOP, 0, "top", GSP_SCREEN_HEIGHT_TOP_2X, GSP_SCREEN_WIDTH },
{ GFX_BOTTOM, 1, "bottom", GSP_SCREEN_HEIGHT_BOTTOM, GSP_SCREEN_WIDTH }
};
// clang-format on

Expand Down
Loading

0 comments on commit fc6cb88

Please sign in to comment.