Integrate all the progress into master #6
|
@ -7,7 +7,7 @@ include $(JABY_ENGINE_DIR)/lib/Wildcard.mk
|
|||
SRCS = $(call rwildcard, src, c cpp)
|
||||
|
||||
INCLUDES += -I$(JABY_ENGINE_DIR)/include
|
||||
#CCFLAGS += -save-temps=obj
|
||||
CCFLAGS += -save-temps=obj
|
||||
|
||||
include $(JABY_ENGINE_DIR)/lib/Makefile
|
||||
include $(JABY_ENGINE_DIR)/lib/PSEXETarget.mk
|
||||
|
|
|
@ -87,17 +87,26 @@ static constexpr const auto rectangle5 = JabyEngine::GPU::POLY_GT4(
|
|||
JabyEngine::GPU::Color24::White()}
|
||||
).set_semi_transparent(true);
|
||||
|
||||
static constexpr const auto line1 = JabyEngine::GPU::LINE_F::create(LineColor, {
|
||||
static constexpr const auto line1 = JabyEngine::GPU::LINE_F::create(LineColor,
|
||||
{0, 0},
|
||||
{JabyEngine::GPU::Display::Width, JabyEngine::GPU::Display::Height}
|
||||
});
|
||||
|
||||
);
|
||||
static constexpr const auto line2 = JabyEngine::GPU::LINE_F::create(LineColor.invert(),
|
||||
JabyEngine::GPU::Vertex(0, 0),
|
||||
JabyEngine::GPU::Vertex(16, 0),
|
||||
JabyEngine::GPU::Vertex(16, 16),
|
||||
JabyEngine::GPU::Vertex(0, 0)
|
||||
);
|
||||
static constexpr const auto line3 = JabyEngine::GPU::LINE_G::create(
|
||||
{LineColor, {JabyEngine::GPU::Display::Width, 0}},
|
||||
{LineColor.invert(), {0, JabyEngine::GPU::Display::Height}}
|
||||
);
|
||||
static constexpr const auto line4 = JabyEngine::GPU::LINE_G::create(
|
||||
JabyEngine::GPU::ColorVertex{JabyEngine::GPU::Color24::Red(), {0, 0}},
|
||||
JabyEngine::GPU::ColorVertex{JabyEngine::GPU::Color24::Green(), {0, 16}},
|
||||
JabyEngine::GPU::ColorVertex{JabyEngine::GPU::Color24::Blue(), {16, 16}},
|
||||
JabyEngine::GPU::ColorVertex{JabyEngine::GPU::Color24::White(), {0, 0}}
|
||||
);
|
||||
|
||||
static void load_assets() {
|
||||
static const JabyEngine::CDFile Assets[] = {
|
||||
|
@ -145,6 +154,8 @@ void main() {
|
|||
|
||||
JabyEngine::GPU::render(line1);
|
||||
JabyEngine::GPU::render(line2);
|
||||
JabyEngine::GPU::render(line3);
|
||||
JabyEngine::GPU::render(line4);
|
||||
|
||||
JabyEngine::GPU::swap_buffers_vsync(2);
|
||||
}
|
||||
|
|
|
@ -20,75 +20,103 @@ namespace JabyEngine {
|
|||
struct LineCodeInterface {
|
||||
typedef ::JabyEngine::GPU::internal::LineCode Code;
|
||||
|
||||
constexpr T& set_poly_line(bool set = true) {
|
||||
if(set) {
|
||||
static_cast<T*>(this)->code.set(Code::PolyLine);
|
||||
}
|
||||
else {
|
||||
static_cast<T*>(this)->code.set(Code::SingleLine);
|
||||
}
|
||||
return *static_cast<T*>(this);
|
||||
}
|
||||
|
||||
constexpr T& set_semi_transparent(bool set = true) {
|
||||
if(set) {
|
||||
static_cast<T*>(this)->code.set(Code::SemiTransparent);
|
||||
static_cast<T*>(this)->head.code.set(Code::SemiTransparent);
|
||||
}
|
||||
else {
|
||||
static_cast<T*>(this)->code.set(Code::NonTransparent);
|
||||
static_cast<T*>(this)->head.code.set(Code::NonTransparent);
|
||||
}
|
||||
return *static_cast<T*>(this);
|
||||
}
|
||||
};
|
||||
|
||||
struct LineHead : public LineCodeInterface<LineHead> {
|
||||
Color24 color;
|
||||
Code code;
|
||||
};
|
||||
|
||||
union LineUnion {
|
||||
LineHead head;
|
||||
Vertex vertex;
|
||||
struct LineHead {
|
||||
Color24 color;
|
||||
LineCode code;
|
||||
|
||||
static constexpr LineUnion create_head(const Color24& color, const LineCode& code, bool is_poly) {
|
||||
return LineUnion{.head = LineHead{.color = color, .code = code}.set_poly_line(is_poly)};
|
||||
static constexpr LineHead create(const Color24& color, const LineCode& code, bool is_poly) {
|
||||
return LineHead{.color = color, .code = code}.set_poly_line(is_poly);
|
||||
}
|
||||
|
||||
static constexpr LineUnion create_vertex(const Vertex& vertex) {
|
||||
return LineUnion{.vertex = {vertex.x, vertex.y}};
|
||||
}
|
||||
constexpr LineHead& set_poly_line(bool set = true) {
|
||||
if(set) {
|
||||
this->code.set(LineCode::PolyLine);
|
||||
}
|
||||
|
||||
static constexpr LineUnion create_terminate() {
|
||||
return LineUnion{.vertex = {static_cast<short>(0x5000), static_cast<short>(0x5000)}};
|
||||
else {
|
||||
this->code.set(LineCode::SingleLine);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template<size_t N>
|
||||
struct Line {
|
||||
LineUnion data[N];
|
||||
struct Termination {
|
||||
Vertex value;
|
||||
|
||||
static constexpr Termination create() {
|
||||
return {.value = {static_cast<short>(0x5000), static_cast<short>(0x5000)}};
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Body>
|
||||
struct SingleLine : public LineCodeInterface<SingleLine<Body>> {
|
||||
LineHead head;
|
||||
Vertex start_point;
|
||||
Body end_point;
|
||||
};
|
||||
|
||||
template<typename Body, size_t N>
|
||||
struct MultiLine : public LineCodeInterface<MultiLine<Body, N>> {
|
||||
LineHead head;
|
||||
Vertex start_point;
|
||||
Body points[N];
|
||||
Termination end;
|
||||
};
|
||||
}
|
||||
|
||||
struct LINE_F {
|
||||
typedef ::JabyEngine::GPU::internal::LineCode Code;
|
||||
typedef ::JabyEngine::GPU::internal::LineUnion LineUnion;
|
||||
typedef internal::LineCode Code;
|
||||
|
||||
static constexpr auto IdentityCode = Code().set(Code::FlatShading).set(Code::SingleLine).set(Code::NonTransparent);
|
||||
|
||||
static constexpr internal::Line<3> create(const Color24& color, const Vertex (&vertices)[2]) {
|
||||
return internal::Line<3>{LineUnion::create_head(color, IdentityCode, false), LineUnion::create_vertex(vertices[0]), LineUnion::create_vertex(vertices[1])};
|
||||
static constexpr internal::SingleLine<Vertex> create(const Color24& color, const Vertex& start_point, const Vertex& end_point) {
|
||||
using namespace internal;
|
||||
return {.head = LineHead::create(color, IdentityCode, false), .start_point = start_point, .end_point = end_point};
|
||||
}
|
||||
|
||||
template<typename...ARGS>
|
||||
static constexpr internal::Line<sizeof...(ARGS) + 2> create(const Color24& color, const ARGS&...args) {
|
||||
return internal::Line<sizeof...(ARGS) + 2>{LineUnion::create_head(color, IdentityCode, true), LineUnion::create_vertex(args)..., LineUnion::create_terminate()};
|
||||
static constexpr internal::MultiLine<Vertex, sizeof...(ARGS)> create(const Color24& color, const Vertex& start_point, const ARGS&...rest) {
|
||||
using namespace internal;
|
||||
return {.head = LineHead::create(color, IdentityCode, true), .start_point = start_point, .points = {rest...}, .end = Termination::create()};
|
||||
}
|
||||
};
|
||||
|
||||
struct LINE_G {
|
||||
typedef LINE_F::Code Code;
|
||||
|
||||
static constexpr auto IdentityCode = Code(LINE_F::IdentityCode).set(Code::GouraudShading);
|
||||
|
||||
static constexpr internal::SingleLine<ColorVertex> create(const ColorVertex& start_point, const ColorVertex& end_point) {
|
||||
using namespace internal;
|
||||
return {.head = LineHead::create(start_point.color, IdentityCode, false), .start_point = start_point.position, .end_point = end_point};
|
||||
}
|
||||
|
||||
template<typename...ARGS>
|
||||
static constexpr internal::MultiLine<ColorVertex, sizeof...(ARGS)> create(const ColorVertex& start_point, const ARGS&...rest) {
|
||||
using namespace internal;
|
||||
return {.head = LineHead::create(start_point.color, IdentityCode, true), .start_point = start_point.position, .points = {rest...}, .end = Termination::create()};
|
||||
}
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
template<size_t N>
|
||||
struct is_render_primitive<Line<N>> {
|
||||
template<typename T>
|
||||
struct is_render_primitive<SingleLine<T>> {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template<typename T, size_t N>
|
||||
struct is_render_primitive<MultiLine<T, N>> {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -101,10 +101,6 @@ namespace JabyEngine {
|
|||
};
|
||||
|
||||
struct POLY_G3 : public internal::PolyCodeInterface<POLY_G3> {
|
||||
struct VertexEx {
|
||||
Vertex position;
|
||||
Color24 color;
|
||||
};
|
||||
static constexpr auto IdentityCode = Code(POLY_F3::IdentityCode).set(Code::GouraudShading);
|
||||
|
||||
Color24 color0; // a
|
||||
|
@ -122,7 +118,7 @@ namespace JabyEngine {
|
|||
{verticies[0], color[0]},
|
||||
{verticies[1], color[1]},
|
||||
{verticies[2], color[2]}}) {}
|
||||
constexpr POLY_G3(const VertexEx (&verticies_ex)[3]) :
|
||||
constexpr POLY_G3(const VertexColor (&verticies_ex)[3]) :
|
||||
color0(verticies_ex[0].color), code(IdentityCode), vertex0(verticies_ex[0].position),
|
||||
color1(verticies_ex[1].color), pad1(0), vertex1(verticies_ex[1].position),
|
||||
color2(verticies_ex[2].color), pad2(0), vertex2(verticies_ex[2].position) {}
|
||||
|
@ -234,7 +230,6 @@ namespace JabyEngine {
|
|||
};
|
||||
|
||||
struct POLY_G4 : public internal::PolyCodeInterface<POLY_G4> {
|
||||
typedef POLY_G3::VertexEx VertexEx;
|
||||
static constexpr auto IdentityCode = Code(POLY_G3::IdentityCode).set(Code::QuadVertics);
|
||||
|
||||
Color24 color0; // a
|
||||
|
@ -257,7 +252,7 @@ namespace JabyEngine {
|
|||
{verticies[2], color[2]},
|
||||
{verticies[3], color[3]}
|
||||
}) {}
|
||||
constexpr POLY_G4(const VertexEx (&verticies_ex)[4]) :
|
||||
constexpr POLY_G4(const VertexColor (&verticies_ex)[4]) :
|
||||
color0(verticies_ex[0].color), code(IdentityCode), vertex0(verticies_ex[0].position),
|
||||
color1(verticies_ex[1].color), pad1(0), vertex1(verticies_ex[1].position),
|
||||
color2(verticies_ex[2].color), pad2(0), vertex2(verticies_ex[2].position),
|
||||
|
|
|
@ -168,6 +168,16 @@ namespace JabyEngine {
|
|||
|
||||
// Type used for primitives
|
||||
typedef PositionI16 Vertex;
|
||||
|
||||
struct VertexColor {
|
||||
Vertex position;
|
||||
Color24 color;
|
||||
};
|
||||
|
||||
struct ColorVertex {
|
||||
Color24 color;
|
||||
alignas(2) Vertex position;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif //!__JABYENGINE_GPU_TYPES_HPP__
|
Loading…
Reference in New Issue