-
Notifications
You must be signed in to change notification settings - Fork 5
Rendering Shapes and Textures with gl2d
Vlod edited this page Nov 23, 2023
·
7 revisions
Because I have many overloads, I will explain what each parameter and each function do.
- renderRectangle: renders a solid color rectangle or with a texture. The rotation is relevant to the object
- renderRectangleAbsRotation: the rotation is relative to the screen rather than the object.
- renderLine: renders a line.
- renderRectangleOutline: renders a rectangle's outline with lines.
- renderCircleOutline: renders a circle outline.
- render9Patch/render9Patch2 used for ui. draws a texture that scales the margins differently so buttons of different sizes can be drawn.
Whenever a method requests a transform as a vec4, it is encoded as X, Y, Width, and Height. Example:
renderer.renderRectangle(glm::vec4{200, 350, 25,25}, Colors_Orange);
//renders an orange rectangle, 200 pixels from the left of the window, and 350 pixels from the top of the window, with a 25 by 25 pixels size.
- transform: explained above, please read :D
- texture: texture to be applied to the rectangle. A separate section on those.
- colors: the color to be applied to the rectangle (with transparency)
- colors[4]: a gradient to be applied to the rectangle (one color for each corner)
- origin: the origin when rotating the object
- rotationDegrees: rotation in degrees :(
- textureCoords: the texture coords for the textures to be sampled from. Basically, we have a vec4 that describes the bottom left point and the top right point of the texture.
renderer.renderRectangle({100,350, 100, 100}, texture, {1,1,1,1}, {}, t);
renderer.renderRectangleOutline({100,350, 100, 100}, {1,1,1,0.5}, 10, {}, t);
renderer.renderRectangle({150,400, 2, 2}, Colors_Orange, {}, t);
renderer.renderRectangle({200,150, 100, 100}, texture, {1,1,1,1}, {}, t);
renderer.renderRectangleOutline({200,150, 100, 100}, {1,1,1,0.5}, 10, {}, t);
renderer.renderRectangle({-1,-1, 2, 2}, Colors_Orange, {}, t);
renderer.renderCircleOutline({500,200}, Colors_Orange, 100);