Let's just use 1 PD_API header
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include <pd/lithium/command.hpp>
|
||||
|
||||
PD_LITHIUM_API PD::Li::Command::Ref PD::Li::CmdPool::NewCmd() {
|
||||
PD_API PD::Li::Command::Ref PD::Li::CmdPool::NewCmd() {
|
||||
if (pPoolIdx >= pPool.size()) {
|
||||
Resize(pPool.size() + 128);
|
||||
}
|
||||
@@ -10,18 +10,16 @@ PD_LITHIUM_API PD::Li::Command::Ref PD::Li::CmdPool::NewCmd() {
|
||||
return nu;
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void PD::Li::CmdPool::Init(size_t initial_size) {
|
||||
Resize(initial_size);
|
||||
}
|
||||
PD_API void PD::Li::CmdPool::Init(size_t initial_size) { Resize(initial_size); }
|
||||
|
||||
PD_LITHIUM_API void PD::Li::CmdPool::Deinit() {
|
||||
PD_API void PD::Li::CmdPool::Deinit() {
|
||||
for (auto it : pPool) {
|
||||
Command::Delete(it);
|
||||
}
|
||||
pPool.clear();
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void PD::Li::CmdPool::Resize(size_t nulen) {
|
||||
PD_API void PD::Li::CmdPool::Resize(size_t nulen) {
|
||||
if (nulen <= pPool.size()) {
|
||||
return; // no idea yet
|
||||
}
|
||||
@@ -32,7 +30,7 @@ PD_LITHIUM_API void PD::Li::CmdPool::Resize(size_t nulen) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void PD::Li::CmdPool::Reset() {
|
||||
PD_API void PD::Li::CmdPool::Reset() {
|
||||
for (u32 i = 0; i < pPoolIdx; i++) {
|
||||
pPool[i]->Clear();
|
||||
}
|
||||
@@ -47,12 +45,12 @@ PD::Li::Command::Ref PD::Li::CmdPool::GetCmd(size_t idx) { return pPool[idx]; }
|
||||
size_t PD::Li::CmdPool::Size() const { return pPoolIdx; }
|
||||
size_t PD::Li::CmdPool::Cap() const { return pPool.size(); }
|
||||
|
||||
PD_LITHIUM_API void PD::Li::CmdPool::Merge(CmdPool& p) {
|
||||
PD_API void PD::Li::CmdPool::Merge(CmdPool& p) {
|
||||
Copy(p);
|
||||
p.Reset();
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void PD::Li::CmdPool::Copy(CmdPool& p) {
|
||||
PD_API void PD::Li::CmdPool::Copy(CmdPool& p) {
|
||||
if (pPoolIdx + p.Size() > pPool.size()) {
|
||||
Resize(pPoolIdx + p.Size());
|
||||
}
|
||||
@@ -64,13 +62,13 @@ PD_LITHIUM_API void PD::Li::CmdPool::Copy(CmdPool& p) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void PD::Li::CmdPool::Sort() {
|
||||
PD_API void PD::Li::CmdPool::Sort() {
|
||||
if (pPoolIdx < 2) return;
|
||||
std::sort(begin(), end(), pTheOrder);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API bool PD::Li::CmdPool::pTheOrder(const Command::Ref& a,
|
||||
const Command::Ref& b) {
|
||||
PD_API bool PD::Li::CmdPool::pTheOrder(const Command::Ref& a,
|
||||
const Command::Ref& b) {
|
||||
if (a->Layer == b->Layer) {
|
||||
if (a->Tex == b->Tex) {
|
||||
return a->Index < b->Index;
|
||||
|
||||
78
source/lithium/drawlist.cpp
Executable file → Normal file
78
source/lithium/drawlist.cpp
Executable file → Normal file
@@ -31,19 +31,19 @@ SOFTWARE.
|
||||
|
||||
namespace PD {
|
||||
namespace Li {
|
||||
PD_LITHIUM_API DrawList::DrawList(int initial_size) {
|
||||
PD_API DrawList::DrawList(int initial_size) {
|
||||
DrawSolid();
|
||||
pPool.Init(initial_size);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API DrawList::~DrawList() {
|
||||
PD_API DrawList::~DrawList() {
|
||||
Clear();
|
||||
pPool.Deinit();
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawSolid() { CurrentTex = Gfx::GetSolidTex(); }
|
||||
PD_API void DrawList::DrawSolid() { CurrentTex = Gfx::GetSolidTex(); }
|
||||
|
||||
PD_LITHIUM_API void DrawList::Clear() {
|
||||
PD_API void DrawList::Clear() {
|
||||
pNumIndices = 0;
|
||||
pNumVertices = 0;
|
||||
pPool.Reset();
|
||||
@@ -56,7 +56,7 @@ PD_LITHIUM_API void DrawList::Clear() {
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::Merge(DrawList::Ref list) {
|
||||
PD_API void DrawList::Merge(DrawList::Ref list) {
|
||||
pPool.Merge(list->pPool);
|
||||
/*for (size_t i = 0; i < list->pDrawList.size(); i++) {
|
||||
pNumIndices += list->pDrawList[i]->IndexBuffer.size();
|
||||
@@ -68,11 +68,9 @@ PD_LITHIUM_API void DrawList::Merge(DrawList::Ref list) {
|
||||
list->Clear();
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::Copy(DrawList::Ref list) {
|
||||
pPool.Copy(list->pPool);
|
||||
}
|
||||
PD_API void DrawList::Copy(DrawList::Ref list) { pPool.Copy(list->pPool); }
|
||||
|
||||
PD_LITHIUM_API void DrawList::Optimize() {
|
||||
PD_API void DrawList::Optimize() {
|
||||
#ifndef NDEBUG
|
||||
PD::TT::Scope s("Optimize");
|
||||
#endif
|
||||
@@ -88,7 +86,7 @@ PD_LITHIUM_API void DrawList::Optimize() {
|
||||
});*/
|
||||
}
|
||||
|
||||
PD_LITHIUM_API Command::Ref DrawList::GetNewCmd() {
|
||||
PD_API Command::Ref DrawList::GetNewCmd() {
|
||||
Command::Ref cmd = pPool.NewCmd();
|
||||
cmd->Index = pPool.Size() - 1;
|
||||
cmd->Tex = CurrentTex->Address;
|
||||
@@ -96,16 +94,15 @@ PD_LITHIUM_API Command::Ref DrawList::GetNewCmd() {
|
||||
return cmd;
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::pClipCmd(Command::Ref cmd) {
|
||||
PD_API void DrawList::pClipCmd(Command::Ref cmd) {
|
||||
if (!pClipRects.empty()) {
|
||||
cmd->ScissorOn = true;
|
||||
cmd->ScissorRect = ivec4(pClipRects.top());
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::PathArcToN(const fvec2& c, float radius,
|
||||
float a_min, float a_max,
|
||||
int segments) {
|
||||
PD_API void DrawList::PathArcToN(const fvec2& c, float radius, float a_min,
|
||||
float a_max, int segments) {
|
||||
// Path.push_back(c);
|
||||
PathReserve(segments + 1);
|
||||
for (int i = 0; i < segments; i++) {
|
||||
@@ -114,8 +111,8 @@ PD_LITHIUM_API void DrawList::PathArcToN(const fvec2& c, float radius,
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::PathFastArcToN(const fvec2& c, float r,
|
||||
float amin, float amax, int s) {
|
||||
PD_API void DrawList::PathFastArcToN(const fvec2& c, float r, float amin,
|
||||
float amax, int s) {
|
||||
/**
|
||||
* Funcion with less division overhead
|
||||
* Usefull for stuff where a lot of calculations are required
|
||||
@@ -128,7 +125,7 @@ PD_LITHIUM_API void DrawList::PathFastArcToN(const fvec2& c, float r,
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::PathRect(fvec2 a, fvec2 b, float rounding) {
|
||||
PD_API void DrawList::PathRect(fvec2 a, fvec2 b, float rounding) {
|
||||
if (rounding == 0.f) {
|
||||
PathAdd(a);
|
||||
PathAdd(vec2(b.x, a.y));
|
||||
@@ -160,8 +157,7 @@ PD_LITHIUM_API void DrawList::PathRect(fvec2 a, fvec2 b, float rounding) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::PathRectEx(fvec2 a, fvec2 b, float rounding,
|
||||
u32 flags) {
|
||||
PD_API void DrawList::PathRectEx(fvec2 a, fvec2 b, float rounding, u32 flags) {
|
||||
if (rounding == 0.f) {
|
||||
PathAdd(a);
|
||||
PathAdd(vec2(b.x, a.y));
|
||||
@@ -210,8 +206,8 @@ PD_LITHIUM_API void DrawList::PathRectEx(fvec2 a, fvec2 b, float rounding,
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawRect(const fvec2& pos, const fvec2& size,
|
||||
u32 color, int thickness) {
|
||||
PD_API void DrawList::DrawRect(const fvec2& pos, const fvec2& size, u32 color,
|
||||
int thickness) {
|
||||
PathRect(pos, pos + size);
|
||||
// Flags is currently hardcoded (1 = close)
|
||||
PathStroke(color, thickness, 1);
|
||||
@@ -221,26 +217,24 @@ void DrawList::DrawRectFilled(const fvec2& pos, const fvec2& size, u32 color) {
|
||||
PathFill(color);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawTriangle(const fvec2& a, const fvec2& b,
|
||||
const fvec2& c, u32 color,
|
||||
int thickness) {
|
||||
PD_API void DrawList::DrawTriangle(const fvec2& a, const fvec2& b,
|
||||
const fvec2& c, u32 color, int thickness) {
|
||||
PathAdd(a);
|
||||
PathAdd(b);
|
||||
PathAdd(c);
|
||||
PathStroke(color, thickness, 1);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawTriangleFilled(const fvec2& a, const fvec2& b,
|
||||
const fvec2& c, u32 color) {
|
||||
PD_API void DrawList::DrawTriangleFilled(const fvec2& a, const fvec2& b,
|
||||
const fvec2& c, u32 color) {
|
||||
PathAdd(a);
|
||||
PathAdd(b);
|
||||
PathAdd(c);
|
||||
PathFill(color);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawCircle(const fvec2& center, float rad,
|
||||
u32 color, int num_segments,
|
||||
int thickness) {
|
||||
PD_API void DrawList::DrawCircle(const fvec2& center, float rad, u32 color,
|
||||
int num_segments, int thickness) {
|
||||
if (num_segments <= 0) {
|
||||
// Auto Segment
|
||||
} else {
|
||||
@@ -251,8 +245,8 @@ PD_LITHIUM_API void DrawList::DrawCircle(const fvec2& center, float rad,
|
||||
PathStroke(color, thickness, (1 << 0));
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawCircleFilled(const fvec2& center, float rad,
|
||||
u32 color, int num_segments) {
|
||||
PD_API void DrawList::DrawCircleFilled(const fvec2& center, float rad,
|
||||
u32 color, int num_segments) {
|
||||
if (num_segments <= 0) {
|
||||
// Auto Segment
|
||||
} else {
|
||||
@@ -263,8 +257,8 @@ PD_LITHIUM_API void DrawList::DrawCircleFilled(const fvec2& center, float rad,
|
||||
}
|
||||
|
||||
// TODO: Don't render OOS
|
||||
PD_LITHIUM_API void DrawList::DrawPolyLine(const std::vector<fvec2>& points,
|
||||
u32 clr, u32 flags, int thickness) {
|
||||
PD_API void DrawList::DrawPolyLine(const std::vector<fvec2>& points, u32 clr,
|
||||
u32 flags, int thickness) {
|
||||
if (points.size() < 2) {
|
||||
return;
|
||||
}
|
||||
@@ -284,8 +278,8 @@ PD_LITHIUM_API void DrawList::DrawPolyLine(const std::vector<fvec2>& points,
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawConvexPolyFilled(
|
||||
const std::vector<fvec2>& points, u32 clr) {
|
||||
PD_API void DrawList::DrawConvexPolyFilled(const std::vector<fvec2>& points,
|
||||
u32 clr) {
|
||||
if (points.size() < 3) {
|
||||
return; // Need at least three points
|
||||
}
|
||||
@@ -293,25 +287,25 @@ PD_LITHIUM_API void DrawList::DrawConvexPolyFilled(
|
||||
Renderer::CmdConvexPolyFilled(cmd, points, clr, CurrentTex);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawText(const fvec2& pos,
|
||||
const std::string& text, u32 color) {
|
||||
PD_API void DrawList::DrawText(const fvec2& pos, const std::string& text,
|
||||
u32 color) {
|
||||
if (!pCurrentFont) {
|
||||
return;
|
||||
}
|
||||
pCurrentFont->CmdTextEx(pPool, pos, color, pFontScale, text);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawTextEx(const fvec2& p,
|
||||
const std::string& text, u32 color,
|
||||
LiTextFlags flags, const fvec2& box) {
|
||||
PD_API void DrawList::DrawTextEx(const fvec2& p, const std::string& text,
|
||||
u32 color, LiTextFlags flags,
|
||||
const fvec2& box) {
|
||||
if (!pCurrentFont) {
|
||||
return;
|
||||
}
|
||||
pCurrentFont->CmdTextEx(pPool, p, color, pFontScale, text, flags, box);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawLine(const fvec2& a, const fvec2& b,
|
||||
u32 color, int t) {
|
||||
PD_API void DrawList::DrawLine(const fvec2& a, const fvec2& b, u32 color,
|
||||
int t) {
|
||||
PathAdd(a);
|
||||
PathAdd(b);
|
||||
PathStroke(color, t);
|
||||
|
||||
@@ -37,7 +37,7 @@ SOFTWARE.
|
||||
|
||||
namespace PD {
|
||||
namespace Li {
|
||||
PD_LITHIUM_API void Font::LoadDefaultFont(int id, int pixel_height) {
|
||||
PD_API void Font::LoadDefaultFont(int id, int pixel_height) {
|
||||
#ifdef PD_LI_INCLUDE_FONTS
|
||||
if (id < pNumFonts) {
|
||||
auto font = pFontData[id];
|
||||
@@ -48,7 +48,7 @@ PD_LITHIUM_API void Font::LoadDefaultFont(int id, int pixel_height) {
|
||||
#endif
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Font::LoadTTF(const std::string& path, int height) {
|
||||
PD_API void Font::LoadTTF(const std::string& path, int height) {
|
||||
/**
|
||||
* Just use LoadFile2Mem which looks way cleaner
|
||||
* and helps not having the font loading code twice
|
||||
@@ -59,15 +59,15 @@ PD_LITHIUM_API void Font::LoadTTF(const std::string& path, int height) {
|
||||
LoadTTF(font, height);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Font::pMakeAtlas(bool final, std::vector<u8>& font_tex,
|
||||
int texszs, PD::Li::Texture::Ref tex) {
|
||||
PD_API void Font::pMakeAtlas(bool final, std::vector<u8>& font_tex, int texszs,
|
||||
PD::Li::Texture::Ref tex) {
|
||||
auto t =
|
||||
Gfx::LoadTex(font_tex, texszs, texszs, Texture::RGBA32, Texture::LINEAR);
|
||||
tex->CopyFrom(t);
|
||||
Textures.push_back(tex);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
|
||||
PD_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
|
||||
/**
|
||||
* Some additional Info:
|
||||
* Removed the stbtt get bitmapbox as we dont need to place
|
||||
@@ -183,7 +183,7 @@ PD_LITHIUM_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API Font::Codepoint& Font::GetCodepoint(u32 cp) {
|
||||
PD_API Font::Codepoint& Font::GetCodepoint(u32 cp) {
|
||||
// Check if codepoijt exist or return a static invalid one
|
||||
auto res = CodeMap.find(cp);
|
||||
if (res == CodeMap.end()) {
|
||||
@@ -194,7 +194,7 @@ PD_LITHIUM_API Font::Codepoint& Font::GetCodepoint(u32 cp) {
|
||||
return res->second;
|
||||
}
|
||||
|
||||
PD_LITHIUM_API fvec2 Font::GetTextBounds(const std::string& text, float scale) {
|
||||
PD_API fvec2 Font::GetTextBounds(const std::string& text, float scale) {
|
||||
u32 id = PD::FNV1A32(text);
|
||||
if (pTMS.find(id) != pTMS.end()) {
|
||||
pTMS[id].TimeStamp = PD::OS::GetTime();
|
||||
@@ -247,9 +247,9 @@ PD_LITHIUM_API fvec2 Font::GetTextBounds(const std::string& text, float scale) {
|
||||
return res;
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Font::CmdTextEx(CmdPool& cmds, const fvec2& pos, u32 color,
|
||||
float scale, const std::string& text,
|
||||
LiTextFlags flags, const fvec2& box) {
|
||||
PD_API void Font::CmdTextEx(CmdPool& cmds, const fvec2& pos, u32 color,
|
||||
float scale, const std::string& text,
|
||||
LiTextFlags flags, const fvec2& box) {
|
||||
fvec2 off;
|
||||
float cfs = (DefaultPixelHeight * scale) / (float)PixelHeight;
|
||||
float lh = (float)PixelHeight * cfs;
|
||||
@@ -336,9 +336,8 @@ PD_LITHIUM_API void Font::CmdTextEx(CmdPool& cmds, const fvec2& pos, u32 color,
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API std::string Font::pWrapText(const std::string& txt, float scale,
|
||||
const PD::fvec2& max,
|
||||
PD::fvec2& dim) {
|
||||
PD_API std::string Font::pWrapText(const std::string& txt, float scale,
|
||||
const PD::fvec2& max, PD::fvec2& dim) {
|
||||
u32 id = PD::FNV1A32(txt);
|
||||
if (pTMS.find(id) != pTMS.end()) {
|
||||
if (pTMS[id].Text.size()) {
|
||||
@@ -373,9 +372,8 @@ PD_LITHIUM_API std::string Font::pWrapText(const std::string& txt, float scale,
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_LITHIUM_API std::string Font::pShortText(const std::string& txt, float scale,
|
||||
const PD::fvec2& max,
|
||||
PD::fvec2& dim) {
|
||||
PD_API std::string Font::pShortText(const std::string& txt, float scale,
|
||||
const PD::fvec2& max, PD::fvec2& dim) {
|
||||
u32 id = PD::FNV1A32(txt);
|
||||
if (pTMS.find(id) != pTMS.end()) {
|
||||
if (pTMS[id].Text.size()) {
|
||||
@@ -417,7 +415,7 @@ PD_LITHIUM_API std::string Font::pShortText(const std::string& txt, float scale,
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Font::CleanupTMS() {
|
||||
PD_API void Font::CleanupTMS() {
|
||||
u64 t = PD::OS::GetTime();
|
||||
for (auto it = pTMS.begin(); it != pTMS.end();) {
|
||||
if (t - it->second.TimeStamp > 1000) {
|
||||
|
||||
35
source/lithium/renderer.cpp
Executable file → Normal file
35
source/lithium/renderer.cpp
Executable file → Normal file
@@ -26,34 +26,33 @@ SOFTWARE.
|
||||
|
||||
namespace PD {
|
||||
namespace Li {
|
||||
PD_LITHIUM_API bool Renderer::InBox(const fvec2& pos, const fvec2& szs,
|
||||
const fvec4& rect) {
|
||||
PD_API bool Renderer::InBox(const fvec2& pos, const fvec2& szs,
|
||||
const fvec4& rect) {
|
||||
return (pos.x + szs.x >= rect.x && pos.y + szs.y >= rect.y &&
|
||||
pos.x <= rect.z && pos.y <= rect.w);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API bool Renderer::InBox(const fvec2& pos, const fvec4& rect) {
|
||||
PD_API bool Renderer::InBox(const fvec2& pos, const fvec4& rect) {
|
||||
return (pos.x > rect.x && pos.x < rect.x + rect.z && pos.y > rect.y &&
|
||||
pos.y < rect.y + rect.w);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API bool Renderer::InBox(const fvec2& alpha, const fvec2& bravo,
|
||||
const fvec2& charlie, const fvec4& rect) {
|
||||
PD_API bool Renderer::InBox(const fvec2& alpha, const fvec2& bravo,
|
||||
const fvec2& charlie, const fvec4& rect) {
|
||||
return ((alpha.x < rect.z && bravo.x < rect.z && charlie.x < rect.z) ||
|
||||
(alpha.y < rect.w && bravo.y < rect.w && charlie.y < rect.w) ||
|
||||
(alpha.x > 0 && bravo.x > 0 && charlie.x > 0) ||
|
||||
(alpha.y > 0 && bravo.y > 0 && charlie.y > 0));
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Renderer::RotateCorner(fvec2& pos, float sinus,
|
||||
float cosinus) {
|
||||
PD_API void Renderer::RotateCorner(fvec2& pos, float sinus, float cosinus) {
|
||||
float x = pos.x * cosinus - pos.y * sinus;
|
||||
float y = pos.y * cosinus - pos.x * sinus;
|
||||
pos = fvec2(x, y);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API Rect Renderer::PrimRect(const fvec2& pos, const fvec2& size,
|
||||
float angle) {
|
||||
PD_API Rect Renderer::PrimRect(const fvec2& pos, const fvec2& size,
|
||||
float angle) {
|
||||
fvec2 c = size * 0.5f; // Center
|
||||
fvec2 corner[4] = {
|
||||
fvec2(-c.x, -c.y),
|
||||
@@ -76,8 +75,7 @@ PD_LITHIUM_API Rect Renderer::PrimRect(const fvec2& pos, const fvec2& size,
|
||||
corner[3] + pos + c);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API Rect Renderer::PrimLine(const fvec2& a, const fvec2& b,
|
||||
int thickness) {
|
||||
PD_API Rect Renderer::PrimLine(const fvec2& a, const fvec2& b, int thickness) {
|
||||
// Using the vec maths api makes the code as short as it is
|
||||
vec2 dir = a - b;
|
||||
float len = dir.Len();
|
||||
@@ -88,8 +86,8 @@ PD_LITHIUM_API Rect Renderer::PrimLine(const fvec2& a, const fvec2& b,
|
||||
return Rect(a + off, b + off, a - off, b - off);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Renderer::CmdQuad(Command::Ref cmd, const Rect& quad,
|
||||
const Rect& uv, u32 color) {
|
||||
PD_API void Renderer::CmdQuad(Command::Ref cmd, const Rect& quad,
|
||||
const Rect& uv, u32 color) {
|
||||
cmd->AddIdx(0).AddIdx(1).AddIdx(2);
|
||||
cmd->AddIdx(0).AddIdx(2).AddIdx(3);
|
||||
cmd->AddVtx(Vertex(quad.BotRight(), uv.BotRight(), color));
|
||||
@@ -98,9 +96,8 @@ PD_LITHIUM_API void Renderer::CmdQuad(Command::Ref cmd, const Rect& quad,
|
||||
cmd->AddVtx(Vertex(quad.BotLeft(), uv.BotLeft(), color));
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Renderer::CmdTriangle(Command::Ref cmd, const fvec2 a,
|
||||
const fvec2 b, const fvec2 c,
|
||||
u32 clr) {
|
||||
PD_API void Renderer::CmdTriangle(Command::Ref cmd, const fvec2 a,
|
||||
const fvec2 b, const fvec2 c, u32 clr) {
|
||||
cmd->AddIdx(2).AddIdx(1).AddIdx(0);
|
||||
cmd->AddVtx(Vertex(a, vec2(0.f, 1.f), clr));
|
||||
cmd->AddVtx(Vertex(b, vec2(1.f, 1.f), clr));
|
||||
@@ -110,9 +107,9 @@ PD_LITHIUM_API void Renderer::CmdTriangle(Command::Ref cmd, const fvec2 a,
|
||||
// TODO: Don't render OOS (Probably make it with a define as it
|
||||
// would probably be faster to render out of screen than checking if
|
||||
// it could be skipped)
|
||||
PD_LITHIUM_API void Renderer::CmdConvexPolyFilled(
|
||||
Command::Ref cmd, const std::vector<fvec2>& points, u32 clr,
|
||||
Texture::Ref tex) {
|
||||
PD_API void Renderer::CmdConvexPolyFilled(Command::Ref cmd,
|
||||
const std::vector<fvec2>& points,
|
||||
u32 clr, Texture::Ref tex) {
|
||||
if (points.size() < 3 || tex == nullptr) {
|
||||
return; // Need at least three points
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user