-
Notifications
You must be signed in to change notification settings - Fork 0
Objects
Class LibGui::Object is for simple objects made up from vertexes.
There are 8 constructors you can use to create LibGui::Object, but they are very similar and differ in only few parameters. Only irreversible parameter is shape, which is generated by one of shape generator functions.
// the 'normal' one, you will use most
Object(const Vec2 position, const Vec2 scale, const Color color, const Shapes::Shape& shape, const int UniformFlags = 0);
// example
LibGui::Object MyObject({250, 250}, {200, 200}, Color::Red, LibGui::Shapes::Rectangle());
// variant of previous, where instead of color you can pass texture on object
// this variant is also for every next constructor, but the concept is same so I won't list it.
Object(const Vec2 position, const Vec2 scale, Texture& texture, const Shapes::Shape& shape, const int UniformFlags = 0);
// here you can also set a window, if you have more of them
Object(const Vec2 position, const Vec2 scale, const Color color, const Shapes::Shape& shape, Window& window, const int UniformFlags = 0);
// use custom shader
Object(const Vec2 position, const Vec2 scale, const Color color, const Shapes::Shape& shape, Shader& shader, const int UniformFlags = 0);
// combination of last two constructors
Object(const Vec2 position, const Vec2 scale, const Color color, const Shapes::Shape& shape, Window& window, Shader& shader, const int UniformFlags = 0);| Property | Description |
|---|---|
Vec2 pos
|
position of object in pixels or (from -1 to 1) based on UniformFlags |
Vec2 scale
|
object vertex position multiplier, so if you put vertex of LibGui::Object on position {0, 1} and set scale to {5, 53.5}, it will end up on {0, 53.5} |
Vec2 color
|
coefficient for all objects vertex colors |
float direction |
rotation of object in degrees |
char UniformFlags |
has it's own page here |
Vec2& shader
|
is reference to a LibGui::Shader object, this object will be used for rendering |
Vec2* texture
|
pointer to texture of this object, if nullptr, no texture is used |
Use LibGui::Object::Render(...) to render objects, this will send uniforms like scale or position to GPU, then render, if you want to send those uniforms yourself (for example, if you have custom shader) set custom_uniSetup to true like LibGui::Object::Render(true).
Theese tell the uniform setup function how to translate position, scale and how to render it. On default these are set to
|Render as polygon|read scale y in pixels|read scale x in pixels|read position y in pixels|read position x in pixels
but you can change it like this:
// create flags with normalized x position and x scale
char myFlags = UniformFlag_XPos_Normalized | UniformFlag_XScale_Normalized;
MyObject.UniFlags = myFlags;
MyObject.pos = {0.5f, 200.0f};
MyObject.scale = {1, 100};The pixel coordinate system is inspired by raylib's one, it's in pixels and {0, 0} is in upper left corner.
To read more about normalized coordinates go here, press Ctrl+F and serach NDC.
Features