Add project files.
This commit is contained in:
6
WhatTheTexture/App.config
Normal file
6
WhatTheTexture/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
25
WhatTheTexture/OpenTK.dll.config
Normal file
25
WhatTheTexture/OpenTK.dll.config
Normal file
@@ -0,0 +1,25 @@
|
||||
<configuration>
|
||||
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
|
||||
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
|
||||
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
|
||||
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
|
||||
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
|
||||
<dllmap os="linux" dll="libX11" target="libX11.so.6"/>
|
||||
<dllmap os="linux" dll="libXi" target="libXi.so.6"/>
|
||||
<dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/>
|
||||
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
|
||||
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
|
||||
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
|
||||
<!-- XQuartz compatibility (X11 on Mac) -->
|
||||
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
|
||||
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
|
||||
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
|
||||
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
|
||||
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
|
||||
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
|
||||
</configuration>
|
||||
79
WhatTheTexture/Program.cs
Normal file
79
WhatTheTexture/Program.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using PixelFormat = OpenTK.Graphics.OpenGL.PixelFormat;
|
||||
|
||||
namespace WhatTheTexture
|
||||
{
|
||||
internal class Program : GameWindow
|
||||
{
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
Width = 1920;
|
||||
Height = 1080;
|
||||
X = (DisplayDevice.Default.Width - Width) / 2;
|
||||
Y = (DisplayDevice.Default.Height - Height) / 2;
|
||||
|
||||
GL.Enable(EnableCap.Texture2D);
|
||||
|
||||
var image = new Bitmap("tex.png");
|
||||
|
||||
var texID = GL.GenTexture();
|
||||
|
||||
GL.ActiveTexture(TextureUnit.Texture0);
|
||||
GL.BindTexture(TextureTarget.Texture2D, texID);
|
||||
var bitmapData = image.LockBits(new Rectangle(0, 0, image.Width, image.Height),
|
||||
ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter,
|
||||
(int) TextureMinFilter.Nearest);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter,
|
||||
(int) TextureMagFilter.Nearest);
|
||||
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bitmapData.Width, bitmapData.Height, 0,
|
||||
PixelFormat.Bgra, PixelType.UnsignedByte, bitmapData.Scan0);
|
||||
|
||||
image.UnlockBits(bitmapData);
|
||||
|
||||
GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
|
||||
GL.Viewport(ClientRectangle);
|
||||
|
||||
GL.Begin(PrimitiveType.Triangles);
|
||||
|
||||
GL.TexCoord2(0, 0);
|
||||
GL.Vertex2(-.8, -.8);
|
||||
GL.TexCoord2(1, 0);
|
||||
GL.Vertex2(.8, -.8);
|
||||
GL.TexCoord2(0, 1);
|
||||
GL.Vertex2(-.8, .8);
|
||||
|
||||
GL.TexCoord2(1, 1);
|
||||
GL.Vertex2(.8, .8);
|
||||
GL.TexCoord2(1, 0);
|
||||
GL.Vertex2(.8, -.8);
|
||||
GL.TexCoord2(0, 1);
|
||||
GL.Vertex2(-.8, .8);
|
||||
|
||||
GL.End();
|
||||
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
using (var p = new Program())
|
||||
{
|
||||
p.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
WhatTheTexture/Properties/AssemblyInfo.cs
Normal file
36
WhatTheTexture/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("WhatTheTexture")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("WhatTheTexture")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("e7b84735-45aa-439a-a64b-2af248447660")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
63
WhatTheTexture/WhatTheTexture.csproj
Normal file
63
WhatTheTexture/WhatTheTexture.csproj
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{E7B84735-45AA-439A-A64B-2AF248447660}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>WhatTheTexture</RootNamespace>
|
||||
<AssemblyName>WhatTheTexture</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\OpenTK.2.0.0\lib\net20\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="OpenTK.dll.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="tex.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
4
WhatTheTexture/packages.config
Normal file
4
WhatTheTexture/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="OpenTK" version="2.0.0" targetFramework="net452" />
|
||||
</packages>
|
||||
BIN
WhatTheTexture/tex.png
Normal file
BIN
WhatTheTexture/tex.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
28
hexworld.sln
Normal file
28
hexworld.sln
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26127.3
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "hexworld", "hexworld\hexworld.csproj", "{AD9ED057-FB47-44CB-8839-22924B409706}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WhatTheTexture", "WhatTheTexture\WhatTheTexture.csproj", "{E7B84735-45AA-439A-A64B-2AF248447660}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AD9ED057-FB47-44CB-8839-22924B409706}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AD9ED057-FB47-44CB-8839-22924B409706}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AD9ED057-FB47-44CB-8839-22924B409706}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AD9ED057-FB47-44CB-8839-22924B409706}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E7B84735-45AA-439A-A64B-2AF248447660}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E7B84735-45AA-439A-A64B-2AF248447660}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E7B84735-45AA-439A-A64B-2AF248447660}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E7B84735-45AA-439A-A64B-2AF248447660}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
6
hexworld/App.config
Normal file
6
hexworld/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
23
hexworld/Cube.cs
Normal file
23
hexworld/Cube.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK;
|
||||
|
||||
namespace hexworld
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Cube
|
||||
{
|
||||
public Vector3 Position;
|
||||
public Vector3 Color;
|
||||
|
||||
public Cube(Vector3 position, Vector3 color)
|
||||
{
|
||||
Position = position;
|
||||
Color = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
25
hexworld/OpenTK.dll.config
Normal file
25
hexworld/OpenTK.dll.config
Normal file
@@ -0,0 +1,25 @@
|
||||
<configuration>
|
||||
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
|
||||
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
|
||||
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
|
||||
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
|
||||
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
|
||||
<dllmap os="linux" dll="libX11" target="libX11.so.6"/>
|
||||
<dllmap os="linux" dll="libXi" target="libXi.so.6"/>
|
||||
<dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/>
|
||||
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
|
||||
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
|
||||
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
|
||||
<!-- XQuartz compatibility (X11 on Mac) -->
|
||||
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
|
||||
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
|
||||
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
|
||||
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
|
||||
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
|
||||
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
|
||||
</configuration>
|
||||
206
hexworld/Program.cs
Normal file
206
hexworld/Program.cs
Normal file
@@ -0,0 +1,206 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace hexworld
|
||||
{
|
||||
internal class Game : GameWindow
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public Game()
|
||||
: this(1920, 1080)
|
||||
{
|
||||
}
|
||||
|
||||
public Game(int width, int height)
|
||||
: base(width, height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
X = (DisplayDevice.Default.Width - Width) / 2;
|
||||
Y = (DisplayDevice.Default.Height - Height) / 2;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Shaders
|
||||
|
||||
private int _pgmId;
|
||||
private int _vsId;
|
||||
private int _fsId;
|
||||
|
||||
#region Handles
|
||||
|
||||
#endregion
|
||||
|
||||
private void LoadShader(string filename, ShaderType type, int program, out int address)
|
||||
{
|
||||
address = GL.CreateShader(type);
|
||||
using (var sr = new StreamReader(filename))
|
||||
{
|
||||
GL.ShaderSource(address, sr.ReadToEnd());
|
||||
}
|
||||
GL.CompileShader(address);
|
||||
GL.AttachShader(program, address);
|
||||
Console.WriteLine(GL.GetShaderInfoLog(address));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Buffers
|
||||
|
||||
private int _vboPosition;
|
||||
private int _cubeVbo;
|
||||
private int _ibo;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data
|
||||
|
||||
private float[] _vertdata;
|
||||
private Cube[] _cubes;
|
||||
private int[] _indices;
|
||||
|
||||
private Matrix4 _view;
|
||||
private Matrix4 _projection;
|
||||
|
||||
#endregion
|
||||
|
||||
private void InitProgram()
|
||||
{
|
||||
_pgmId = GL.CreateProgram();
|
||||
|
||||
LoadShader("vs.glsl", ShaderType.VertexShader, _pgmId, out _vsId);
|
||||
LoadShader("fs.glsl", ShaderType.FragmentShader, _pgmId, out _fsId);
|
||||
|
||||
GL.LinkProgram(_pgmId);
|
||||
Console.WriteLine(GL.GetProgramInfoLog(_pgmId));
|
||||
|
||||
GL.GenBuffers(1, out _vboPosition);
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, _vboPosition);
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr) (_vertdata.Length * sizeof(float)), _vertdata,
|
||||
BufferUsageHint.StaticDraw);
|
||||
GL.EnableVertexAttribArray(0);
|
||||
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
|
||||
|
||||
GL.GenBuffers(1, out _cubeVbo);
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, _cubeVbo);
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr) (_cubes.Length * sizeof(float) * 6), _cubes,
|
||||
BufferUsageHint.StaticDraw);
|
||||
GL.EnableVertexAttribArray(1);
|
||||
GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, false, 6 * sizeof(float), 0);
|
||||
GL.VertexAttribDivisor(1, 1);
|
||||
|
||||
GL.EnableVertexAttribArray(2);
|
||||
GL.VertexAttribPointer(2, 3, VertexAttribPointerType.Float, false, 6 * sizeof(float), 3 * sizeof(float));
|
||||
GL.VertexAttribDivisor(2, 1);
|
||||
|
||||
GL.GenBuffers(1, out _ibo);
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, _ibo);
|
||||
GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr) (_indices.Length * sizeof(int)), _indices,
|
||||
BufferUsageHint.StaticDraw);
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
|
||||
_vertdata = new[]
|
||||
{
|
||||
-.5f, -.5f, -.5f,
|
||||
-.5f, -.5f, .5f,
|
||||
-.5f, .5f, -.5f,
|
||||
-.5f, .5f, .5f,
|
||||
.5f, -.5f, -.5f,
|
||||
.5f, -.5f, .5f,
|
||||
.5f, .5f, -.5f,
|
||||
.5f, .5f, .5f,
|
||||
};
|
||||
|
||||
_indices = new[]
|
||||
{
|
||||
0, 1, 2, 1, 2, 3,
|
||||
4, 5, 6, 5, 6, 7,
|
||||
0, 1, 4, 1, 4, 5,
|
||||
2, 3, 6, 3, 6, 7,
|
||||
0, 2, 4, 2, 4, 6,
|
||||
1, 3, 5, 3, 5, 7
|
||||
};
|
||||
|
||||
_cubes = new[]
|
||||
{
|
||||
new Cube(new Vector3(2, 2, 0), new Vector3(0.9f, 0.1f, 0.1f)),
|
||||
new Cube(new Vector3(2, 1, 0), new Vector3(0.1f, 0.1f, 0.1f)),
|
||||
new Cube(new Vector3(2, 0, 0), new Vector3(0.1f, 0.9f, 0.1f)),
|
||||
new Cube(new Vector3(2, -1, 0), new Vector3(0.1f, 0.1f, 0.1f)),
|
||||
new Cube(new Vector3(2, -2, 0), new Vector3(0.9f, 0.1f, 0.1f)),
|
||||
new Cube(new Vector3(1, 2, 0), new Vector3(0.1f, 0.1f, 0.1f)),
|
||||
new Cube(new Vector3(1, -2, 0), new Vector3(0.1f, 0.1f, 0.1f)),
|
||||
new Cube(new Vector3(0, 2, 0), new Vector3(0.1f, 0.1f, 0.9f)),
|
||||
new Cube(new Vector3(0, -2, 0), new Vector3(0.1f, 0.1f, 0.9f)),
|
||||
new Cube(new Vector3(-1, 2, 0), new Vector3(0.1f, 0.1f, 0.1f)),
|
||||
new Cube(new Vector3(-1, -2, 0), new Vector3(0.1f, 0.1f, 0.1f)),
|
||||
new Cube(new Vector3(-2, 2, 0), new Vector3(0.9f, 0.1f, 0.1f)),
|
||||
new Cube(new Vector3(-2, 1, 0), new Vector3(0.1f, 0.1f, 0.1f)),
|
||||
new Cube(new Vector3(-2, 0, 0), new Vector3(0.1f, 0.9f, 0.1f)),
|
||||
new Cube(new Vector3(-2, -1, 0), new Vector3(0.1f, 0.1f, 0.1f)),
|
||||
new Cube(new Vector3(-2, -2, 0), new Vector3(0.9f, 0.1f, 0.1f)),
|
||||
};
|
||||
|
||||
InitProgram();
|
||||
|
||||
_view = _projection = Matrix4.Identity;
|
||||
}
|
||||
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
base.OnRenderFrame(e);
|
||||
GL.Viewport(ClientRectangle);
|
||||
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
|
||||
|
||||
GL.DrawElementsInstanced(PrimitiveType.Triangles, _indices.Length, DrawElementsType.UnsignedInt, IntPtr.Zero,
|
||||
_cubes.Length);
|
||||
|
||||
GL.Flush();
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
base.OnUpdateFrame(e);
|
||||
|
||||
_view = Matrix4.LookAt(Vector3.Zero, -Vector3.One, Vector3.UnitZ);
|
||||
|
||||
GL.UniformMatrix4(0, false, ref _view);
|
||||
GL.UniformMatrix4(1, false, ref _projection);
|
||||
|
||||
GL.UseProgram(_pgmId);
|
||||
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
float size = 100;
|
||||
_projection = Matrix4.CreateOrthographic(Width / size, Height / size, -50, 50);
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Game gw;
|
||||
using (gw = new Game())
|
||||
{
|
||||
gw.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
hexworld/Properties/AssemblyInfo.cs
Normal file
36
hexworld/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("hexworld")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("hexworld")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("ad9ed057-fb47-44cb-8839-22924b409706")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
10
hexworld/fs.glsl
Normal file
10
hexworld/fs.glsl
Normal file
@@ -0,0 +1,10 @@
|
||||
#version 440
|
||||
|
||||
in vec4 color;
|
||||
out vec4 outputColor;
|
||||
|
||||
void
|
||||
main()
|
||||
{
|
||||
outputColor = color;
|
||||
}
|
||||
75
hexworld/hexworld.csproj
Normal file
75
hexworld/hexworld.csproj
Normal file
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{AD9ED057-FB47-44CB-8839-22924B409706}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>hexworld</RootNamespace>
|
||||
<AssemblyName>hexworld</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\OpenTK.2.0.0\lib\net20\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Cube.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="vs.glsl">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="OpenTK.dll.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="fs.glsl">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="tex.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
5
hexworld/packages.config
Normal file
5
hexworld/packages.config
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
|
||||
<package id="OpenTK" version="2.0.0" targetFramework="net452" />
|
||||
</packages>
|
||||
BIN
hexworld/tex.png
Normal file
BIN
hexworld/tex.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
17
hexworld/vs.glsl
Normal file
17
hexworld/vs.glsl
Normal file
@@ -0,0 +1,17 @@
|
||||
#version 440
|
||||
|
||||
layout (location = 0) in vec3 vPosition;
|
||||
layout (location = 1) in vec3 vColor;
|
||||
layout (location = 2) in vec3 vOffset;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
layout (location = 0) uniform mat4 view;
|
||||
layout (location = 1) uniform mat4 projection;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 pos = vPosition + vOffset;
|
||||
gl_Position = projection * view * vec4(pos, 1.0);
|
||||
color = vec4( vColor, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user