36 lines
890 B
C
36 lines
890 B
C
/**
|
|
* Copyright (c) 2021 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "rectangle.h"
|
|
|
|
void rectangleInit(rectangle_t *rectangle) {
|
|
rectangle->width = 32;
|
|
rectangle->height = 32;
|
|
textureInit(&rectangle->texture, 1, 1, NULL);
|
|
quadInit(&rectangle->quad, 0, 0,0,0,0, 1,1,1,1);
|
|
}
|
|
|
|
void rectangleSetColor(rectangle_t *rectangle, pixel_t color) {
|
|
textureBufferPixels(&rectangle->texture,
|
|
0, 0, 1, 1, &color
|
|
);
|
|
}
|
|
|
|
void rectangleRender(rectangle_t *rect, shader_t *shader, float x, float y) {
|
|
shaderUsePositionAndScale(shader,
|
|
x, y, 0,
|
|
0, 0, 0,
|
|
rect->width, rect->height, 1
|
|
);
|
|
shaderUseTexture(shader, &rect->texture);
|
|
primitiveDraw(&rect->quad, 0, -1);
|
|
}
|
|
|
|
void rectangleDispose(rectangle_t *rectangle) {
|
|
primitiveDispose(&rectangle->quad);
|
|
textureDispose(&rectangle->texture);
|
|
} |