diff --git a/Program.cs b/Program.cs index ffff5fc..e654a7f 100644 --- a/Program.cs +++ b/Program.cs @@ -50,9 +50,10 @@ void main(void) { out vec4 outputColor; in vec2 texCoord; uniform sampler2D texture0; +uniform vec4 color; void main() { - outputColor = texture(texture0, texCoord); + outputColor = texture(texture0, texCoord) * color; }"; VertexShader = GL.CreateShader(ShaderType.VertexShader); @@ -306,7 +307,7 @@ public class Game : GameWindow { Rectangle box = new Rectangle(windowWidth - thumbnailWidth, i * thumbnailHeight, thumbnailWidth, thumbnailHeight); DrawTexture(textures[i], box); if (i == textureIndex) { - DrawBox(box, 3); + DrawBox(box, 3, new Color4(1f, 1f, 0f, 1f)); } } @@ -314,17 +315,22 @@ public class Game : GameWindow { } void DrawTexture(Texture texture, Rectangle box) { + DrawTexture(texture, box, new Color4(1f, 1f, 1f, 1f)); + } + + void DrawTexture(Texture texture, Rectangle box, Color4 color) { + GL.Uniform4(shader.GetUniformLocation("color"), color.R, color.G, color.B, color.A); SetVertices(box.Left, box.Top, box.Width, box.Height); GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.DynamicDraw); GL.BindTexture(TextureTarget.Texture2D, texture.Handle); GL.DrawElements(PrimitiveType.Triangles, indices.Length, DrawElementsType.UnsignedInt, 0); } - void DrawBox(Rectangle box, int thickness) { - DrawTexture(TEXTURE_WHITE, new Rectangle(box.Left, box.Top, box.Width, thickness)); - DrawTexture(TEXTURE_WHITE, new Rectangle(box.Left, box.Top, thickness, box.Height)); - DrawTexture(TEXTURE_WHITE, new Rectangle(box.Left, box.Top + box.Height - thickness, box.Width, thickness)); - DrawTexture(TEXTURE_WHITE, new Rectangle(box.Left + box.Width - thickness, box.Top, thickness, box.Height)); + void DrawBox(Rectangle box, int thickness, Color4 color) { + DrawTexture(TEXTURE_WHITE, new Rectangle(box.Left, box.Top, box.Width, thickness), color); + DrawTexture(TEXTURE_WHITE, new Rectangle(box.Left, box.Top, thickness, box.Height), color); + DrawTexture(TEXTURE_WHITE, new Rectangle(box.Left, box.Top + box.Height - thickness, box.Width, thickness), color); + DrawTexture(TEXTURE_WHITE, new Rectangle(box.Left + box.Width - thickness, box.Top, thickness, box.Height), color); } protected override void OnResize(ResizeEventArgs e) {