diff --git a/ComputerGraphicsLab2/ComputerGraphicsLab2.csproj b/ComputerGraphicsLab2/ComputerGraphicsLab2.csproj index aaadea9..9f75a9f 100644 --- a/ComputerGraphicsLab2/ComputerGraphicsLab2.csproj +++ b/ComputerGraphicsLab2/ComputerGraphicsLab2.csproj @@ -33,6 +33,15 @@ 4 + + Lib\OpenTK.dll + + + Lib\OpenTK.Compatibility.dll + + + Lib\OpenTK.GLControl.dll + @@ -54,6 +63,9 @@ + + Form1.cs + ResXFileCodeGenerator Resources.Designer.cs @@ -76,5 +88,8 @@ + + + \ No newline at end of file diff --git a/ComputerGraphicsLab2/Form1.Designer.cs b/ComputerGraphicsLab2/Form1.Designer.cs index 32c849c..b28dc41 100644 --- a/ComputerGraphicsLab2/Form1.Designer.cs +++ b/ComputerGraphicsLab2/Form1.Designer.cs @@ -29,12 +29,32 @@ namespace ComputerGraphicsLab2 /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + this.glControl1 = new OpenTK.GLControl(); + this.SuspendLayout(); + // + // glControl1 + // + this.glControl1.BackColor = System.Drawing.Color.Black; + this.glControl1.Location = new System.Drawing.Point(12, 12); + this.glControl1.Name = "glControl1"; + this.glControl1.Size = new System.Drawing.Size(776, 426); + this.glControl1.TabIndex = 0; + this.glControl1.VSync = false; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.glControl1); + this.Name = "Form1"; this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + this.ResumeLayout(false); } + private OpenTK.GLControl glControl1; + #endregion } } \ No newline at end of file diff --git a/ComputerGraphicsLab2/Form1.cs b/ComputerGraphicsLab2/Form1.cs index d7952eb..559d716 100644 --- a/ComputerGraphicsLab2/Form1.cs +++ b/ComputerGraphicsLab2/Form1.cs @@ -1,20 +1,48 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; +using OpenTK; +using OpenTK.Graphics; +using OpenTK.Graphics.OpenGL; +using OpenTK.Input; +using System.Drawing; +using BeginMode = OpenTK.Graphics.OpenGL.BeginMode; +using ClearBufferMask = OpenTK.Graphics.OpenGL.ClearBufferMask; +using GL = OpenTK.Graphics.OpenGL.GL; namespace ComputerGraphicsLab2 { public partial class Form1 : Form { + private int CubeSize = 128; + public Form1() { InitializeComponent(); } + + private void Form1_Load(object sender, EventArgs e) + { + var width = 512; + var height = 512; + + var left = (width - CubeSize) / 2; + var right = left + CubeSize; + var bottom = (height - CubeSize) / 2; + var top = bottom + CubeSize; + + GL.ClearColor(Color.White); + GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); + GL.Color3(255, 0, 0); + GL.Begin(BeginMode.Quads); + GL.Vertex2(left, bottom); + GL.Vertex2(left, top); + GL.Vertex2(right, bottom); + GL.Vertex2(right, top); + GL.End(); + } + + private void glControl1_Load(object sender, EventArgs e) + { + } } } \ No newline at end of file