implement not working example

This commit is contained in:
Elizaveta Chirkova 2025-09-09 17:25:48 +05:00
parent 6f7882ba7c
commit 378e9cb979
3 changed files with 71 additions and 8 deletions

View file

@ -33,6 +33,15 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="OpenTK">
<HintPath>Lib\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.Compatibility">
<HintPath>Lib\OpenTK.Compatibility.dll</HintPath>
</Reference>
<Reference Include="OpenTK.GLControl">
<HintPath>Lib\OpenTK.GLControl.dll</HintPath>
</Reference>
<Reference Include="System"/> <Reference Include="System"/>
<Reference Include="System.Core"/> <Reference Include="System.Core"/>
<Reference Include="System.Xml.Linq"/> <Reference Include="System.Xml.Linq"/>
@ -54,6 +63,9 @@
</Compile> </Compile>
<Compile Include="Program.cs"/> <Compile Include="Program.cs"/>
<Compile Include="Properties\AssemblyInfo.cs"/> <Compile Include="Properties\AssemblyInfo.cs"/>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
@ -76,5 +88,8 @@
<ItemGroup> <ItemGroup>
<None Include="App.config"/> <None Include="App.config"/>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Lib\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
</Project> </Project>

View file

@ -29,12 +29,32 @@ namespace ComputerGraphicsLab2
/// </summary> /// </summary>
private void InitializeComponent() 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.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.glControl1);
this.Name = "Form1";
this.Text = "Form1"; this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
} }
private OpenTK.GLControl glControl1;
#endregion #endregion
} }
} }

View file

@ -1,20 +1,48 @@
using System; 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 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 namespace ComputerGraphicsLab2
{ {
public partial class Form1 : Form public partial class Form1 : Form
{ {
private int CubeSize = 128;
public Form1() public Form1()
{ {
InitializeComponent(); 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)
{
}
} }
} }