Switch obsolete Tao 3D libs for OpenTK (not really tested yet)

This commit is contained in:
Cinder Biscuits
2017-04-24 07:39:26 -05:00
parent c54b95c539
commit 247a3550a6
15 changed files with 456 additions and 440 deletions

View File

@@ -1,148 +1,156 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>14.0.25123</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{93CEA633-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>AvatarPreview</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<OutputType>WinExe</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>AvatarPreview</RootNamespace>
<StartupObject></StartupObject>
<StartArguments></StartArguments>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoStdLib>False</NoStdLib>
<NoWarn>1591,1574,0419</NoWarn>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoStdLib>False</NoStdLib>
<NoWarn>1591,1574,0419</NoWarn>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<Name>System</Name>
<Private>False</Private>
</Reference>
<Reference Include="System.Data" >
<Name>System.Data</Name>
<Private>False</Private>
</Reference>
<Reference Include="System.Drawing" >
<Name>System.Drawing</Name>
<Private>False</Private>
</Reference>
<Reference Include="System.Windows.Forms" >
<Name>System.Windows.Forms</Name>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<Name>System.Xml</Name>
<Private>False</Private>
</Reference>
<Reference Include="Tao.OpenGl" >
<Name>Tao.OpenGl</Name>
<Private>False</Private>
</Reference>
<Reference Include="Tao.Platform.Windows" >
<Name>Tao.Platform.Windows</Name>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\LibreMetaverse\LibreMetaverse.csproj">
<Name>LibreMetaverse</Name>
<Project>{27C70F3A-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\LibreMetaverseTypes\LibreMetaverseTypes.csproj">
<Name>LibreMetaverseTypes</Name>
<Project>{B37B02AD-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="frmAvatar.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GLMesh.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Program.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<SubType>Code</SubType>
</Compile>
<EmbeddedResource Include="frmAvatar.resx">
<DependentUpon>frmAvatar.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="frmAvatar.Designer.cs">
<DependentUpon>frmAvatar.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>14.0.25123</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{93CEA633-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>AvatarPreview</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>
</AppDesignerFolder>
<RootNamespace>AvatarPreview</RootNamespace>
<StartupObject>
</StartupObject>
<StartArguments>
</StartArguments>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoStdLib>False</NoStdLib>
<NoWarn>1591,1574,0419,0618</NoWarn>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoStdLib>False</NoStdLib>
<NoWarn>1591,1574,0419,0618</NoWarn>
<PlatformTarget>AnyCPU</PlatformTarget>
</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="OpenTK.GLControl, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\..\packages\OpenTK.GLControl.1.1.2349.61993\lib\NET40\OpenTK.GLControl.dll</HintPath>
</Reference>
<Reference Include="System">
<Name>System</Name>
<Private>False</Private>
</Reference>
<Reference Include="System.Data">
<Name>System.Data</Name>
<Private>False</Private>
</Reference>
<Reference Include="System.Drawing">
<Name>System.Drawing</Name>
<Private>False</Private>
</Reference>
<Reference Include="System.Windows.Forms">
<Name>System.Windows.Forms</Name>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml">
<Name>System.Xml</Name>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\LibreMetaverse\LibreMetaverse.csproj">
<Name>LibreMetaverse</Name>
<Project>{27C70F3A-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\LibreMetaverseTypes\LibreMetaverseTypes.csproj">
<Name>LibreMetaverseTypes</Name>
<Project>{B37B02AD-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="frmAvatar.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GLMesh.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Program.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<SubType>Code</SubType>
</Compile>
<EmbeddedResource Include="frmAvatar.resx">
<DependentUpon>frmAvatar.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="frmAvatar.Designer.cs">
<DependentUpon>frmAvatar.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>

View File

@@ -110,6 +110,7 @@ namespace AvatarPreview
}
}
[Obsolete]
public override void LoadLODMesh(int level, string filename)
{
LODMesh lod = new LODMesh();

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="OpenTK" publicKeyToken="bad199fe84eb3df4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -41,7 +41,7 @@ namespace AvatarPreview
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.glControl = new Tao.Platform.Windows.SimpleOpenGlControl();
this.glControl = new OpenTK.GLControl();
this.tabControl = new System.Windows.Forms.TabControl();
this.tavView = new System.Windows.Forms.TabPage();
this.scrollZoom = new System.Windows.Forms.HScrollBar();
@@ -250,19 +250,11 @@ namespace AvatarPreview
//
// glControl
//
this.glControl.AccumBits = ((byte)(0));
this.glControl.AutoCheckErrors = false;
this.glControl.AutoFinish = false;
this.glControl.AutoMakeCurrent = true;
this.glControl.AutoSwapBuffers = true;
this.glControl.BackColor = System.Drawing.Color.Black;
this.glControl.ColorBits = ((byte)(32));
this.glControl.DepthBits = ((byte)(16));
this.glControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.glControl.Location = new System.Drawing.Point(0, 0);
this.glControl.Name = "glControl";
this.glControl.Size = new System.Drawing.Size(558, 653);
this.glControl.StencilBits = ((byte)(0));
this.glControl.TabIndex = 0;
this.glControl.Paint += new System.Windows.Forms.PaintEventHandler(this.glControl_Paint);
this.glControl.Resize += new System.EventHandler(this.glControl_Resize);
@@ -1101,7 +1093,7 @@ namespace AvatarPreview
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
private System.Windows.Forms.SplitContainer splitContainer1;
private Tao.Platform.Windows.SimpleOpenGlControl glControl;
private OpenTK.GLControl glControl;
private System.Windows.Forms.TabControl tabControl;
private System.Windows.Forms.TabPage tabMorphs;
private System.Windows.Forms.TabPage tabTextures;

View File

@@ -1,19 +1,14 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Xml;
using Tao.OpenGl;
using Tao.Platform.Windows;
using OpenTK.Graphics.OpenGL;
using OpenMetaverse;
using OpenMetaverse.Imaging;
using OpenMetaverse.Rendering;
using OpenMetaverse.Assets;
namespace AvatarPreview
@@ -29,16 +24,13 @@ namespace AvatarPreview
{
InitializeComponent();
glControl.InitializeContexts();
Gl.glShadeModel(Gl.GL_SMOOTH);
Gl.glClearColor(0f, 0f, 0f, 0f);
Gl.glClearDepth(1.0f);
Gl.glEnable(Gl.GL_DEPTH_TEST);
Gl.glDepthMask(Gl.GL_TRUE);
Gl.glDepthFunc(Gl.GL_LEQUAL);
Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST);
GL.ShadeModel(ShadingModel.Smooth);
GL.ClearColor(Color.Black);
GL.ClearDepth(1.0f);
GL.Enable(EnableCap.DepthTest);
GL.DepthMask(true);
GL.DepthFunc(DepthFunction.Lequal);
GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
glControl_Resize(null, null);
}
@@ -125,25 +117,20 @@ namespace AvatarPreview
private void glControl_Paint(object sender, PaintEventArgs e)
{
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
Gl.glLoadIdentity();
// Setup wireframe or solid fill drawing mode
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.LoadIdentity();
if (_wireframe)
Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
else
Gl.glPolygonMode(Gl.GL_FRONT, Gl.GL_FILL);
GL.PolygonMode(MaterialFace.Front, PolygonMode.Fill);
// Push the world matrix
Gl.glPushMatrix();
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
GL.PushMatrix();
GL.EnableClientState(ArrayCap.VertexArray);
GL.EnableClientState(ArrayCap.TextureCoordArray);
// World rotations
Gl.glRotatef((float)scrollRoll.Value, 1f, 0f, 0f);
Gl.glRotatef((float)scrollPitch.Value, 0f, 1f, 0f);
Gl.glRotatef((float)scrollYaw.Value, 0f, 0f, 1f);
GL.Rotate(scrollRoll.Value, 1f, 0f, 0f);
GL.Rotate(scrollRoll.Value, 0f, 1f, 0f);
GL.Rotate(scrollRoll.Value, 0f, 0f, 1f);
if (_meshes.Count > 0)
{
@@ -151,61 +138,62 @@ namespace AvatarPreview
{
if (!_showSkirt && mesh.Name == "skirtMesh")
continue;
Gl.glColor3f(1f, 1f, 1f);
GL.Color3(1f, 1f, 1f);
// Individual prim matrix
Gl.glPushMatrix();
GL.PushMatrix();
//Gl.glTranslatef(mesh.Position.X, mesh.Position.Y, mesh.Position.Z);
Gl.glRotatef(mesh.RotationAngles.X, 1f, 0f, 0f);
Gl.glRotatef(mesh.RotationAngles.Y, 0f, 1f, 0f);
Gl.glRotatef(mesh.RotationAngles.Z, 0f, 0f, 1f);
GL.Rotate(mesh.RotationAngles.X, 1f, 0f, 0f);
GL.Rotate(mesh.RotationAngles.Y, 0f, 1f, 0f);
GL.Rotate(mesh.RotationAngles.Z, 0f, 0f, 1f);
Gl.glScalef(mesh.Scale.X, mesh.Scale.Y, mesh.Scale.Z);
GL.Scale(mesh.Scale.X, mesh.Scale.Y, mesh.Scale.Z);
// TODO: Texturing
Gl.glTexCoordPointer(2, Gl.GL_FLOAT, 0, mesh.RenderData.TexCoords);
Gl.glVertexPointer(3, Gl.GL_FLOAT, 0, mesh.RenderData.Vertices);
Gl.glDrawElements(Gl.GL_TRIANGLES, mesh.RenderData.Indices.Length, Gl.GL_UNSIGNED_SHORT, mesh.RenderData.Indices);
GL.TexCoordPointer(2, TexCoordPointerType.Float, 0, mesh.RenderData.TexCoords);
GL.VertexPointer(3, VertexPointerType.Float, 0, mesh.RenderData.TexCoords);
GL.DrawElements(BeginMode.Triangles, mesh.RenderData.Indices.Length, DrawElementsType.UnsignedShort, mesh.RenderData.Indices);
}
}
// Pop the world matrix
Gl.glPopMatrix();
GL.PopMatrix();
GL.DisableClientState(ArrayCap.TextureCoordArray);
GL.DisableClientState(ArrayCap.VertexArray);
Gl.glDisableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
Gl.glFlush();
GL.Flush();
}
private void glControl_Resize(object sender, EventArgs e)
{
//Gl.glClearColor(0.39f, 0.58f, 0.93f, 1.0f); // Cornflower blue anyone?
Gl.glClearColor(0f, 0f, 0f, 1f);
//GL.ClearColor(0.39f, 0.58f, 0.93f, 1.0f); // Cornflower blue anyone?
GL.ClearColor(0f, 0f, 0f, 1f);
Gl.glPushMatrix();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
GL.PushMatrix();
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Viewport(0, 0, glControl.Width, glControl.Height);
Gl.glViewport(0, 0, glControl.Width, glControl.Height);
Glu.gluPerspective(50.0d, 1.0d, 0.001d, 50d);
OpenTK.Matrix4 perspectiveMatrix = OpenTK.Matrix4.CreatePerspectiveFieldOfView(50.0f, 1.0f, 0.001f, 50f);
GL.LoadMatrix(ref perspectiveMatrix);
Vector3 center = Vector3.Zero;
GLMesh head, lowerBody;
if (_meshes.TryGetValue("headMesh", out head) && _meshes.TryGetValue("lowerBodyMesh", out lowerBody))
center = (head.RenderData.Center + lowerBody.RenderData.Center) / 2f;
Glu.gluLookAt(
center.X, (double)scrollZoom.Value * 0.1d + center.Y, center.Z,
center.X, (double)scrollZoom.Value * 0.1d + center.Y + 1d, center.Z,
0d, 0d, 1d);
Gl.glMatrixMode(Gl.GL_MODELVIEW);
OpenTK.Matrix4 lookAt = OpenTK.Matrix4.LookAt(
new OpenTK.Vector3(center.X, scrollZoom.Value * 0.1f + center.Y, center.Z),
new OpenTK.Vector3(center.X, scrollZoom.Value * 0.1f + center.Y + 1f, center.Z),
new OpenTK.Vector3(0f, 0f, 1f));
GL.LoadMatrix(ref lookAt);
GL.MatrixMode(MatrixMode.Modelview);
}
private void scroll_ValueChanged(object sender, EventArgs e)

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="OpenTK" version="2.0.0" targetFramework="net40" />
<package id="OpenTK.GLControl" version="1.1.2349.61993" targetFramework="net40" />
</packages>

View File

@@ -76,6 +76,15 @@
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<HintPath>..\..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\..\packages\Lyncee.OpenTK.1.1.1173.43181\lib\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.Compatibility, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\..\packages\Lyncee.OpenTK.Compatibility.1.1.1173.43181\lib\OpenTK.Compatibility.dll</HintPath>
</Reference>
<Reference Include="OpenTK.GLControl, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\..\packages\OpenTK.GLControl.1.1.2349.61993\lib\NET40\OpenTK.GLControl.dll</HintPath>
</Reference>
<Reference Include="System">
<Name>System</Name>
<Private>False</Private>
@@ -96,14 +105,6 @@
<Name>System.Xml</Name>
<Private>False</Private>
</Reference>
<Reference Include="Tao.OpenGl">
<Name>Tao.OpenGl</Name>
<Private>False</Private>
</Reference>
<Reference Include="Tao.Platform.Windows">
<Name>Tao.Platform.Windows</Name>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\LibreMetaverse\LibreMetaverse.csproj">
@@ -167,6 +168,8 @@
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="OpenTK" publicKeyToken="bad199fe84eb3df4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -31,7 +31,7 @@ namespace PrimWorkshop
GlacialComponents.Controls.GLColumn glColumn1 = new GlacialComponents.Controls.GLColumn();
GlacialComponents.Controls.GLColumn glColumn2 = new GlacialComponents.Controls.GLColumn();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.glControl = new Tao.Platform.Windows.SimpleOpenGlControl();
this.glControl = new OpenTK.GLControl();
this.panel1 = new System.Windows.Forms.Panel();
this.txtPass = new System.Windows.Forms.TextBox();
this.txtLast = new System.Windows.Forms.TextBox();
@@ -83,20 +83,12 @@ namespace PrimWorkshop
//
// glControl
//
this.glControl.AccumBits = ((byte)(0));
this.glControl.AutoCheckErrors = false;
this.glControl.AutoFinish = false;
this.glControl.AutoMakeCurrent = true;
this.glControl.AutoSwapBuffers = true;
this.glControl.BackColor = System.Drawing.Color.Black;
this.glControl.ColorBits = ((byte)(32));
this.tableLayoutPanel1.SetColumnSpan(this.glControl, 2);
this.glControl.DepthBits = ((byte)(16));
this.glControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.glControl.Location = new System.Drawing.Point(3, 3);
this.glControl.Name = "glControl";
this.glControl.Size = new System.Drawing.Size(618, 411);
this.glControl.StencilBits = ((byte)(0));
this.glControl.TabIndex = 7;
this.glControl.TabStop = false;
this.glControl.MouseMove += new System.Windows.Forms.MouseEventHandler(this.glControl_MouseMove);
@@ -366,7 +358,7 @@ namespace PrimWorkshop
#endregion
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private Tao.Platform.Windows.SimpleOpenGlControl glControl;
private OpenTK.GLControl glControl;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.TextBox txtPass;
private System.Windows.Forms.TextBox txtLast;

View File

@@ -2,13 +2,11 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
using Tao.OpenGl;
using Tao.Platform.Windows;
using ICSharpCode.SharpZipLib.Zip;
using OpenTK.Graphics.OpenGL;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenMetaverse.Imaging;
@@ -50,7 +48,7 @@ namespace PrimWorkshop
uint LastHit = 0;
//warning CS0414: The private field `PrimWorkshop.frmBrowser.PivotPosition' is assigned but its value is never used
Vector3 PivotPosition = Vector3.Zero;
OpenMetaverse.Vector3 PivotPosition = OpenMetaverse.Vector3.Zero;
private bool Pivoting;
Point LastPivot;
@@ -73,7 +71,6 @@ namespace PrimWorkshop
InitializeComponent();
// Setup OpenGL
glControl.InitializeContexts();
glControl.SwapBuffers();
glControl.MouseWheel += new MouseEventHandler(glControl_MouseWheel);
@@ -122,7 +119,7 @@ namespace PrimWorkshop
foreach (TextureInfo tex in Textures.Values)
{
int id = tex.ID;
Gl.glDeleteTextures(1, ref id);
GL.DeleteTextures(1, ref id);
}
Textures.Clear();
@@ -218,13 +215,13 @@ namespace PrimWorkshop
private void InitOpenGL()
{
Gl.glShadeModel(Gl.GL_SMOOTH);
GL.ShadeModel(ShadingModel.Smooth);
Gl.glClearDepth(1.0f);
Gl.glEnable(Gl.GL_DEPTH_TEST);
Gl.glDepthMask(Gl.GL_TRUE);
Gl.glDepthFunc(Gl.GL_LEQUAL);
Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST);
GL.ClearDepth(1d);
GL.Enable(EnableCap.DepthTest);
GL.DepthMask(true);
GL.DepthFunc(DepthFunction.Lequal);
GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
}
private void InitHeightmap()
@@ -301,14 +298,14 @@ namespace PrimWorkshop
Client.Self.Movement.Camera.Far = (float)Camera.Far;
}
Gl.glPushMatrix();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
GL.PushMatrix();
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
SetPerspective();
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glPopMatrix();
GL.MatrixMode(MatrixMode.Modelview);
GL.PopMatrix();
}
private bool ExportObject(RenderablePrim parent, string fileName, out int prims, out int textures, out string error)
@@ -824,28 +821,38 @@ namespace PrimWorkshop
private void SetPerspective()
{
Glu.gluPerspective(50.0d * Camera.Zoom, 1.0d, 0.1d, Camera.Far);
OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView(
50.0f * (float)Camera.Zoom, 1.0f, 0.1f, (float)Camera.Far);
}
private void GluPickMatrix(double x, double y, double deltax, double deltay, int[] viewport)
{
if (deltax <= 0 || deltay <= 0) return;
GL.Translate((viewport[2] - 2 * (x - viewport[0])) / deltax,
(viewport[3] - 2 * (y - viewport[1])) / deltay,
0);
GL.Scale(viewport[2] / deltax, viewport[3] / deltay, 1.0);
}
private void StartPicking(int cursorX, int cursorY)
{
int[] viewport = new int[4];
GL.SelectBuffer(SELECT_BUFSIZE, SelectBuffer);
GL.RenderMode(RenderingMode.Select);
Gl.glSelectBuffer(SELECT_BUFSIZE, SelectBuffer);
Gl.glRenderMode(Gl.GL_SELECT);
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPushMatrix();
Gl.glLoadIdentity();
Gl.glGetIntegerv(Gl.GL_VIEWPORT, viewport);
Glu.gluPickMatrix(cursorX, viewport[3] - cursorY, 5, 5, viewport);
GL.MatrixMode(MatrixMode.Projection);
GL.PushMatrix();
GL.LoadIdentity();
GL.GetInteger(GetPName.Viewport, viewport);
GluPickMatrix(cursorX, viewport[3] - cursorY, 5, 5, viewport);
SetPerspective();
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glInitNames();
GL.MatrixMode(MatrixMode.Modelview);
GL.InitNames();
}
private void StopPicking()
@@ -853,13 +860,13 @@ namespace PrimWorkshop
int hits;
// Resotre the original projection matrix
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPopMatrix();
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glFlush();
GL.MatrixMode(MatrixMode.Projection);
GL.PopMatrix();
GL.MatrixMode(MatrixMode.Modelview);
GL.Flush();
// Return to normal rendering mode
hits = Gl.glRenderMode(Gl.GL_RENDER);
hits = GL.RenderMode(RenderingMode.Render);
// If there are hits process them
if (hits != 0)
@@ -1083,34 +1090,36 @@ namespace PrimWorkshop
{
try
{
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
Gl.glLoadIdentity();
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.LoadIdentity();
GL.EnableClientState(ArrayCap.VertexArray);
GL.EnableClientState(ArrayCap.TextureCoordArray);
if (Clicked)
StartPicking(ClickX, ClickY);
// Setup wireframe or solid fill drawing mode
Gl.glPolygonMode(Gl.GL_FRONT, Gl.GL_LINE);
GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
// Position the camera
Glu.gluLookAt(
OpenTK.Matrix4 lookAt = OpenTK.Matrix4.LookAt(
Camera.Position.X, Camera.Position.Y, Camera.Position.Z,
Camera.FocalPoint.X, Camera.FocalPoint.Y, Camera.FocalPoint.Z,
0f, 0f, 1f);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref lookAt);
RenderSkybox();
// Push the world matrix
Gl.glPushMatrix();
GL.PushMatrix();
RenderTerrain();
RenderPrims();
RenderAvatars();
Gl.glDisableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
GL.DisableClientState(ArrayCap.TextureCoordArray);
GL.DisableClientState(ArrayCap.VertexArray);
if (Clicked)
{
@@ -1119,8 +1128,8 @@ namespace PrimWorkshop
}
// Pop the world matrix
Gl.glPopMatrix();
Gl.glFlush();
GL.PopMatrix();
GL.Flush();
glControl.Invalidate();
}
@@ -1175,14 +1184,14 @@ namespace PrimWorkshop
int i = 0;
// No texture
Gl.glBindTexture(Gl.GL_TEXTURE_2D, 0);
GL.BindTexture(TextureTarget.Texture2D, 0);
for (int hy = 0; hy < 16; hy++)
{
for (int hx = 0; hx < 16; hx++)
{
uint patchName = (uint)(TERRAIN_START + i);
Gl.glPushName(patchName);
GL.PushName(patchName);
++i;
// Check if this patch is currently selected
@@ -1190,8 +1199,7 @@ namespace PrimWorkshop
for (int y = 0; y < 15; y++)
{
Gl.glBegin(Gl.GL_TRIANGLE_STRIP);
GL.Begin(BeginMode.TriangleStrip);
for (int x = 0; x < 15; x++)
{
// Vertex 0
@@ -1199,42 +1207,41 @@ namespace PrimWorkshop
float color = height / MaxHeight;
float red = (selected) ? 1f : color;
Gl.glColor3f(red, color, color);
Gl.glTexCoord2f(0f, 0f);
Gl.glVertex3f(hx * 16 + x, hy * 16 + y, height);
GL.Color3(red, color, color);
GL.TexCoord2(0f, 0f);
GL.Vertex3(hx * 16 + x, hy * 16 + y, height);
// Vertex 1
height = Heightmap[hy, hx].Data[y * 16 + (x + 1)];
color = height / MaxHeight;
red = (selected) ? 1f : color;
Gl.glColor3f(red, color, color);
Gl.glTexCoord2f(1f, 0f);
Gl.glVertex3f(hx * 16 + x + 1, hy * 16 + y, height);
GL.Color3(red, color, color);
GL.TexCoord2(1f, 0f);
GL.Vertex3(hx * 16 + x + 1, hy * 16 + y, height);
// Vertex 2
height = Heightmap[hy, hx].Data[(y + 1) * 16 + x];
color = height / MaxHeight;
red = (selected) ? 1f : color;
Gl.glColor3f(red, color, color);
Gl.glTexCoord2f(0f, 1f);
Gl.glVertex3f(hx * 16 + x, hy * 16 + y + 1, height);
GL.Color3(red, color, color);
GL.TexCoord2(0f, 1f);
GL.Vertex3(hx * 16 + x, hy * 16 + y + 1, height);
// Vertex 3
height = Heightmap[hy, hx].Data[(y + 1) * 16 + (x + 1)];
color = height / MaxHeight;
red = (selected) ? 1f : color;
Gl.glColor3f(red, color, color);
Gl.glTexCoord2f(1f, 1f);
Gl.glVertex3f(hx * 16 + x + 1, hy * 16 + y + 1, height);
GL.Color3(red, color, color);
GL.TexCoord2(1f, 1f);
GL.Vertex3(hx * 16 + x + 1, hy * 16 + y + 1, height);
}
Gl.glEnd();
GL.End();
}
Gl.glPopName();
GL.PopName();
}
}
}
@@ -1254,13 +1261,13 @@ namespace PrimWorkshop
{
if (RenderPrimList != null && RenderPrimList.Count > 0)
{
Gl.glEnable(Gl.GL_TEXTURE_2D);
GL.Enable(EnableCap.Texture2D);
lock (RenderPrimList)
{
bool firstPass = true;
Gl.glDisable(Gl.GL_BLEND);
Gl.glEnable(Gl.GL_DEPTH_TEST);
GL.Disable(EnableCap.Blend);
GL.Enable(EnableCap.DepthTest);
StartRender:
@@ -1278,9 +1285,9 @@ namespace PrimWorkshop
continue;
}
}
Gl.glPushName(prim.LocalID);
Gl.glPushMatrix();
GL.PushName(prim.LocalID);
GL.PushMatrix();
if (prim.ParentID != 0)
{
@@ -1288,23 +1295,23 @@ namespace PrimWorkshop
Primitive parent = parentRender.Prim;
// Apply parent translation and rotation
Gl.glMultMatrixf(Math3D.CreateTranslationMatrix(parent.Position));
Gl.glMultMatrixf(Math3D.CreateRotationMatrix(parent.Rotation));
GL.MultMatrix(Math3D.CreateTranslationMatrix(parent.Position));
GL.MultMatrix(Math3D.CreateRotationMatrix(parent.Rotation));
}
// Apply prim translation and rotation
Gl.glMultMatrixf(Math3D.CreateTranslationMatrix(prim.Position));
Gl.glMultMatrixf(Math3D.CreateRotationMatrix(prim.Rotation));
GL.MultMatrix(Math3D.CreateTranslationMatrix(prim.Position));
GL.MultMatrix(Math3D.CreateRotationMatrix(prim.Rotation));
// Scale the prim
Gl.glScalef(prim.Scale.X, prim.Scale.Y, prim.Scale.Z);
GL.Scale(prim.Scale.X, prim.Scale.Y, prim.Scale.Z);
// Draw the prim faces
for (int j = 0; j < render.Mesh.Faces.Count; j++)
{
Face face = render.Mesh.Faces[j];
FaceData data = (FaceData)face.UserData;
Color4 color = face.TextureFace.RGBA;
OpenMetaverse.Color4 color = face.TextureFace.RGBA;
bool alpha = false;
int textureID = 0;
@@ -1322,18 +1329,18 @@ namespace PrimWorkshop
textureID = info.ID;
// Enable texturing for this face
Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_FILL);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
}
else
{
if (face.TextureFace.TextureID == Primitive.TextureEntry.WHITE_TEXTURE ||
face.TextureFace.TextureID == UUID.Zero)
{
Gl.glPolygonMode(Gl.GL_FRONT, Gl.GL_FILL);
GL.PolygonMode(MaterialFace.Front, PolygonMode.Fill);
}
else
{
Gl.glPolygonMode(Gl.GL_FRONT, Gl.GL_LINE);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
}
}
@@ -1342,41 +1349,40 @@ namespace PrimWorkshop
// Color this prim differently based on whether it is selected or not
if (LastHit == prim.LocalID || (LastHit != 0 && LastHit == prim.ParentID))
{
Gl.glColor4f(1f, color.G * 0.3f, color.B * 0.3f, color.A);
GL.Color4(1f, color.G * 0.3f, color.B * 0.3f, color.A);
}
else
{
Gl.glColor4f(color.R, color.G, color.B, color.A);
GL.Color4(color.R, color.G, color.B, color.A);
}
// Bind the texture
Gl.glBindTexture(Gl.GL_TEXTURE_2D, textureID);
Gl.glTexCoordPointer(2, Gl.GL_FLOAT, 0, data.TexCoords);
Gl.glVertexPointer(3, Gl.GL_FLOAT, 0, data.Vertices);
Gl.glDrawElements(Gl.GL_TRIANGLES, data.Indices.Length, Gl.GL_UNSIGNED_SHORT, data.Indices);
GL.BindTexture(TextureTarget.Texture2D, textureID);
GL.TexCoordPointer(2, TexCoordPointerType.Float, 0, data.TexCoords);
GL.VertexPointer(3, VertexPointerType.Float, 0, data.Vertices);
GL.DrawElements(BeginMode.Triangles, data.Indices.Length, DrawElementsType.UnsignedShort, data.Indices);
}
#endregion Texturing
}
Gl.glPopMatrix();
Gl.glPopName();
GL.PopMatrix();
GL.PopName();
}
if (firstPass)
{
firstPass = false;
Gl.glEnable(Gl.GL_BLEND);
Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
//Gl.glDisable(Gl.GL_DEPTH_TEST);
GL.Enable(EnableCap.Blend);
GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
goto StartRender;
}
}
Gl.glEnable(Gl.GL_DEPTH_TEST);
Gl.glDisable(Gl.GL_TEXTURE_2D);
GL.Enable(EnableCap.DepthTest);
GL.Disable(EnableCap.Texture2D);
}
}
@@ -1384,23 +1390,23 @@ namespace PrimWorkshop
{
if (Client != null && Client.Network.CurrentSim != null)
{
Gl.glColor3f(0f, 1f, 0f);
GL.Color3(0f, 1f, 0f);
Client.Network.CurrentSim.ObjectsAvatars.ForEach(
delegate(Avatar avatar)
{
Gl.glPushMatrix();
Gl.glTranslatef(avatar.Position.X, avatar.Position.Y, avatar.Position.Z);
GL.PushMatrix();
GL.Translate(avatar.Position.X, avatar.Position.Y, avatar.Position.Z);
Glu.GLUquadric quad = Glu.gluNewQuadric();
Glu.gluSphere(quad, 1.0d, 10, 10);
Glu.gluDeleteQuadric(quad);
Gl.glPopMatrix();
var quad = OpenTK.Graphics.Glu.NewQuadric();
OpenTK.Graphics.Glu.Sphere(quad, 1.0d, 10, 10);
OpenTK.Graphics.Glu.DeleteQuadric(quad);
GL.PopMatrix();
}
);
Gl.glColor3f(1f, 1f, 1f);
GL.Color3(1f, 1f, 1f);
}
}
@@ -1446,21 +1452,23 @@ namespace PrimWorkshop
try
{
Gl.glGenTextures(1, out textureID);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, textureID);
GL.GenTextures(1, out textureID);
GL.BindTexture(TextureTarget.Texture2D, textureID);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.LinearMipmapNearest);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)All.Repeat);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)All.Repeat);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR_MIPMAP_NEAREST); //Gl.GL_NEAREST);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_REPEAT);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_REPEAT);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_GENERATE_MIPMAP, Gl.GL_TRUE); //Gl.GL_FALSE);
//Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA, bitmap.Width, bitmap.Height, 0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE,
// bitmapData.Scan0);
//int error = Gl.glGetError();
int error = Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, Gl.GL_RGBA, imgData.Width, imgData.Height, Gl.GL_BGRA,
Gl.GL_UNSIGNED_BYTE, raw);
int error = OpenTK.Graphics.Glu.Build2DMipmap(OpenTK.Graphics.TextureTarget.Texture2D,
(int)OpenTK.Graphics.PixelInternalFormat.Rgba, imgData.Width, imgData.Height,
OpenTK.Graphics.PixelFormat.Bgra, OpenTK.Graphics.PixelType.UnsignedByte, raw);
if (error == 0)
{
@@ -1629,18 +1637,18 @@ namespace PrimWorkshop
private void glControl_Resize(object sender, EventArgs e)
{
Gl.glClearColor(0.39f, 0.58f, 0.93f, 1.0f);
GL.ClearColor(0.39f, 0.58f, 0.93f, 1.0f);
Gl.glViewport(0, 0, glControl.Width, glControl.Height);
GL.Viewport(0, 0, glControl.Width, glControl.Height);
Gl.glPushMatrix();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
GL.PushMatrix();
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
SetPerspective();
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glPopMatrix();
GL.MatrixMode(MatrixMode.Modelview);
GL.PopMatrix();
// Set the center of the glControl as the default pivot point
LastPivot = glControl.PointToScreen(new Point(glControl.Width / 2, glControl.Height / 2));

View File

@@ -15,7 +15,7 @@ namespace PrimWorkshop
{
if (disposing && (components != null))
{
glControl.DestroyContexts();
glControl.Context.Dispose();
components.Dispose();
}
base.Dispose(disposing);
@@ -48,7 +48,7 @@ namespace PrimWorkshop
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.splitContainer = new System.Windows.Forms.SplitContainer();
this.glControl = new Tao.Platform.Windows.SimpleOpenGlControl();
this.glControl = new OpenTK.GLControl();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.panel2 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
@@ -233,19 +233,11 @@ namespace PrimWorkshop
//
// glControl
//
this.glControl.AccumBits = ((byte)(0));
this.glControl.AutoCheckErrors = false;
this.glControl.AutoFinish = false;
this.glControl.AutoMakeCurrent = true;
this.glControl.AutoSwapBuffers = true;
this.glControl.BackColor = System.Drawing.Color.Black;
this.glControl.ColorBits = ((byte)(32));
this.glControl.DepthBits = ((byte)(16));
this.glControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.glControl.Location = new System.Drawing.Point(0, 0);
this.glControl.Name = "glControl";
this.glControl.Size = new System.Drawing.Size(550, 512);
this.glControl.StencilBits = ((byte)(0));
this.glControl.TabIndex = 5;
this.glControl.Paint += new System.Windows.Forms.PaintEventHandler(this.glControl_Paint);
this.glControl.Resize += new System.EventHandler(this.glControl_Resize);
@@ -436,7 +428,7 @@ namespace PrimWorkshop
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
private System.Windows.Forms.SplitContainer splitContainer;
private Tao.Platform.Windows.SimpleOpenGlControl glControl;
private OpenTK.GLControl glControl;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.HScrollBar scrollRoll;
private System.Windows.Forms.HScrollBar scrollPitch;

View File

@@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
using Tao.OpenGl;
using Tao.Platform.Windows;
using ICSharpCode.SharpZipLib.Zip;
using OpenTK.Graphics.OpenGL;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenMetaverse.Imaging;
@@ -35,16 +33,15 @@ namespace PrimWorkshop
public frmPrimWorkshop()
{
InitializeComponent();
glControl.InitializeContexts();
Gl.glShadeModel(Gl.GL_SMOOTH);
Gl.glClearColor(0f, 0f, 0f, 0f);
GL.ShadeModel(ShadingModel.Smooth);
GL.ClearColor(Color.Black);
Gl.glClearDepth(1.0f);
Gl.glEnable(Gl.GL_DEPTH_TEST);
Gl.glDepthMask(Gl.GL_TRUE);
Gl.glDepthFunc(Gl.GL_LEQUAL);
Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST);
GL.ClearDepth(1f);
GL.Enable(EnableCap.DepthTest);
GL.DepthMask(true);
GL.DepthFunc(DepthFunction.Lequal);
GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
TexturePointers[0] = 0;
@@ -81,32 +78,33 @@ namespace PrimWorkshop
private void glControl_Paint(object sender, PaintEventArgs e)
{
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
Gl.glLoadIdentity();
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.LoadIdentity();
// Setup wireframe or solid fill drawing mode
if (Wireframe)
Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
else
Gl.glPolygonMode(Gl.GL_FRONT, Gl.GL_FILL);
GL.PolygonMode(MaterialFace.Front, PolygonMode.Fill);
Vector3 center = Vector3.Zero;
Glu.gluLookAt(
center.X, (double)scrollZoom.Value * 0.1d + center.Y, center.Z,
center.X, center.Y, center.Z,
0d, 0d, 1d);
OpenTK.Matrix4 lookAt = OpenTK.Matrix4.LookAt(
center.X, scrollZoom.Value * 0.1f + center.Y, center.Z,
center.X, center.Y, center.Z,
0f, 0f, 1f);
GL.LoadMatrix(ref lookAt);
// Push the world matrix
Gl.glPushMatrix();
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
GL.PushMatrix();
GL.EnableClientState(ArrayCap.VertexArray);
GL.EnableClientState(ArrayCap.TextureCoordArray);
// World rotations
Gl.glRotatef((float)scrollRoll.Value, 1f, 0f, 0f);
Gl.glRotatef((float)scrollPitch.Value, 0f, 1f, 0f);
Gl.glRotatef((float)scrollYaw.Value, 0f, 0f, 1f);
GL.Rotate((float)scrollRoll.Value, 1f, 0f, 0f);
GL.Rotate((float)scrollPitch.Value, 0f, 1f, 0f);
GL.Rotate((float)scrollYaw.Value, 0f, 0f, 1f);
if (Prims != null)
{
@@ -115,12 +113,12 @@ namespace PrimWorkshop
Primitive prim = Prims[i].Prim;
if (i == cboPrim.SelectedIndex)
Gl.glColor3f(1f, 0f, 0f);
GL.Color3(1f, 0f, 0f);
else
Gl.glColor3f(1f, 1f, 1f);
GL.Color3(1f, 1f, 1f);
// Individual prim matrix
Gl.glPushMatrix();
GL.PushMatrix();
// The root prim position is sim-relative, while child prim positions are
// parent-relative. We want to apply parent-relative translations but not
@@ -128,12 +126,12 @@ namespace PrimWorkshop
if (Prims[i].Prim.ParentID != 0)
{
// Apply prim translation and rotation
Gl.glMultMatrixf(Math3D.CreateTranslationMatrix(prim.Position));
Gl.glMultMatrixf(Math3D.CreateRotationMatrix(prim.Rotation));
GL.MultMatrix(Math3D.CreateTranslationMatrix(prim.Position));
GL.MultMatrix(Math3D.CreateRotationMatrix(prim.Rotation));
}
// Prim scaling
Gl.glScalef(prim.Scale.X, prim.Scale.Y, prim.Scale.Z);
GL.Scale(prim.Scale.X, prim.Scale.Y, prim.Scale.Z);
// Draw the prim faces
for (int j = 0; j < Prims[i].Faces.Count; j++)
@@ -142,7 +140,7 @@ namespace PrimWorkshop
{
// This prim is currently selected in the dropdown
//Gl.glColor3f(0f, 1f, 0f);
Gl.glColor3f(1f, 1f, 1f);
GL.Color3(1f, 1f, 1f);
if (j == cboFace.SelectedIndex)
{
@@ -156,7 +154,7 @@ namespace PrimWorkshop
else
{
// This prim is not currently selected in the dropdown
Gl.glColor3f(1f, 1f, 1f);
GL.Color3(1f, 1f, 1f);
}
#region Texturing
@@ -169,51 +167,52 @@ namespace PrimWorkshop
// Set the color to solid white so the texture is not altered
//Gl.glColor3f(1f, 1f, 1f);
// Enable texturing for this face
Gl.glEnable(Gl.GL_TEXTURE_2D);
GL.Enable(EnableCap.Texture2D);
}
else
{
Gl.glDisable(Gl.GL_TEXTURE_2D);
GL.Disable(EnableCap.Texture2D);
}
// Bind the texture
Gl.glBindTexture(Gl.GL_TEXTURE_2D, data.TexturePointer);
GL.BindTexture(TextureTarget.Texture2D, data.TexturePointer);
#endregion Texturing
Gl.glTexCoordPointer(2, Gl.GL_FLOAT, 0, data.TexCoords);
Gl.glVertexPointer(3, Gl.GL_FLOAT, 0, data.Vertices);
Gl.glDrawElements(Gl.GL_TRIANGLES, data.Indices.Length, Gl.GL_UNSIGNED_SHORT, data.Indices);
GL.TexCoordPointer(2, TexCoordPointerType.Float, 0, data.TexCoords);
GL.VertexPointer(3, VertexPointerType.Float, 0, data.Vertices);
GL.DrawElements(BeginMode.Triangles, data.Indices.Length, DrawElementsType.UnsignedShort, data.Indices);
}
// Pop the prim matrix
Gl.glPopMatrix();
GL.PopMatrix();
}
}
// Pop the world matrix
Gl.glPopMatrix();
GL.PopMatrix();
GL.DisableClientState(ArrayCap.TextureCoordArray);
GL.DisableClientState(ArrayCap.VertexArray);
Gl.glDisableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
Gl.glFlush();
GL.Flush();
}
private void glControl_Resize(object sender, EventArgs e)
{
Gl.glClearColor(0.39f, 0.58f, 0.93f, 1.0f);
GL.ClearColor(0.39f, 0.58f, 0.93f, 1.0f);
Gl.glViewport(0, 0, glControl.Width, glControl.Height);
GL.Viewport(0, 0, glControl.Width, glControl.Height);
Gl.glPushMatrix();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
GL.PushMatrix();
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
Glu.gluPerspective(50.0d, 1.0d, 0.1d, 256d);
OpenTK.Matrix4 perspectiveMatrix = OpenTK.Matrix4.CreatePerspectiveFieldOfView(50.0f, 1.0f, 0.1f, 256f);
GL.LoadMatrix(ref perspectiveMatrix);
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glPopMatrix();
GL.MatrixMode(MatrixMode.Modelview);
GL.PopMatrix();
}
#endregion GLControl Callbacks
@@ -428,18 +427,19 @@ namespace PrimWorkshop
Bitmap bitmap = new Bitmap(data.Texture);
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
Rectangle rectangle = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
BitmapData bitmapData = bitmap.LockBits(rectangle, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
BitmapData bitmapData = bitmap.LockBits(rectangle, ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Gl.glGenTextures(1, out data.TexturePointer);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, data.TexturePointer);
GL.GenTextures(1, out data.TexturePointer);
GL.BindTexture(TextureTarget.Texture2D, data.TexturePointer);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR_MIPMAP_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_REPEAT);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_REPEAT);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_GENERATE_MIPMAP, Gl.GL_TRUE);
Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, Gl.GL_RGB8, bitmap.Width, bitmap.Height, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapData.Scan0);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.LinearMipmapLinear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)All.ClampToEdge);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)All.ClampToEdge);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1);
OpenTK.Graphics.Glu.Build2DMipmap(OpenTK.Graphics.TextureTarget.Texture2D, (int)OpenTK.Graphics.PixelInternalFormat.Rgb8,
bitmap.Width, bitmap.Height, OpenTK.Graphics.PixelFormat.Bgr, OpenTK.Graphics.PixelType.UnsignedByte, bitmapData.Scan0);
bitmap.UnlockBits(bitmapData);
bitmap.Dispose();
@@ -510,19 +510,20 @@ namespace PrimWorkshop
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
// Create the GL texture space
Gl.glGenTextures(1, TexturePointers);
GL.GenTextures(1, TexturePointers);
Rectangle rectangle = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
BitmapData bitmapData = bitmap.LockBits(rectangle, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
BitmapData bitmapData = bitmap.LockBits(rectangle, ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, TexturePointers[0]);
GL.BindTexture(TextureTarget.Texture2D, TexturePointers[0]);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR_MIPMAP_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP_TO_EDGE);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP_TO_EDGE);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_GENERATE_MIPMAP, Gl.GL_TRUE);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.LinearMipmapLinear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)All.ClampToEdge);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)All.ClampToEdge);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1);
Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, Gl.GL_RGB8, bitmap.Width, bitmap.Height, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapData.Scan0);
OpenTK.Graphics.Glu.Build2DMipmap(OpenTK.Graphics.TextureTarget.Texture2D, (int)OpenTK.Graphics.PixelInternalFormat.Rgb8,
bitmap.Width, bitmap.Height, OpenTK.Graphics.PixelFormat.Bgr, OpenTK.Graphics.PixelType.UnsignedByte, bitmapData.Scan0);
bitmap.UnlockBits(bitmapData);
bitmap.Dispose();

View File

@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Lyncee.OpenTK" version="1.1.1173.43181" targetFramework="net40" />
<package id="Lyncee.OpenTK.Compatibility" version="1.1.1173.43181" targetFramework="net40" />
<package id="OpenTK" version="2.0.0" targetFramework="net40" />
<package id="OpenTK.GLControl" version="1.1.2349.61993" targetFramework="net40" />
<package id="SharpZipLib" version="0.86.0" targetFramework="net40" />
</packages>