SetVertices() now takes in a width and height instead of right and bottom

This commit is contained in:
Colin McMillen 2023-06-29 22:57:38 -04:00
parent 0625040304
commit 904726aba6

View File

@ -285,7 +285,7 @@ public class Game : GameWindow {
int photoWidth = (int) (1.0 * windowHeight / active.Height * active.Width);
int letterboxWidth = (maxPhotoWidth - photoWidth) / 2;
SetVertices(letterboxWidth, 0, photoWidth + letterboxWidth, windowHeight);
SetVertices(letterboxWidth, 0, photoWidth, windowHeight);
GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferObject);
GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.DynamicDraw);
GL.ActiveTexture(TextureUnit.Texture0);
@ -294,7 +294,7 @@ public class Game : GameWindow {
GL.DrawElements(PrimitiveType.Triangles, indices.Length, DrawElementsType.UnsignedInt, 0);
for (int i = 0; i < textures.Count; i++) {
SetVertices(windowWidth - thumbnailWidth, i * thumbnailHeight, windowWidth, i * thumbnailHeight + thumbnailHeight - borderWidth);
SetVertices(windowWidth - thumbnailWidth, i * thumbnailHeight, thumbnailWidth, thumbnailHeight - borderWidth);
GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferObject);
GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.DynamicDraw);
GL.ActiveTexture(TextureUnit.Texture0);
@ -317,7 +317,7 @@ public class Game : GameWindow {
GL.Viewport(0, 0, windowWidth, windowHeight);
}
private void SetVertices(float left, float top, float right, float bottom) {
private void SetVertices(float left, float top, float width, float height) {
// top left
vertices[0] = left;
vertices[1] = top;
@ -326,22 +326,22 @@ public class Game : GameWindow {
vertices[4] = 0f;
// top right
vertices[5] = right;
vertices[5] = left + width;
vertices[6] = top;
vertices[7] = 0f;
vertices[8] = 1f;
vertices[9] = 0f;
// bottom right
vertices[10] = right;
vertices[11] = bottom;
vertices[10] = left + width;
vertices[11] = top + height;
vertices[12] = 0f;
vertices[13] = 1f;
vertices[14] = 1f;
// bottom left
vertices[15] = left;
vertices[16] = bottom;
vertices[16] = top + height;
vertices[17] = 0f;
vertices[18] = 0f;
vertices[19] = 1f;