SetVertices() now takes in a width and height instead of right and bottom
This commit is contained in:
parent
0625040304
commit
904726aba6
14
Program.cs
14
Program.cs
@ -285,7 +285,7 @@ public class Game : GameWindow {
|
|||||||
int photoWidth = (int) (1.0 * windowHeight / active.Height * active.Width);
|
int photoWidth = (int) (1.0 * windowHeight / active.Height * active.Width);
|
||||||
int letterboxWidth = (maxPhotoWidth - photoWidth) / 2;
|
int letterboxWidth = (maxPhotoWidth - photoWidth) / 2;
|
||||||
|
|
||||||
SetVertices(letterboxWidth, 0, photoWidth + letterboxWidth, windowHeight);
|
SetVertices(letterboxWidth, 0, photoWidth, windowHeight);
|
||||||
GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferObject);
|
GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferObject);
|
||||||
GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.DynamicDraw);
|
GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.DynamicDraw);
|
||||||
GL.ActiveTexture(TextureUnit.Texture0);
|
GL.ActiveTexture(TextureUnit.Texture0);
|
||||||
@ -294,7 +294,7 @@ public class Game : GameWindow {
|
|||||||
GL.DrawElements(PrimitiveType.Triangles, indices.Length, DrawElementsType.UnsignedInt, 0);
|
GL.DrawElements(PrimitiveType.Triangles, indices.Length, DrawElementsType.UnsignedInt, 0);
|
||||||
|
|
||||||
for (int i = 0; i < textures.Count; i++) {
|
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.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferObject);
|
||||||
GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.DynamicDraw);
|
GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.DynamicDraw);
|
||||||
GL.ActiveTexture(TextureUnit.Texture0);
|
GL.ActiveTexture(TextureUnit.Texture0);
|
||||||
@ -317,7 +317,7 @@ public class Game : GameWindow {
|
|||||||
GL.Viewport(0, 0, windowWidth, windowHeight);
|
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
|
// top left
|
||||||
vertices[0] = left;
|
vertices[0] = left;
|
||||||
vertices[1] = top;
|
vertices[1] = top;
|
||||||
@ -326,22 +326,22 @@ public class Game : GameWindow {
|
|||||||
vertices[4] = 0f;
|
vertices[4] = 0f;
|
||||||
|
|
||||||
// top right
|
// top right
|
||||||
vertices[5] = right;
|
vertices[5] = left + width;
|
||||||
vertices[6] = top;
|
vertices[6] = top;
|
||||||
vertices[7] = 0f;
|
vertices[7] = 0f;
|
||||||
vertices[8] = 1f;
|
vertices[8] = 1f;
|
||||||
vertices[9] = 0f;
|
vertices[9] = 0f;
|
||||||
|
|
||||||
// bottom right
|
// bottom right
|
||||||
vertices[10] = right;
|
vertices[10] = left + width;
|
||||||
vertices[11] = bottom;
|
vertices[11] = top + height;
|
||||||
vertices[12] = 0f;
|
vertices[12] = 0f;
|
||||||
vertices[13] = 1f;
|
vertices[13] = 1f;
|
||||||
vertices[14] = 1f;
|
vertices[14] = 1f;
|
||||||
|
|
||||||
// bottom left
|
// bottom left
|
||||||
vertices[15] = left;
|
vertices[15] = left;
|
||||||
vertices[16] = bottom;
|
vertices[16] = top + height;
|
||||||
vertices[17] = 0f;
|
vertices[17] = 0f;
|
||||||
vertices[18] = 0f;
|
vertices[18] = 0f;
|
||||||
vertices[19] = 1f;
|
vertices[19] = 1f;
|
||||||
|
Loading…
Reference in New Issue
Block a user