make Draw{Box,Texture} take a Rectangle

This commit is contained in:
Colin McMillen 2023-07-06 21:55:51 -04:00
parent 536abbf2b4
commit 4ed9ed0796

View File

@ -308,16 +308,20 @@ public class Game : GameWindow {
DrawTexture(active, letterboxWidth, 0, photoWidth, windowHeight); DrawTexture(active, letterboxWidth, 0, photoWidth, windowHeight);
for (int i = 0; i < textures.Count; i++) { for (int i = 0; i < textures.Count; i++) {
// FIXME: make this a rect or something Rectangle box = new Rectangle(windowWidth - thumbnailWidth, i * thumbnailHeight, thumbnailWidth, thumbnailHeight - borderWidth);
DrawTexture(textures[i], windowWidth - thumbnailWidth, i * thumbnailHeight, thumbnailWidth, thumbnailHeight - borderWidth); DrawTexture(textures[i], box);
if (i == textureIndex) { if (i == textureIndex) {
DrawBox(windowWidth - thumbnailWidth, i * thumbnailHeight, thumbnailWidth, thumbnailHeight - borderWidth, 2); DrawBox(box, 2);
} }
} }
SwapBuffers(); SwapBuffers();
} }
void DrawTexture(Texture texture, Rectangle box) {
DrawTexture(texture, box.Left, box.Top, box.Width, box.Height);
}
void DrawTexture(Texture texture, int left, int top, int width, int height) { void DrawTexture(Texture texture, int left, int top, int width, int height) {
SetVertices(left, top, width, height); SetVertices(left, top, width, height);
GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.DynamicDraw); GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.DynamicDraw);
@ -325,6 +329,10 @@ public class Game : GameWindow {
GL.DrawElements(PrimitiveType.Triangles, indices.Length, DrawElementsType.UnsignedInt, 0); GL.DrawElements(PrimitiveType.Triangles, indices.Length, DrawElementsType.UnsignedInt, 0);
} }
void DrawBox(Rectangle box, int thickness) {
DrawBox(box.Left, box.Top, box.Width, box.Height, thickness);
}
void DrawBox(int left, int top, int width, int height, int thickness) { void DrawBox(int left, int top, int width, int height, int thickness) {
DrawTexture(TEXTURE_WHITE, left, top, width, thickness); DrawTexture(TEXTURE_WHITE, left, top, width, thickness);
DrawTexture(TEXTURE_WHITE, left, top, thickness, height); DrawTexture(TEXTURE_WHITE, left, top, thickness, height);