# 0.2.6-2
- Add Scissor (CLIP RECT) to lithium commands and UI7 Drawlist API - Enable ClipRect to UI7::Menu (probably create a enable/disable flag)
This commit is contained in:
@ -38,9 +38,9 @@ SOFTWARE.
|
||||
#include <pd/lithium/renderer.hpp>
|
||||
#include <pd/lithium/spritesheet.hpp>
|
||||
// Image
|
||||
#include <pd/image/image.hpp>
|
||||
#include <pd/image/img_blur.hpp>
|
||||
#include <pd/image/img_convert.hpp>
|
||||
#include <pd/image/img_edit.hpp>
|
||||
// Drivers
|
||||
#include <pd/drivers/hid.hpp>
|
||||
// Overlays
|
||||
|
@ -34,6 +34,7 @@ SOFTWARE.
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -27,15 +27,15 @@ SOFTWARE.
|
||||
#include <pd/core/common.hpp>
|
||||
|
||||
namespace PD {
|
||||
class ImgEdit {
|
||||
class Image {
|
||||
public:
|
||||
ImgEdit() = default;
|
||||
ImgEdit(const std::string& path) { this->Load(path); }
|
||||
ImgEdit(const std::vector<u8>& buf) { this->Load(buf); }
|
||||
ImgEdit(const std::vector<u8>& buf, int w, int h, int fmt = 4) {
|
||||
Image() = default;
|
||||
Image(const std::string& path) { this->Load(path); }
|
||||
Image(const std::vector<u8>& buf) { this->Load(buf); }
|
||||
Image(const std::vector<u8>& buf, int w, int h, int fmt = 4) {
|
||||
this->Copy(buf, w, h, fmt);
|
||||
}
|
||||
~ImgEdit() = default;
|
||||
~Image() = default;
|
||||
|
||||
void Load(const std::string& path);
|
||||
void Load(const std::vector<u8>& buf);
|
@ -167,6 +167,24 @@ class Command : public SmartCtor<Command> {
|
||||
*/
|
||||
RenderMode Rendermode() const { return mode; }
|
||||
|
||||
/** Setter for Scissor Mode */
|
||||
Command& SetScissorMode(ScissorMode mode) {
|
||||
scissor = mode;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Getter for Scissor Mode */
|
||||
ScissorMode GetScissorMode() const { return scissor; }
|
||||
|
||||
/** Setter for Scissor Area */
|
||||
Command& ScissorRect(const vec4& v) {
|
||||
scissor_area = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Getter for Scissor Area */
|
||||
vec4 ScissorRect() const { return scissor_area; }
|
||||
|
||||
private:
|
||||
/**
|
||||
* Vertex Buffer
|
||||
@ -188,6 +206,10 @@ class Command : public SmartCtor<Command> {
|
||||
int index;
|
||||
/** RenderMode (Default to RenderMode_RGBA) */
|
||||
RenderMode mode = RenderMode_RGBA;
|
||||
/** Scissor Mode (for defined area to render) */
|
||||
ScissorMode scissor = ScissorMode_None;
|
||||
/** scissor box (top left and bottom right) */
|
||||
vec4 scissor_area;
|
||||
};
|
||||
} // namespace LI
|
||||
} // namespace PD
|
@ -61,5 +61,11 @@ enum RenderMode {
|
||||
RenderMode_RGBA, ///< RGBA [for textures or solid colors]
|
||||
RenderMode_Font, ///< A8 [for textures only crated by 1 color channel]
|
||||
};
|
||||
/** Scissor Mode (for ClipRect related rendering) */
|
||||
enum ScissorMode {
|
||||
ScissorMode_None = 0, ///< No Scissor
|
||||
ScissorMode_Inverted = 1, ///< Render Pixels outside the box
|
||||
ScissorMode_Normal = 3, ///< Only render pixels inside the box
|
||||
};
|
||||
} // namespace LI
|
||||
} // namespace PD
|
@ -118,6 +118,26 @@ class StaticObject : public SmartCtor<StaticObject> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a Custom Scissor Mode for Object Copy List
|
||||
* @param m New Mode to Set
|
||||
*/
|
||||
void ReSetScissorMode(ScissorMode m) {
|
||||
for (auto& i : cpy) {
|
||||
i->SetScissorMode(m);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Custom Scissor Rect to All Objects
|
||||
* @param v Scissor Rect to set
|
||||
*/
|
||||
void ReScissorRect(const vec4& v) {
|
||||
for (auto& i : cpy) {
|
||||
i->ScissorRect(v);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Reference to the Copy Commands List
|
||||
* @return command list reference
|
||||
@ -296,6 +316,18 @@ class StaticText : public SmartCtor<StaticText> {
|
||||
*/
|
||||
Font::Ref Font() { return font; }
|
||||
|
||||
/**
|
||||
* Set a Custom Scissor Mode Static Text
|
||||
* @param m New Mode to Set
|
||||
*/
|
||||
void SetScissorMode(ScissorMode m) { text->ReSetScissorMode(m); }
|
||||
|
||||
/**
|
||||
* Set Custom Scissor Rect to Static Text
|
||||
* @param v Scissor Rect to set
|
||||
*/
|
||||
void ScissorRect(const vec4& v) { text->ReScissorRect(v); }
|
||||
|
||||
private:
|
||||
/** Font */
|
||||
Font::Ref font;
|
||||
|
@ -85,6 +85,12 @@ class DrawList : public SmartCtor<DrawList> {
|
||||
/** Process [Render] the Drawlist */
|
||||
void Process();
|
||||
|
||||
/** Push a Clip Rect */
|
||||
void PushClipRect(const vec4& v) { clip_rects.push(v); }
|
||||
|
||||
/** Revert Last Clip Rect */
|
||||
void PopClipRect() { clip_rects.pop(); }
|
||||
|
||||
/** Getter for the Layer */
|
||||
int Layer() const { return layer; }
|
||||
/** Setter fot the Layer */
|
||||
@ -100,9 +106,10 @@ class DrawList : public SmartCtor<DrawList> {
|
||||
friend class Menu;
|
||||
friend class Context;
|
||||
|
||||
int layer; ///< Current Layer
|
||||
int base; ///< Base Layer
|
||||
LI::Renderer::Ref ren; ///< Renderer Reference
|
||||
int layer; ///< Current Layer
|
||||
int base; ///< Base Layer
|
||||
LI::Renderer::Ref ren; ///< Renderer Reference
|
||||
std::stack<vec4> clip_rects; ///< Stack containing Scissor Areas
|
||||
// Map for Auto Static Text
|
||||
std::unordered_map<u32, LI::StaticText::Ref> static_text;
|
||||
// List of Drawcommands generated
|
||||
|
Reference in New Issue
Block a user