]> O.S.I.I.S - jp/crow.git/commitdiff
put OpenTKCrowWin in game win
authorjpbruyere <jp.bruyere@hotmail.com>
Thu, 21 Jul 2016 04:43:51 +0000 (06:43 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Thu, 21 Jul 2016 04:43:51 +0000 (06:43 +0200)
16 files changed:
Crow.csproj
Crow.sln
Images/Icons/crow.png [new file with mode: 0644]
Images/Icons/crow.svg [new file with mode: 0644]
OTKCrow/OTKCrow.csproj [deleted file]
OTKCrow/OpenGL/Shader.cs [deleted file]
OTKCrow/OpenGL/vaoMesh.cs [deleted file]
OTKCrow/OpenTKGameWindow.cs [deleted file]
Tests/GLCrow.cs [deleted file]
Tests/GOLIBTests.cs [deleted file]
Tests/OpenGL/Shader.cs [new file with mode: 0644]
Tests/OpenGL/vaoMesh.cs [new file with mode: 0644]
Tests/OpenTK.dll.config [deleted file]
Tests/OpenTKGameWindow.cs [new file with mode: 0644]
Tests/Tests.csproj
src/GraphicObjects/Window.cs

index 722764a14393b90da172ebfd64853b1b53afd4e0..2933f844227747c25ecbc207eddee6ebba2dc410 100644 (file)
     <Reference Include="System.Drawing" />
     <Reference Include="cairo-sharp">
       <HintPath>$(SolutionDir)packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\cairo-sharp.dll</HintPath>
+      <Package>gtk-sharp-3.0</Package>
     </Reference>
     <Reference Include="gdk-sharp">
       <HintPath>$(SolutionDir)packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\gdk-sharp.dll</HintPath>
+      <Package>gtk-sharp-2.0</Package>
     </Reference>
     <Reference Include="gio-sharp">
       <HintPath>$(SolutionDir)packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\gio-sharp.dll</HintPath>
+      <Package>gio-sharp-3.0</Package>
     </Reference>
     <Reference Include="glib-sharp">
       <HintPath>$(SolutionDir)packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\glib-sharp.dll</HintPath>
+      <Package>glib-sharp-3.0</Package>
     </Reference>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
     <EmbeddedResource Include="Styles\TextRun.style" />
     <EmbeddedResource Include="Styles\TabItem.style" />
     <EmbeddedResource Include="Styles\Slider.style" />
+    <EmbeddedResource Include="Images\Icons\crow.png" />
+    <EmbeddedResource Include="Images\Icons\crow.svg" />
   </ItemGroup>
   <ItemGroup>
     <None Include="README.md" />
index d24e6d4fb2f06db8558cf7a03cd94022d3d2b843..81c03617a44f37ce432bcdf27e0977ed405a3df3 100644 (file)
--- a/Crow.sln
+++ b/Crow.sln
@@ -5,18 +5,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crow", "Crow.csproj", "{C29
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{74289092-9F70-4941-AFCB-DFD7BE2140B6}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OTKCrow", "OTKCrow\OTKCrow.csproj", "{350D4F49-9901-4998-9903-BCA7D48DA58C}"
-EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
                Release|Any CPU = Release|Any CPU
        EndGlobalSection
        GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {350D4F49-9901-4998-9903-BCA7D48DA58C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-               {350D4F49-9901-4998-9903-BCA7D48DA58C}.Debug|Any CPU.Build.0 = Debug|Any CPU
-               {350D4F49-9901-4998-9903-BCA7D48DA58C}.Release|Any CPU.ActiveCfg = Release|Any CPU
-               {350D4F49-9901-4998-9903-BCA7D48DA58C}.Release|Any CPU.Build.0 = Release|Any CPU
                {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/Images/Icons/crow.png b/Images/Icons/crow.png
new file mode 100644 (file)
index 0000000..7b737d0
Binary files /dev/null and b/Images/Icons/crow.png differ
diff --git a/Images/Icons/crow.svg b/Images/Icons/crow.svg
new file mode 100644 (file)
index 0000000..4904e68
--- /dev/null
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   version="1.1"
+   id="svg4242"
+   viewBox="0 0 256 256"
+   height="256"
+   width="256">
+  <defs
+     id="defs4244">
+    <radialGradient
+       r="110.25913"
+       fy="270.70752"
+       fx="372.23856"
+       cy="270.70752"
+       cx="372.23856"
+       gradientTransform="matrix(1.062155,-0.3274557,0.07305654,0.2041912,-10.009476,513.34516)"
+       gradientUnits="userSpaceOnUse"
+       id="radialGradient4294"
+       xlink:href="#linearGradient3866" />
+    <linearGradient
+       id="linearGradient3866">
+      <stop
+         id="stop3868"
+         offset="0"
+         style="stop-color:#7f8084;stop-opacity:1;" />
+      <stop
+         id="stop3870"
+         offset="1"
+         style="stop-color:#33343c;stop-opacity:1;" />
+    </linearGradient>
+    <linearGradient
+       y2="306.08167"
+       x2="343.59439"
+       y1="279.60583"
+       x1="334.9541"
+       gradientTransform="matrix(1,0,0,1.0091769,40.07781,159.75914)"
+       gradientUnits="userSpaceOnUse"
+       id="linearGradient4296"
+       xlink:href="#linearGradient3876" />
+    <linearGradient
+       id="linearGradient3876">
+      <stop
+         id="stop3878"
+         offset="0"
+         style="stop-color:#ffffff;stop-opacity:1;" />
+      <stop
+         style="stop-color:#7f7f7f;stop-opacity:1;"
+         offset="0.64247584"
+         id="stop3884" />
+      <stop
+         id="stop3880"
+         offset="1"
+         style="stop-color:#1a1a1a;stop-opacity:1;" />
+    </linearGradient>
+  </defs>
+  <metadata
+     id="metadata4247">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     transform="translate(0,-796.36219)"
+     id="layer1">
+    <g
+       transform="matrix(1.2350742,-0.53882275,0.65916664,1.4650343,-673.53297,471.49303)"
+       id="g4184">
+      <path
+         style="opacity:1;fill:url(#radialGradient4294);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.96044916px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+         d="m 487.68304,411.00893 c -2.99682,-0.23105 -5.81177,-0.55121 -9.1875,-0.59375 -8.40713,2.77744 -30.28806,5.94556 -33.03125,6.90625 -42.47708,7.28343 -94.98471,24.15339 -120.90625,39.21875 l 4.5,12 c -2.11072,-3.69563 -4.31718,-7.19861 -5.78125,-12.1875 -0.18227,2.82859 0.84496,7.82162 1.5,9.53125 0.65503,1.70962 1.61057,3.36756 3.34375,5.96875 -1.99166,-0.84449 -7.11658,-11.75343 -7.375,-12.875 -0.15386,-0.66767 1.05534,10.33056 2.84375,11.6875 -1.80696,-1.49188 -1.52305,-1.66181 -2.75,-2.84375 -1.22696,-1.18195 -2.71173,-3.93719 -3.9375,-5.0625 0.3843,2.49805 3.42098,8.39174 4.8125,9.40625 -0.86053,-0.0279 -2.97317,-2.46587 -3.46875,-3.03125 -0.99115,-1.13075 -1.48932,-3.9565 -2.03125,-4.9375 -0.50246,0.39731 -1.6681,3.34737 -2.0625,4 -0.39441,0.65262 -0.74884,1.40612 -1.03125,2.25 -0.56482,1.68775 -0.87547,3.68174 -0.96875,5.75 -0.0933,2.06825 0.0591,4.22015 0.46875,6.15625 0.20483,0.96804 0.47603,1.87987 0.8125,2.71875 0.33646,0.83887 0.71548,1.60436 1.1875,2.25 0.70264,0.75969 1.84388,1.48568 3.25,2.15625 1.40611,0.67056 3.0821,1.28578 4.84375,1.8125 1.76164,0.52671 3.60577,0.95312 5.375,1.28125 1.76922,0.32812 3.47738,0.55018 4.90625,0.625 0.24031,-0.0875 -0.45581,-0.78256 -1.3125,-2.15625 -0.42835,-0.68686 -0.90225,-1.56763 -1.3125,-2.59375 -0.41026,-1.02613 -0.77149,-2.21654 -0.96875,-3.59375 0.5081,1.36152 1.77536,3.78883 3.0625,5.34375 1.28714,1.55493 5.38999,3.14625 5.5,3.03125 -1.03917,-1.47385 -1.47448,-2.2088 -1.71875,-4.5625 -0.16233,-1.56406 -0.31418,-1.70098 -0.3125,-2.59375 0.002,-1.18053 -0.57594,-1.72994 -0.53125,-2.03125 1.77126,1.56 0.69713,6.57726 3.03125,8.65625 0.54324,0.48387 1.40275,0.27647 2.375,0.4375 0.36923,-0.0588 2.2407,0.0938 2.625,0.0312 l -4.34375,-9.75 5.75,9.5 c 2.18192,-0.25918 6.49585,-2.30584 6.53125,-2.3125 -1.93129,-2.48728 -4.12405,-4.98149 -6.53125,-7.46875 1.76984,1.76613 7.30073,6.91537 7.78125,6.96875 2.24762,0.24967 67.93089,-26.76399 85.5,-30.96875 l -4.71875,-6.3125 6.625,5.90625 c 16.63744,-3.85235 29.80389,-5.39971 51.3125,-12.78125 2.77265,-0.72543 5.88424,-2.80725 9.125,-5.3125 l -2.96875,-9.34375 4.1875,8.375 c 1.1134,-0.89476 2.14336,-1.65364 3.3125,-2.65625 l -4.28125,-6.4375 5.9375,5.03125 c 0.22145,-0.19242 0.4641,-0.39907 0.6875,-0.59375 l -3.40625,-4.4375 4.59375,3.40625 c 1.49874,-1.3084 2.9456,-2.59231 4.53125,-3.9375 l -4.84375,-1.25 7.75,-1.03125 c 2.01674,-1.64114 4.00268,-3.30676 6.15625,-4.8125 -4.34436,-4.58536 -11.02475,-7.98537 -20.34375,-10.09375 l -5.71875,4.15625 3.875,-4.59375 c -0.34329,-0.0684 -0.74363,-0.0912 -1.09375,-0.15625 l -6.34375,4.375 3.09375,-4.90625 c -0.40346,-0.0596 -0.77578,-0.13199 -1.1875,-0.1875 l -6.1875,6.1875 3.78125,-6.4375 c -0.69105,-0.0777 -1.53691,-0.0583 -2.25,-0.125 l -7.25,7.96875 5.1875,-8.125 z"
+         id="path4150" />
+      <path
+         style="fill:url(#linearGradient4296);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+         d="m 502.57781,423.08731 c -85.9867,11.86766 -158.64637,39.03586 -212.85714,75.32784 -0.54182,2.60394 0.35052,2.5753 2.37373,3.22191 50.90148,-37.35132 134.86502,-67.36701 210.48341,-78.54975 z"
+         id="path4143" />
+    </g>
+    <text
+       id="text4912"
+       y="1041.6479"
+       x="85.000008"
+       style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Arial Black';-inkscape-font-specification:'Arial Black, '"
+         y="1041.6479"
+         x="85.000008"
+         id="tspan4914">C<tspan
+   id="tspan4916"
+   style="font-size:15px">.</tspan>R<tspan
+   id="tspan4918"
+   style="font-size:15px">.</tspan>O<tspan
+   id="tspan4922"
+   style="font-size:15px">.</tspan>W<tspan
+   id="tspan4924"
+   style="font-size:15px">.</tspan></tspan></text>
+  </g>
+</svg>
diff --git a/OTKCrow/OTKCrow.csproj b/OTKCrow/OTKCrow.csproj
deleted file mode 100644 (file)
index 6a55770..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{350D4F49-9901-4998-9903-BCA7D48DA58C}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <RootNamespace>OTKCrow</RootNamespace>
-    <AssemblyName>OTKCrow</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <ProductVersion>8.0.30703</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ReleaseVersion>0.4</ReleaseVersion>
-    <OutputPath>$(SolutionDir)/build/$(Configuration)</OutputPath>
-    <IntermediateOutputPath>$(SolutionDir)/build/obj/$(Configuration)</IntermediateOutputPath>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <DefineConstants>DEBUG;MEASURE_TIME</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <ConsolePause>false</ConsolePause>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>full</DebugType>
-    <Optimize>true</Optimize>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <ConsolePause>false</ConsolePause>
-  </PropertyGroup>
-  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-  <ItemGroup>
-    <Reference Include="System" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-    <Reference Include="System.Drawing" />
-    <Reference Include="cairo-sharp">
-      <HintPath>..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\cairo-sharp.dll</HintPath>
-    </Reference>
-    <Reference Include="OpenTK">
-      <HintPath>..\packages\OpenTK.Next.1.2.2336.6514-pre\lib\net20\OpenTK.dll</HintPath>
-    </Reference>
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="OpenTKGameWindow.cs" />
-    <Compile Include="OpenGL\Shader.cs" />
-    <Compile Include="OpenGL\vaoMesh.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\Crow.csproj">
-      <Project>{C2980F9B-4798-4C05-99E2-E174810F7C7B}</Project>
-      <Name>Crow</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <ItemGroup>
-    <Folder Include="OpenGL\" />
-  </ItemGroup>
-</Project>
diff --git a/OTKCrow/OpenGL/Shader.cs b/OTKCrow/OpenGL/Shader.cs
deleted file mode 100644 (file)
index 54f9140..0000000
+++ /dev/null
@@ -1,317 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.IO;
-using System.Reflection;
-using OpenTK;
-using OpenTK.Graphics.OpenGL;
-using System.Collections.Generic;
-
-namespace Tetra
-{
-       public class Shader : IDisposable
-       {
-               #region CTOR
-               public Shader ()
-               {
-                       Init ();
-               }
-               public Shader (string vertResPath, string fragResPath = null, string geomResPath = null)
-               {
-                       VertSourcePath = vertResPath;
-                       FragSourcePath = fragResPath;
-                       GeomSourcePath = geomResPath;
-
-                       loadSourcesFiles ();
-
-                       Init ();
-               }
-               #endregion
-
-               public string   VertSourcePath,
-                                               FragSourcePath,
-                                               GeomSourcePath;
-               #region Sources
-               protected string _vertSource = @"
-                       #version 330
-                       precision lowp float;
-
-                       uniform mat4 mvp;
-
-                       layout(location = 0) in vec3 in_position;
-                       layout(location = 1) in vec2 in_tex;
-
-                       out vec2 texCoord;
-
-                       void main(void)
-                       {
-                               texCoord = in_tex;
-                               gl_Position = mvp * vec4(in_position, 1.0);
-                       }";
-
-               protected string _fragSource = @"
-                       #version 330
-                       precision lowp float;
-
-                       uniform sampler2D tex;
-
-                       in vec2 texCoord;
-                       out vec4 out_frag_color;
-
-                       void main(void)
-                       {
-                               out_frag_color = texture( tex, texCoord);
-                       }";
-               string _geomSource = @"";
-//                     #version 330
-//                     layout(triangles) in;
-//                     layout(triangle_strip, max_vertices=3) out;
-//                     void main()
-//                     {
-//                             for(int i=0; i<3; i++)
-//                             {
-//                                     gl_Position = gl_in[i].gl_Position;
-//                                     EmitVertex();
-//                             }
-//                             EndPrimitive();
-//                     }";
-               #endregion
-
-               #region Private and protected fields
-               public int vsId, fsId, gsId, pgmId, mvpLocation;
-
-               Matrix4 mvp = Matrix4.Identity;
-               #endregion
-
-
-               #region Public properties
-               public virtual string vertSource
-               {
-                       get { return _vertSource;}
-                       set { _vertSource = value; }
-               }
-               public virtual string fragSource
-               {
-                       get { return _fragSource;}
-                       set { _fragSource = value; }
-               }
-               public virtual string geomSource
-               {
-                       get { return _geomSource; }
-                       set { _geomSource = value; }
-               }
-
-               public virtual Matrix4 MVP{
-                       set { mvp = value; }
-                       get { return mvp; }
-               }
-               #endregion
-
-               #region Public functions
-               /// <summary>
-               /// configure sources and compile
-               /// </summary>
-               public virtual void Init()
-               {
-                       Compile ();
-               }
-               public void Reload(){
-                       loadSourcesFiles ();
-                       Compile ();
-               }
-               public void SetSource(ShaderType shaderType, string _source){
-                       switch (shaderType) {
-                       case ShaderType.FragmentShader:
-                               fragSource = _source;
-                               return;
-                       case ShaderType.VertexShader:
-                               vertSource = _source;
-                               return;
-                       case ShaderType.GeometryShader:
-                               geomSource = _source;
-                               return;
-                       }
-               }
-               public string GetSource(ShaderType shaderType){
-                       switch (shaderType) {
-                       case ShaderType.FragmentShader:
-                               return fragSource;
-                       case ShaderType.VertexShader:
-                               return vertSource;
-                       case ShaderType.GeometryShader:
-                               return geomSource;
-                       }
-                       return "";
-               }
-               public string GetSourcePath(ShaderType shaderType){
-                       switch (shaderType) {
-                       case ShaderType.FragmentShader:
-                               return FragSourcePath;
-                       case ShaderType.VertexShader:
-                               return VertSourcePath;
-                       case ShaderType.GeometryShader:
-                               return GeomSourcePath;
-                       }
-                       return "";
-               }
-               public virtual void Compile()
-               {
-                       Dispose ();
-
-                       pgmId = GL.CreateProgram();
-
-                       if (!string.IsNullOrEmpty(vertSource))
-                       {
-                               vsId = GL.CreateShader(ShaderType.VertexShader);
-                               compileShader(vsId, vertSource);
-                       }
-                       if (!string.IsNullOrEmpty(fragSource))
-                       {
-                               fsId = GL.CreateShader(ShaderType.FragmentShader);
-                               compileShader(fsId, fragSource);
-
-                       }
-                       if (!string.IsNullOrEmpty(geomSource))
-                       {
-                               gsId = GL.CreateShader(ShaderType.GeometryShader);
-                               compileShader(gsId,geomSource);
-                       }
-
-                       if (vsId != 0)
-                               GL.AttachShader(pgmId, vsId);
-                       if (fsId != 0)
-                               GL.AttachShader(pgmId, fsId);
-                       if (gsId != 0)
-                               GL.AttachShader(pgmId, gsId);
-
-                       BindVertexAttributes ();
-
-                       string info;
-                       GL.LinkProgram(pgmId);
-                       GL.GetProgramInfoLog(pgmId, out info);
-
-                       if (!string.IsNullOrEmpty (info)) {
-                               Debug.WriteLine ("Linkage:");
-                               Debug.WriteLine (info);
-                       }
-
-                       info = null;
-
-                       GL.ValidateProgram(pgmId);
-                       GL.GetProgramInfoLog(pgmId, out info);
-                       if (!string.IsNullOrEmpty (info)) {
-                               Debug.WriteLine ("Validation:");
-                               Debug.WriteLine (info);
-                       }
-
-                       GL.UseProgram (pgmId);
-
-                       GetUniformLocations ();
-                       BindSamplesSlots ();
-
-                       Disable ();
-               }
-
-               protected virtual void BindVertexAttributes()
-               {
-                       GL.BindAttribLocation(pgmId, 0, "in_position");
-                       GL.BindAttribLocation(pgmId, 1, "in_tex");
-               }
-               protected virtual void GetUniformLocations()
-               {
-                       mvpLocation = GL.GetUniformLocation(pgmId, "mvp");
-               }
-               protected virtual void BindSamplesSlots(){
-                       GL.Uniform1(GL.GetUniformLocation (pgmId, "tex"), 0);
-               }
-               public void SetMVP(Matrix4 _mvp){
-                       GL.UniformMatrix4(mvpLocation, false, ref _mvp);
-               }
-               public virtual void Enable(){
-                       GL.UseProgram (pgmId);
-               }
-               public virtual void Disable(){
-                       GL.UseProgram (0);
-               }
-               public static void Enable(Shader s)
-               {
-                       if (s == null)
-                               return;
-                       s.Enable ();
-               }
-               public static void Disable(Shader s)
-               {
-                       if (s == null)
-                               return;
-                       s.Disable ();
-               }
-               #endregion
-
-               void loadSourcesFiles(){
-                       Stream s;
-
-                       if (!string.IsNullOrEmpty (VertSourcePath)) {
-                               s = Crow.Interface.GetStreamFromPath (VertSourcePath);
-                               if (s != null) {
-                                       using (StreamReader sr = new StreamReader (s)) {
-                                               vertSource = sr.ReadToEnd ();
-                                       }
-                               }
-                       }
-
-                       if (!string.IsNullOrEmpty (FragSourcePath)) {
-                               s = Crow.Interface.GetStreamFromPath (FragSourcePath);
-                               if (s != null) {
-                                       using (StreamReader sr = new StreamReader (s)) {
-                                               fragSource = sr.ReadToEnd ();
-                                       }
-                               }
-                       }
-
-                       if (!string.IsNullOrEmpty (GeomSourcePath)) {
-                               s = Crow.Interface.GetStreamFromPath (GeomSourcePath);
-                               if (s != null) {
-                                       using (StreamReader sr = new StreamReader (s)) {
-                                               geomSource = sr.ReadToEnd ();
-                                       }
-                               }
-                       }                       
-               }
-               void compileShader(int shader, string source)
-               {
-                       GL.ShaderSource(shader, source);
-                       GL.CompileShader(shader);
-
-                       string info;
-                       GL.GetShaderInfoLog(shader, out info);
-                       Debug.WriteLine(info);
-
-                       int compileResult;
-                       GL.GetShader(shader, ShaderParameter.CompileStatus, out compileResult);
-                       if (compileResult != 1)
-                       {
-                               Debug.WriteLine("Compile Error!");
-                               Debug.WriteLine(source);
-                       }
-               }
-               public override string ToString ()
-               {
-                       return string.Format ("{0} {1} {2}", VertSourcePath, FragSourcePath, GeomSourcePath);
-               }
-
-               #region IDisposable implementation
-               public virtual void Dispose ()
-               {                       
-                       if (GL.IsProgram (pgmId))
-                               GL.DeleteProgram (pgmId);
-
-                       if (GL.IsShader (vsId))
-                               GL.DeleteShader (vsId);
-                       if (GL.IsShader (fsId))
-                               GL.DeleteShader (fsId);
-                       if (GL.IsShader (gsId))
-                               GL.DeleteShader (gsId);
-               }
-               #endregion
-       }
-}
-
diff --git a/OTKCrow/OpenGL/vaoMesh.cs b/OTKCrow/OpenGL/vaoMesh.cs
deleted file mode 100644 (file)
index b076362..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-using System.Collections.Generic;
-using OpenTK;
-using OpenTK.Graphics.OpenGL;
-//using System.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using System.Threading;
-using System.Diagnostics;
-using System.Linq;
-
-namespace Crow
-{
-       public class vaoMesh : IDisposable
-       {
-               public int vaoHandle,
-               positionVboHandle,
-               texVboHandle,
-               eboHandle;
-
-               public Vector3[] positions;
-               public Vector2[] texCoords;
-               public int[] indices;
-
-               public vaoMesh()
-               {
-               }
-
-               public vaoMesh (Vector3[] _positions, Vector2[] _texCoord, int[] _indices)
-               {
-                       positions = _positions;
-                       texCoords = _texCoord;
-                       indices = _indices;
-
-                       CreateVBOs ();
-                       CreateVAOs ();
-               }
-
-               public vaoMesh (float x, float y, float z, float width, float height, float TileX = 1f, float TileY = 1f)
-               {
-                       positions =
-                               new Vector3[] {
-                               new Vector3 (x - width / 2, y + height / 2, z),
-                               new Vector3 (x - width / 2, y - height / 2, z),
-                               new Vector3 (x + width / 2, y + height / 2, z),
-                               new Vector3 (x + width / 2, y - height / 2, z)
-                       };
-                       texCoords =     new Vector2[] {
-                               new Vector2 (0, TileY),
-                               new Vector2 (0, 0),
-                               new Vector2 (TileX, TileY),
-                               new Vector2 (TileX, 0)
-                       };
-                       indices = new int[] { 0, 1, 2, 3 };
-
-                       CreateVBOs ();
-                       CreateVAOs ();
-               }
-               public void CreateBuffers(){
-                       CreateVBOs ();
-                       CreateVAOs ();
-               }
-               protected void CreateVBOs()
-               {
-                       positionVboHandle = GL.GenBuffer();
-                       GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
-                       GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
-                               new IntPtr(positions.Length * Vector3.SizeInBytes),
-                               positions, BufferUsageHint.StaticDraw);
-
-                       if (texCoords != null) {
-                               texVboHandle = GL.GenBuffer ();
-                               GL.BindBuffer (BufferTarget.ArrayBuffer, texVboHandle);
-                               GL.BufferData<Vector2> (BufferTarget.ArrayBuffer,
-                                       new IntPtr (texCoords.Length * Vector2.SizeInBytes),
-                                       texCoords, BufferUsageHint.StaticDraw);
-                       }
-
-                       GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
-
-                       if (indices != null) {
-                               eboHandle = GL.GenBuffer ();
-                               GL.BindBuffer (BufferTarget.ElementArrayBuffer, eboHandle);
-                               GL.BufferData (BufferTarget.ElementArrayBuffer,
-                                       new IntPtr (sizeof(uint) * indices.Length),
-                                       indices, BufferUsageHint.StaticDraw);
-                               GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
-                       }
-               }
-               protected void CreateVAOs()
-               {
-                       vaoHandle = GL.GenVertexArray();
-                       GL.BindVertexArray(vaoHandle);
-
-                       GL.EnableVertexAttribArray(0);
-                       GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
-                       GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, true, Vector3.SizeInBytes, 0);
-
-                       if (texCoords != null) {
-                               GL.EnableVertexAttribArray (1);
-                               GL.BindBuffer (BufferTarget.ArrayBuffer, texVboHandle);
-                               GL.VertexAttribPointer (1, 2, VertexAttribPointerType.Float, true, Vector2.SizeInBytes, 0);
-                       }
-                       if (indices != null)
-                               GL.BindBuffer(BufferTarget.ElementArrayBuffer, eboHandle);
-
-                       GL.BindVertexArray(0);
-               }
-
-               public void Render(BeginMode _primitiveType){
-                       GL.BindVertexArray(vaoHandle);
-                       if (indices == null)
-                               GL.DrawArrays (_primitiveType, 0, positions.Length);
-                       else
-                               GL.DrawElements(_primitiveType, indices.Length,
-                                       DrawElementsType.UnsignedInt, IntPtr.Zero);
-                       GL.BindVertexArray (0);
-               }
-               public void Render(BeginMode _primitiveType, int[] _customIndices){
-                       GL.BindVertexArray(vaoHandle);
-                       GL.DrawElements(_primitiveType, _customIndices.Length,
-                               DrawElementsType.UnsignedInt, _customIndices);
-                       GL.BindVertexArray (0);
-               }
-               public void Render(BeginMode _primitiveType, int instances){
-
-                       GL.BindVertexArray(vaoHandle);
-                       GL.DrawElementsInstanced(_primitiveType, indices.Length,
-                               DrawElementsType.UnsignedInt, IntPtr.Zero, instances);
-                       GL.BindVertexArray (0);
-               }
-
-               #region IDisposable implementation
-               public void Dispose ()
-               {
-                       GL.DeleteBuffer (positionVboHandle);
-                       GL.DeleteBuffer (texVboHandle);
-                       GL.DeleteBuffer (eboHandle);
-                       GL.DeleteVertexArray (vaoHandle);
-               }
-               #endregion
-
-       }
-}
\ No newline at end of file
diff --git a/OTKCrow/OpenTKGameWindow.cs b/OTKCrow/OpenTKGameWindow.cs
deleted file mode 100644 (file)
index 1dcd606..0000000
+++ /dev/null
@@ -1,331 +0,0 @@
-//
-//  OpenTKGameWindow.cs
-//
-//  Author:
-//       Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
-//
-//  Copyright (c) 2016 jp
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Threading;
-using System.Xml;
-using Cairo;
-using OpenTK;
-using OpenTK.Graphics.OpenGL;
-
-namespace Crow
-{
-       public class OpenTKGameWindow : GameWindow, IValueChange
-    {
-               #region IValueChange implementation
-               public event EventHandler<ValueChangeEventArgs> ValueChanged;
-               public virtual void NotifyValueChanged(string MemberName, object _value)
-               {
-                       if (ValueChanged != null)                               
-                               ValueChanged.Invoke(this, new ValueChangeEventArgs(MemberName, _value));
-               }
-               #endregion
-
-               public Interface CrowInterface;
-
-               #region FPS
-               int frameCpt = 0;
-               int _fps = 0;
-
-               public int fps {
-                       get { return _fps; }
-                       set {
-                               if (_fps == value)
-                                       return;
-
-                               _fps = value;
-
-                               if (_fps > fpsMax) {
-                                       fpsMax = _fps;
-                                       ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMax", fpsMax));
-                               } else if (_fps < fpsMin) {
-                                       fpsMin = _fps;
-                                       ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMin", fpsMin));
-                               }
-
-                               ValueChanged.Raise(this, new ValueChangeEventArgs ("fps", _fps));
-                               #if MEASURE_TIME
-                               ValueChanged.Raise (this, new ValueChangeEventArgs ("update",
-                                       this.CrowInterface.clippingTime.ElapsedTicks.ToString () + " ticks"));
-                               ValueChanged.Raise (this, new ValueChangeEventArgs ("layouting",
-                                       this.CrowInterface.layoutTime.ElapsedTicks.ToString () + " ticks"));
-                               ValueChanged.Raise (this, new ValueChangeEventArgs ("drawing",
-                                       this.CrowInterface.drawingTime.ElapsedTicks.ToString () + " ticks"));
-                               #endif
-                       }
-               }
-
-               public int fpsMin = int.MaxValue;
-               public int fpsMax = 0;
-
-               void resetFps ()
-               {
-                       fpsMin = int.MaxValue;
-                       fpsMax = 0;
-                       _fps = 0;
-               }
-               public string update = "";
-               public string drawing = "";
-               public string layouting = "";
-               #endregion
-
-               #region ctor
-               public OpenTKGameWindow(int _width = 800, int _height = 600, string _title="Crow",
-                       int colors = 32, int depth = 24, int stencil = 0, int samples = 1,
-                       int major=3, int minor=3)
-                       : this(_width, _height, new OpenTK.Graphics.GraphicsMode(colors, depth, stencil, samples),
-                               _title,GameWindowFlags.Default,DisplayDevice.Default,
-                               major,minor,OpenTK.Graphics.GraphicsContextFlags.Default)
-               {
-               }
-               public OpenTKGameWindow (int width, int height, OpenTK.Graphics.GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device, int major, int minor, OpenTK.Graphics.GraphicsContextFlags flags)
-                       : base(width,height,mode,title,options,device,major,minor,flags)
-               {
-                       CrowInterface = new Interface ();
-
-                       Thread t = new Thread (interfaceThread);
-                       t.IsBackground = true;
-                       t.Start ();
-               }
-
-               #endregion
-
-               void interfaceThread()
-               {
-                       CrowInterface.Quit += Quit;
-                       CrowInterface.MouseCursorChanged += CrowInterface_MouseCursorChanged;
-                       while (CrowInterface.ClientRectangle.Size.Width == 0)
-                               Thread.Sleep (5);
-                       
-                       while (true) {
-                               CrowInterface.Update ();
-                               Thread.Sleep (1);
-                       }
-               }
-
-               public void Quit (object sender, EventArgs e)
-               {
-                       this.Exit ();
-               }
-               void CrowInterface_MouseCursorChanged (object sender, MouseCursorChangedEventArgs e)
-               {
-                       this.Cursor = new MouseCursor(
-                               (int)e.NewCursor.Xhot,
-                               (int)e.NewCursor.Yhot,
-                               (int)e.NewCursor.Width,
-                               (int)e.NewCursor.Height,
-                               e.NewCursor.data);
-               }
-
-               #region Events
-               //those events are raised only if mouse isn't in a graphic object
-               public event EventHandler<OpenTK.Input.MouseWheelEventArgs> MouseWheelChanged;
-               public event EventHandler<OpenTK.Input.MouseButtonEventArgs> MouseButtonUp;
-               public event EventHandler<OpenTK.Input.MouseButtonEventArgs> MouseButtonDown;
-               public event EventHandler<OpenTK.Input.MouseButtonEventArgs> MouseClick;
-               public event EventHandler<OpenTK.Input.MouseMoveEventArgs> MouseMove;
-               public event EventHandler<OpenTK.Input.KeyboardKeyEventArgs> KeyboardKeyDown;
-               public event EventHandler<OpenTK.Input.KeyboardKeyEventArgs> KeyboardKeyUp;
-
-               #endregion
-
-               #region graphic context
-               int texID;
-               Tetra.Shader shader;
-               public static Crow.vaoMesh quad;
-
-               void createContext()
-               {
-                       #region Create texture
-                       if (GL.IsTexture(texID))
-                               GL.DeleteTexture (texID);
-                       GL.GenTextures(1, out texID);
-                       GL.ActiveTexture (TextureUnit.Texture0);
-                       GL.BindTexture(TextureTarget.Texture2D, texID);
-
-                       GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba,
-                               ClientRectangle.Width, ClientRectangle.Height, 0,
-                               OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, CrowInterface.bmp);
-
-                       GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
-                       GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
-
-                       GL.BindTexture(TextureTarget.Texture2D, 0);
-                       #endregion
-               }
-               void OpenGLDraw()
-               {
-                       bool blend, depthTest;
-                       GL.GetBoolean (GetPName.Blend, out blend);
-                       GL.GetBoolean (GetPName.DepthTest, out depthTest);
-                       GL.Enable (EnableCap.Blend);
-                       GL.Disable (EnableCap.DepthTest);
-
-                       shader.Enable ();
-                       GL.ActiveTexture (TextureUnit.Texture0);
-                       GL.BindTexture (TextureTarget.Texture2D, texID);
-                       lock (CrowInterface.RenderMutex) {
-                               if (CrowInterface.IsDirty) {
-                                       GL.TexSubImage2D (TextureTarget.Texture2D, 0,
-                                               CrowInterface.DirtyRect.Left, CrowInterface.DirtyRect.Top,
-                                               CrowInterface.DirtyRect.Width, CrowInterface.DirtyRect.Height,
-                                               OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, CrowInterface.dirtyBmp);
-                                       CrowInterface.IsDirty = false;
-                               }
-                       }
-                       quad.Render (BeginMode.TriangleStrip);
-                       GL.BindTexture(TextureTarget.Texture2D, 0);
-                       shader.Disable ();
-                       if (!blend)
-                               GL.Disable (EnableCap.Blend);
-                       if (depthTest)
-                               GL.Enable (EnableCap.DepthTest);
-               }
-               #endregion
-
-               public virtual void OnRender(FrameEventArgs e)
-               {
-               }
-               public virtual void GLClear()
-               {
-                       GL.Clear (ClearBufferMask.ColorBufferBit);
-               }
-
-               #region Game win overrides
-               protected override void OnLoad(EventArgs e)
-               {
-                       base.OnLoad(e);
-
-                       this.KeyPress += new EventHandler<OpenTK.KeyPressEventArgs>(OpenTKGameWindow_KeyPress);
-                       Keyboard.KeyDown += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyDown);
-                       Keyboard.KeyUp += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyUp);
-                       Mouse.WheelChanged += new EventHandler<OpenTK.Input.MouseWheelEventArgs>(Mouse_WheelChanged);
-                       Mouse.ButtonDown += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(Mouse_ButtonDown);
-                       Mouse.ButtonUp += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(Mouse_ButtonUp);
-                       Mouse.Move += new EventHandler<OpenTK.Input.MouseMoveEventArgs>(Mouse_Move);
-
-                       GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-
-                       Console.WriteLine("\n\n*************************************");
-                       Console.WriteLine("GL version: " + GL.GetString (StringName.Version));
-                       Console.WriteLine("GL vendor: " + GL.GetString (StringName.Vendor));
-                       Console.WriteLine("GLSL version: " + GL.GetString (StringName.ShadingLanguageVersion));
-                       Console.WriteLine("*************************************\n");
-
-                       shader = new Tetra.Shader ();
-                       shader.Enable();
-                       shader.SetMVP(OpenTK.Matrix4.CreateOrthographicOffCenter (-0.5f, 0.5f, -0.5f, 0.5f, 1, -1));
-                       GL.UseProgram(0);
-                       quad = new Crow.vaoMesh (0, 0, 0, 1, 1, 1, -1);
-               }
-
-               protected override void OnUpdateFrame(FrameEventArgs e)
-               {
-                       base.OnUpdateFrame(e);
-                       fps = (int)RenderFrequency;
-
-
-                       if (frameCpt > 50) {
-                               resetFps ();
-                               frameCpt = 0;
-                               GC.Collect();
-                               GC.WaitForPendingFinalizers();
-                               NotifyValueChanged("memory", GC.GetTotalMemory (false).ToString());
-                       }
-                       frameCpt++;
-                       //CrowInterface.Update ();
-               }
-               protected override void OnRenderFrame(FrameEventArgs e)
-               {
-                       GLClear ();
-
-                       base.OnRenderFrame(e);
-
-                       OnRender (e);
-                       OpenGLDraw ();
-
-                       SwapBuffers ();
-               }
-
-               protected override void OnResize(EventArgs e)
-               {
-                       base.OnResize (e);
-                       CrowInterface.ProcessResize(
-                               new Rectangle(
-                               0,
-                               0,
-                               this.ClientRectangle.Width,
-                               this.ClientRectangle.Height));
-                       createContext ();
-                       GL.Viewport (0, 0, ClientRectangle.Width, ClientRectangle.Height);
-               }
-               #endregion
-
-               #region Mouse Handling
-               void update_mouseButtonStates(ref MouseState e, OpenTK.Input.MouseState otk_e){
-                       for (int i = 0; i < MouseState.MaxButtons; i++) {
-                               if (otk_e.IsButtonDown ((OpenTK.Input.MouseButton)i))
-                                       e.EnableBit (i);
-                       }
-               }
-               void Mouse_Move(object sender, OpenTK.Input.MouseMoveEventArgs otk_e)
-        {
-                       if (!CrowInterface.ProcessMouseMove (otk_e.X, otk_e.Y))
-                               MouseMove.Raise (sender, otk_e);
-        }
-               void Mouse_ButtonUp(object sender, OpenTK.Input.MouseButtonEventArgs otk_e)
-        {
-                       if (!CrowInterface.ProcessMouseButtonUp ((int)otk_e.Button))
-                               MouseButtonUp.Raise (sender, otk_e);
-        }
-               void Mouse_ButtonDown(object sender, OpenTK.Input.MouseButtonEventArgs otk_e)
-               {
-                       if (!CrowInterface.ProcessMouseButtonDown ((int)otk_e.Button))
-                               MouseButtonDown.Raise (sender, otk_e);
-        }
-               void Mouse_WheelChanged(object sender, OpenTK.Input.MouseWheelEventArgs otk_e)
-        {
-                       if (!CrowInterface.ProcessMouseWheelChanged (otk_e.DeltaPrecise))
-                               MouseWheelChanged.Raise (sender, otk_e);
-        }
-               #endregion
-
-               #region keyboard Handling
-               void Keyboard_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs otk_e)
-               {
-                       //if (!CrowInterface.ProcessKeyDown((int)otk_e.Key))
-                               KeyboardKeyDown.Raise (this, otk_e);
-        }
-               void Keyboard_KeyUp(object sender, OpenTK.Input.KeyboardKeyEventArgs otk_e)
-               {
-                       //if (!CrowInterface.ProcessKeyUp((int)otk_e.Key))
-                               KeyboardKeyUp.Raise (this, otk_e);
-               }
-               void OpenTKGameWindow_KeyPress (object sender, OpenTK.KeyPressEventArgs e)
-               {
-                       CrowInterface.ProcessKeyPress (e.KeyChar);
-               }
-        #endregion
-    }
-}
diff --git a/Tests/GLCrow.cs b/Tests/GLCrow.cs
deleted file mode 100644 (file)
index 1ede026..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-//
-//  GLCrow.cs
-//
-//  Author:
-//       Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
-//
-//  Copyright (c) 2016 jp
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-using System;
-using GLC;
-using Pencil.Gaming;
-using System.Collections.Generic;
-using Crow;
-using System.Linq;
-using System.IO;
-
-namespace Tests
-{
-       public class GLCrow : GLC.Window
-       {
-               int idx = 0;
-               string [] testFiles;
-
-               public int intValue = 25;
-
-               public int IntValue {
-                       get {
-                               return intValue;
-                       }
-                       set {
-                               intValue = value;
-                               NotifyValueChanged ("IntValue", intValue);
-                       }
-               }
-               void onSpinnerValueChange(object sender, ValueChangeEventArgs e){
-                       if (e.MemberName != "Value")
-                               return;
-                       intValue = Convert.ToInt32(e.NewValue);
-               }
-               void change_alignment(object sender, EventArgs e){
-                       RadioButton rb = sender as RadioButton;
-                       if (rb == null)
-                               return;
-                       NotifyValueChanged ("alignment", Enum.Parse(typeof(Alignment), rb.Caption));
-               }
-               public IList<String> List2 = new List<string>(new string[]
-                       {
-                               "string1",
-                               "string2"
-                               //"string3",
-                               //"string4",
-                               //"string5",
-                               //"string6",
-                               //"string7",
-                               //"string8",
-                               //"string8",
-                               //"string8",
-                               //"string8",
-                               //"string8",
-                               //"string8",
-                               //"string9"
-                       }
-               );
-               IList<Color> testList = Color.ColorDic.ToList();
-               public IList<Color> TestList {
-                       set{
-                               testList = value;
-                               NotifyValueChanged ("TestList", testList);
-                       }
-                       get { return testList; }
-               }
-
-               void OnClear (object sender, MouseButtonEventArgs e) => TestList = null;
-
-               void OnLoadList (object sender, MouseButtonEventArgs e) => TestList = Color.ColorDic.ToList();
-
-
-               [STAThread]
-               public static void Main (string [] args)
-               {
-                       using (GLCrow w = new GLCrow ()) {                              
-                               w.Run (30);
-                       }
-               }
-               public object data = "datas";
-               public object Datas {
-                       get { return data; }
-               }
-               void onSetDataToNull (object sender, MouseButtonEventArgs e) {
-                       data = null;
-                       NotifyValueChanged ("Datas", null);
-               }
-               public override void OnLoad ()
-               {
-                       //testFiles = new string [] { @"Interfaces/Divers/testBind0.crow" };
-                       testFiles = new string [] { @"Interfaces/Divers/testCombobox.crow" };
-                       testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray ();
-                       //testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/basicTests", "*.crow")).ToArray ();
-                       testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Container", "*.crow")).ToArray ();
-                       testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Group", "*.crow")).ToArray ();
-                       testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Stack", "*.crow")).ToArray ();
-                       testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Splitter", "*.crow")).ToArray ();
-                       testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Expandable", "*.crow")).ToArray ();
-                       testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Divers", "*.crow")).ToArray ();
-
-                       //testFiles = Directory.GetFiles(@"Interfaces", "*.crow").Concat(testFiles).ToArray();
-                       this.Title = testFiles [idx];
-                       CrowInterface.LoadInterface(testFiles[idx]).DataSource = this;
-                                               
-                       //CrowInterface.LoadInterface ("#Tests.ui.fps.crow").DataSource = this;                 
-               }
-               public GLCrow(int _width = 800, int _height=600)
-                       :base(_width, _height, 32, 24, 0, 8, "TestWin")
-               {
-                       
-               }
-
-               protected override void OnKeyEvent (GlfwWindowPtr wnd, Pencil.Gaming.Key key, int scanCode, KeyAction action, Pencil.Gaming.KeyModifiers mods)
-               {
-                       base.OnKeyEvent (wnd, key, scanCode, action, mods);
-                       switch (action) {
-                       case KeyAction.Release:
-                               
-                               break;
-                       case KeyAction.Press:
-                               if (key == Pencil.Gaming.Key.Space) {
-                                       CrowInterface.ClearInterface ();
-                                       idx++;
-                                       if (idx == testFiles.Length)
-                                               idx = 0;
-                                       this.Title = testFiles [idx];
-                                       CrowInterface.LoadInterface(testFiles[idx]).DataSource = this;
-
-                               }
-                               break;
-                       }
-               }
-       }
-}
-
diff --git a/Tests/GOLIBTests.cs b/Tests/GOLIBTests.cs
deleted file mode 100644 (file)
index 53f3659..0000000
+++ /dev/null
@@ -1,277 +0,0 @@
-#define MONO_CAIRO_DEBUG_DISPOSE
-
-
-using System;
-using System.Runtime.InteropServices;
-using OpenTK;
-using OpenTK.Graphics.OpenGL;
-
-using System.Diagnostics;
-
-//using GGL;
-using Crow;
-using System.Threading;
-using System.Collections.Generic;
-using System.Linq;
-
-
-namespace test
-{
-       class GOLIBTests : OpenTKGameWindow, IValueChange
-       {
-               #region IValueChange implementation
-               public event EventHandler<ValueChangeEventArgs> ValueChanged;
-               public virtual void NotifyValueChanged(string MemberName, object _value)
-               {
-                       ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));                 
-               }
-               #endregion
-
-               public GOLIBTests ()
-                       : base(800, 600,"test: press spacebar to toogle test files")
-               {
-                       //VSync = VSyncMode.Off;
-                       Interface.CurrentInterface = CrowInterface;
-                       GraphicObject obj = CrowInterface.LoadInterface("Interfaces/" + testFiles[idx]);
-                       obj.DataSource = this;
-
-               }
-
-               int frameCpt = 0;
-               int idx = 0;
-               string[] testFiles = {
-                       "testMsgBox.goml",
-                       "testCombobox.goml",
-                       "testExpandable.goml",
-                       "test_Listbox.goml",
-                       "6.crow",
-                       "testGroupBox.goml",
-                       "1.crow",
-                       "5.crow",
-                       "testCheckbox.goml",
-                       "testWindow.goml",
-                       "fps.goml",
-                       "testTabView.crow",
-                       "0.crow",
-                       "testImage.crow",
-                       "testOutOfClipUpdate.crow",
-//                     "test_Listbox.goml",
-//                     "testTreeView.crow",
-                       "1.crow",
-                       "clip4.crow",
-                       "clip3.crow",
-                       "clip2.crow",
-                       "clip0.crow",
-                       "clip1.crow",
-                       "testPopper.goml",
-                       "testTextBox.crow",
-                       "testColorList.crow",
-//                     "5.crow",
-//                     "testCombobox.goml",
-//                     "testPopper.goml",
-                       "testTextBox.crow",
-//                     "testColorList.crow",
-                       "4.crow",
-                       "testSpinner.goml",
-                       "testScrollbar.goml",
-                       "testGrid.goml",
-                       "testButton.crow",
-                       "testBorder.goml",
-//                     "testButton2.crow",
-                       "test2WayBinding.crow",
-                       "test4.goml",
-                       "2.crow",
-                       "test1.goml",
-                       "testWindow2.goml",
-
-                       "testWindow3.goml",
-                       "testLabel.goml",
-                       "testAll.goml",
-//                     "testSpinner.goml",
-//                     "testRadioButton2.goml",
-                       "testContainer.goml",
-                       "testRadioButton.goml",
-
-//                     "testMeter.goml",
-               };
-
-               #region FPS
-               int _fps = 0;
-
-               public int fps {
-                       get { return _fps; }
-                       set {
-                               if (_fps == value)
-                                       return;
-
-                               _fps = value;
-
-                               if (_fps > fpsMax) {
-                                       fpsMax = _fps;
-                                       ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMax", fpsMax));
-                               } else if (_fps < fpsMin) {
-                                       fpsMin = _fps;
-                                       ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMin", fpsMin));
-                               }
-
-                               ValueChanged.Raise(this, new ValueChangeEventArgs ("fps", _fps));
-                               #if MEASURE_TIME
-                               ValueChanged.Raise (this, new ValueChangeEventArgs ("update",
-                                       this.CrowInterface.updateTime.ElapsedTicks.ToString () + " ticks"));
-                               ValueChanged.Raise (this, new ValueChangeEventArgs ("layouting",
-                                       this.CrowInterface.layoutTime.ElapsedTicks.ToString () + " ticks"));
-                               ValueChanged.Raise (this, new ValueChangeEventArgs ("drawing",
-                                       this.CrowInterface.drawingTime.ElapsedTicks.ToString () + " ticks"));
-                               #endif
-                       }
-               }
-
-               public int fpsMin = int.MaxValue;
-               public int fpsMax = 0;
-
-               void resetFps ()
-               {
-                       fpsMin = int.MaxValue;
-                       fpsMax = 0;
-                       _fps = 0;
-               }
-               public string update = "";
-               public string drawing = "";
-               public string layouting = "";
-               public Alignment alignment = Alignment.Left;
-               #endregion
-
-               public int intValue = 25;
-
-               public int IntValue {
-                       get {
-                               return intValue;
-                       }
-                       set {
-                               intValue = value;
-                               NotifyValueChanged ("IntValue", intValue);
-                       }
-               }
-               void onSpinnerValueChange(object sender, ValueChangeEventArgs e){
-                       if (e.MemberName != "Value")
-                               return;
-                       intValue = Convert.ToInt32(e.NewValue);
-               }
-               void change_alignment(object sender, EventArgs e){
-                       RadioButton rb = sender as RadioButton;
-                       if (rb == null)
-                               return;
-                       NotifyValueChanged ("alignment", Enum.Parse(typeof(Alignment), rb.Caption));
-               }
-               public IList<String> List2 = new List<string>(new string[]
-                       {
-                               "string1",
-                               "string2",
-                               "string3",
-                               "string4",
-                               "string5",
-                               "string6",
-                               "string7",
-                               "string8",
-                               "string8",
-                               "string8",
-                               "string8",
-                               "string8",
-                               "string8",
-                               "string9"
-                       }
-               );
-               IList<Color> testList = Color.ColorDic.ToList();
-               public IList<Color> TestList {
-                       set{
-                               testList = value;
-                               NotifyValueChanged ("TestList", testList);
-                       }
-                       get { return testList; }
-               }
-               void OnClear (object sender, MouseButtonEventArgs e) => TestList = null;
-
-               void OnLoadList (object sender, MouseButtonEventArgs e) {
-                       TestList = Color.ColorDic.ToList();
-               }
-
-               void GOLIBTests_KeyboardKeyDown1 (object sender, OpenTK.Input.KeyboardKeyEventArgs e)
-               {
-                       if (e.Key == OpenTK.Input.Key.Escape) {
-                               Quit (null, null);
-                               return;
-                       } else if (e.Key == OpenTK.Input.Key.L) {
-                               TestList.Add ("new string");
-                               NotifyValueChanged ("TestList", TestList);
-                               return;
-                       } else if (e.Key == OpenTK.Input.Key.W) {
-                               GraphicObject w = CrowInterface.LoadInterface("Interfaces/testWindow.goml");
-                               w.DataSource = this;
-                               return;
-                       }
-                       CrowInterface.ClearInterface ();
-                       idx++;
-                       if (idx == testFiles.Length)
-                               idx = 0;
-                       this.Title = testFiles [idx];
-                       GraphicObject obj = CrowInterface.LoadInterface("Interfaces/" + testFiles[idx]);
-                       obj.DataSource = this;
-               }
-
-//             protected override void OnUpdateFrame (FrameEventArgs e)
-//             {
-//                     //if (frameCpt % 8 == 0)
-//                             base.OnUpdateFrame (e);
-//
-//                     fps = (int)RenderFrequency;
-//
-//
-//                     if (frameCpt > 50) {
-//                             resetFps ();
-//                             frameCpt = 0;
-//                             GC.Collect();
-//                             GC.WaitForPendingFinalizers();
-//                             NotifyValueChanged("memory", GC.GetTotalMemory (false).ToString());
-//                     }
-//                     frameCpt++;
-//             }
-               void onButClick(object send, MouseButtonEventArgs e)
-               {
-                       Console.WriteLine ("button clicked:" + send.ToString());
-               }
-               void onAddTabButClick(object sender, MouseButtonEventArgs e){
-                       
-                       TabView tv = CrowInterface.FindByName("tabview1") as TabView;
-                       if (tv == null)
-                               return;
-                       tv.AddChild (new TabItem () { Caption = "NewTab" });
-               }
-               [STAThread]
-               static void Main ()
-               {
-                       Console.WriteLine ("starting example");
-                       Gtk.Application.Init ();
-                       GOLIBTests win = new GOLIBTests ();
-                       win.KeyPressEvent += win.Win_KeyPressEvent;
-
-                       Gtk.Application.Run ();
-               }
-               void onMsgBoxOk(object sender, EventArgs e){
-                       Debug.WriteLine ("OK");
-               }
-               void onMsgBoxCancel(object sender, EventArgs e)
-               {
-                       Debug.WriteLine ("cancel");
-               }
-               void Win_KeyPressEvent (object o, Gtk.KeyPressEventArgs args)
-               {
-                       CrowInterface.ClearInterface ();
-                       idx++;
-                       if (idx == testFiles.Length)
-                               idx = 0;
-                       this.Title = testFiles [idx];
-                       GraphicObject obj = CrowInterface.LoadInterface("Interfaces/" + testFiles[idx]);
-                       obj.DataSource = this;                  
-               }
-       }
-}
diff --git a/Tests/OpenGL/Shader.cs b/Tests/OpenGL/Shader.cs
new file mode 100644 (file)
index 0000000..54f9140
--- /dev/null
@@ -0,0 +1,317 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Reflection;
+using OpenTK;
+using OpenTK.Graphics.OpenGL;
+using System.Collections.Generic;
+
+namespace Tetra
+{
+       public class Shader : IDisposable
+       {
+               #region CTOR
+               public Shader ()
+               {
+                       Init ();
+               }
+               public Shader (string vertResPath, string fragResPath = null, string geomResPath = null)
+               {
+                       VertSourcePath = vertResPath;
+                       FragSourcePath = fragResPath;
+                       GeomSourcePath = geomResPath;
+
+                       loadSourcesFiles ();
+
+                       Init ();
+               }
+               #endregion
+
+               public string   VertSourcePath,
+                                               FragSourcePath,
+                                               GeomSourcePath;
+               #region Sources
+               protected string _vertSource = @"
+                       #version 330
+                       precision lowp float;
+
+                       uniform mat4 mvp;
+
+                       layout(location = 0) in vec3 in_position;
+                       layout(location = 1) in vec2 in_tex;
+
+                       out vec2 texCoord;
+
+                       void main(void)
+                       {
+                               texCoord = in_tex;
+                               gl_Position = mvp * vec4(in_position, 1.0);
+                       }";
+
+               protected string _fragSource = @"
+                       #version 330
+                       precision lowp float;
+
+                       uniform sampler2D tex;
+
+                       in vec2 texCoord;
+                       out vec4 out_frag_color;
+
+                       void main(void)
+                       {
+                               out_frag_color = texture( tex, texCoord);
+                       }";
+               string _geomSource = @"";
+//                     #version 330
+//                     layout(triangles) in;
+//                     layout(triangle_strip, max_vertices=3) out;
+//                     void main()
+//                     {
+//                             for(int i=0; i<3; i++)
+//                             {
+//                                     gl_Position = gl_in[i].gl_Position;
+//                                     EmitVertex();
+//                             }
+//                             EndPrimitive();
+//                     }";
+               #endregion
+
+               #region Private and protected fields
+               public int vsId, fsId, gsId, pgmId, mvpLocation;
+
+               Matrix4 mvp = Matrix4.Identity;
+               #endregion
+
+
+               #region Public properties
+               public virtual string vertSource
+               {
+                       get { return _vertSource;}
+                       set { _vertSource = value; }
+               }
+               public virtual string fragSource
+               {
+                       get { return _fragSource;}
+                       set { _fragSource = value; }
+               }
+               public virtual string geomSource
+               {
+                       get { return _geomSource; }
+                       set { _geomSource = value; }
+               }
+
+               public virtual Matrix4 MVP{
+                       set { mvp = value; }
+                       get { return mvp; }
+               }
+               #endregion
+
+               #region Public functions
+               /// <summary>
+               /// configure sources and compile
+               /// </summary>
+               public virtual void Init()
+               {
+                       Compile ();
+               }
+               public void Reload(){
+                       loadSourcesFiles ();
+                       Compile ();
+               }
+               public void SetSource(ShaderType shaderType, string _source){
+                       switch (shaderType) {
+                       case ShaderType.FragmentShader:
+                               fragSource = _source;
+                               return;
+                       case ShaderType.VertexShader:
+                               vertSource = _source;
+                               return;
+                       case ShaderType.GeometryShader:
+                               geomSource = _source;
+                               return;
+                       }
+               }
+               public string GetSource(ShaderType shaderType){
+                       switch (shaderType) {
+                       case ShaderType.FragmentShader:
+                               return fragSource;
+                       case ShaderType.VertexShader:
+                               return vertSource;
+                       case ShaderType.GeometryShader:
+                               return geomSource;
+                       }
+                       return "";
+               }
+               public string GetSourcePath(ShaderType shaderType){
+                       switch (shaderType) {
+                       case ShaderType.FragmentShader:
+                               return FragSourcePath;
+                       case ShaderType.VertexShader:
+                               return VertSourcePath;
+                       case ShaderType.GeometryShader:
+                               return GeomSourcePath;
+                       }
+                       return "";
+               }
+               public virtual void Compile()
+               {
+                       Dispose ();
+
+                       pgmId = GL.CreateProgram();
+
+                       if (!string.IsNullOrEmpty(vertSource))
+                       {
+                               vsId = GL.CreateShader(ShaderType.VertexShader);
+                               compileShader(vsId, vertSource);
+                       }
+                       if (!string.IsNullOrEmpty(fragSource))
+                       {
+                               fsId = GL.CreateShader(ShaderType.FragmentShader);
+                               compileShader(fsId, fragSource);
+
+                       }
+                       if (!string.IsNullOrEmpty(geomSource))
+                       {
+                               gsId = GL.CreateShader(ShaderType.GeometryShader);
+                               compileShader(gsId,geomSource);
+                       }
+
+                       if (vsId != 0)
+                               GL.AttachShader(pgmId, vsId);
+                       if (fsId != 0)
+                               GL.AttachShader(pgmId, fsId);
+                       if (gsId != 0)
+                               GL.AttachShader(pgmId, gsId);
+
+                       BindVertexAttributes ();
+
+                       string info;
+                       GL.LinkProgram(pgmId);
+                       GL.GetProgramInfoLog(pgmId, out info);
+
+                       if (!string.IsNullOrEmpty (info)) {
+                               Debug.WriteLine ("Linkage:");
+                               Debug.WriteLine (info);
+                       }
+
+                       info = null;
+
+                       GL.ValidateProgram(pgmId);
+                       GL.GetProgramInfoLog(pgmId, out info);
+                       if (!string.IsNullOrEmpty (info)) {
+                               Debug.WriteLine ("Validation:");
+                               Debug.WriteLine (info);
+                       }
+
+                       GL.UseProgram (pgmId);
+
+                       GetUniformLocations ();
+                       BindSamplesSlots ();
+
+                       Disable ();
+               }
+
+               protected virtual void BindVertexAttributes()
+               {
+                       GL.BindAttribLocation(pgmId, 0, "in_position");
+                       GL.BindAttribLocation(pgmId, 1, "in_tex");
+               }
+               protected virtual void GetUniformLocations()
+               {
+                       mvpLocation = GL.GetUniformLocation(pgmId, "mvp");
+               }
+               protected virtual void BindSamplesSlots(){
+                       GL.Uniform1(GL.GetUniformLocation (pgmId, "tex"), 0);
+               }
+               public void SetMVP(Matrix4 _mvp){
+                       GL.UniformMatrix4(mvpLocation, false, ref _mvp);
+               }
+               public virtual void Enable(){
+                       GL.UseProgram (pgmId);
+               }
+               public virtual void Disable(){
+                       GL.UseProgram (0);
+               }
+               public static void Enable(Shader s)
+               {
+                       if (s == null)
+                               return;
+                       s.Enable ();
+               }
+               public static void Disable(Shader s)
+               {
+                       if (s == null)
+                               return;
+                       s.Disable ();
+               }
+               #endregion
+
+               void loadSourcesFiles(){
+                       Stream s;
+
+                       if (!string.IsNullOrEmpty (VertSourcePath)) {
+                               s = Crow.Interface.GetStreamFromPath (VertSourcePath);
+                               if (s != null) {
+                                       using (StreamReader sr = new StreamReader (s)) {
+                                               vertSource = sr.ReadToEnd ();
+                                       }
+                               }
+                       }
+
+                       if (!string.IsNullOrEmpty (FragSourcePath)) {
+                               s = Crow.Interface.GetStreamFromPath (FragSourcePath);
+                               if (s != null) {
+                                       using (StreamReader sr = new StreamReader (s)) {
+                                               fragSource = sr.ReadToEnd ();
+                                       }
+                               }
+                       }
+
+                       if (!string.IsNullOrEmpty (GeomSourcePath)) {
+                               s = Crow.Interface.GetStreamFromPath (GeomSourcePath);
+                               if (s != null) {
+                                       using (StreamReader sr = new StreamReader (s)) {
+                                               geomSource = sr.ReadToEnd ();
+                                       }
+                               }
+                       }                       
+               }
+               void compileShader(int shader, string source)
+               {
+                       GL.ShaderSource(shader, source);
+                       GL.CompileShader(shader);
+
+                       string info;
+                       GL.GetShaderInfoLog(shader, out info);
+                       Debug.WriteLine(info);
+
+                       int compileResult;
+                       GL.GetShader(shader, ShaderParameter.CompileStatus, out compileResult);
+                       if (compileResult != 1)
+                       {
+                               Debug.WriteLine("Compile Error!");
+                               Debug.WriteLine(source);
+                       }
+               }
+               public override string ToString ()
+               {
+                       return string.Format ("{0} {1} {2}", VertSourcePath, FragSourcePath, GeomSourcePath);
+               }
+
+               #region IDisposable implementation
+               public virtual void Dispose ()
+               {                       
+                       if (GL.IsProgram (pgmId))
+                               GL.DeleteProgram (pgmId);
+
+                       if (GL.IsShader (vsId))
+                               GL.DeleteShader (vsId);
+                       if (GL.IsShader (fsId))
+                               GL.DeleteShader (fsId);
+                       if (GL.IsShader (gsId))
+                               GL.DeleteShader (gsId);
+               }
+               #endregion
+       }
+}
+
diff --git a/Tests/OpenGL/vaoMesh.cs b/Tests/OpenGL/vaoMesh.cs
new file mode 100644 (file)
index 0000000..b076362
--- /dev/null
@@ -0,0 +1,145 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+using OpenTK;
+using OpenTK.Graphics.OpenGL;
+//using System.Drawing;
+using System.Drawing.Imaging;
+using System.IO;
+using System.Threading;
+using System.Diagnostics;
+using System.Linq;
+
+namespace Crow
+{
+       public class vaoMesh : IDisposable
+       {
+               public int vaoHandle,
+               positionVboHandle,
+               texVboHandle,
+               eboHandle;
+
+               public Vector3[] positions;
+               public Vector2[] texCoords;
+               public int[] indices;
+
+               public vaoMesh()
+               {
+               }
+
+               public vaoMesh (Vector3[] _positions, Vector2[] _texCoord, int[] _indices)
+               {
+                       positions = _positions;
+                       texCoords = _texCoord;
+                       indices = _indices;
+
+                       CreateVBOs ();
+                       CreateVAOs ();
+               }
+
+               public vaoMesh (float x, float y, float z, float width, float height, float TileX = 1f, float TileY = 1f)
+               {
+                       positions =
+                               new Vector3[] {
+                               new Vector3 (x - width / 2, y + height / 2, z),
+                               new Vector3 (x - width / 2, y - height / 2, z),
+                               new Vector3 (x + width / 2, y + height / 2, z),
+                               new Vector3 (x + width / 2, y - height / 2, z)
+                       };
+                       texCoords =     new Vector2[] {
+                               new Vector2 (0, TileY),
+                               new Vector2 (0, 0),
+                               new Vector2 (TileX, TileY),
+                               new Vector2 (TileX, 0)
+                       };
+                       indices = new int[] { 0, 1, 2, 3 };
+
+                       CreateVBOs ();
+                       CreateVAOs ();
+               }
+               public void CreateBuffers(){
+                       CreateVBOs ();
+                       CreateVAOs ();
+               }
+               protected void CreateVBOs()
+               {
+                       positionVboHandle = GL.GenBuffer();
+                       GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
+                       GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
+                               new IntPtr(positions.Length * Vector3.SizeInBytes),
+                               positions, BufferUsageHint.StaticDraw);
+
+                       if (texCoords != null) {
+                               texVboHandle = GL.GenBuffer ();
+                               GL.BindBuffer (BufferTarget.ArrayBuffer, texVboHandle);
+                               GL.BufferData<Vector2> (BufferTarget.ArrayBuffer,
+                                       new IntPtr (texCoords.Length * Vector2.SizeInBytes),
+                                       texCoords, BufferUsageHint.StaticDraw);
+                       }
+
+                       GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
+
+                       if (indices != null) {
+                               eboHandle = GL.GenBuffer ();
+                               GL.BindBuffer (BufferTarget.ElementArrayBuffer, eboHandle);
+                               GL.BufferData (BufferTarget.ElementArrayBuffer,
+                                       new IntPtr (sizeof(uint) * indices.Length),
+                                       indices, BufferUsageHint.StaticDraw);
+                               GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
+                       }
+               }
+               protected void CreateVAOs()
+               {
+                       vaoHandle = GL.GenVertexArray();
+                       GL.BindVertexArray(vaoHandle);
+
+                       GL.EnableVertexAttribArray(0);
+                       GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
+                       GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, true, Vector3.SizeInBytes, 0);
+
+                       if (texCoords != null) {
+                               GL.EnableVertexAttribArray (1);
+                               GL.BindBuffer (BufferTarget.ArrayBuffer, texVboHandle);
+                               GL.VertexAttribPointer (1, 2, VertexAttribPointerType.Float, true, Vector2.SizeInBytes, 0);
+                       }
+                       if (indices != null)
+                               GL.BindBuffer(BufferTarget.ElementArrayBuffer, eboHandle);
+
+                       GL.BindVertexArray(0);
+               }
+
+               public void Render(BeginMode _primitiveType){
+                       GL.BindVertexArray(vaoHandle);
+                       if (indices == null)
+                               GL.DrawArrays (_primitiveType, 0, positions.Length);
+                       else
+                               GL.DrawElements(_primitiveType, indices.Length,
+                                       DrawElementsType.UnsignedInt, IntPtr.Zero);
+                       GL.BindVertexArray (0);
+               }
+               public void Render(BeginMode _primitiveType, int[] _customIndices){
+                       GL.BindVertexArray(vaoHandle);
+                       GL.DrawElements(_primitiveType, _customIndices.Length,
+                               DrawElementsType.UnsignedInt, _customIndices);
+                       GL.BindVertexArray (0);
+               }
+               public void Render(BeginMode _primitiveType, int instances){
+
+                       GL.BindVertexArray(vaoHandle);
+                       GL.DrawElementsInstanced(_primitiveType, indices.Length,
+                               DrawElementsType.UnsignedInt, IntPtr.Zero, instances);
+                       GL.BindVertexArray (0);
+               }
+
+               #region IDisposable implementation
+               public void Dispose ()
+               {
+                       GL.DeleteBuffer (positionVboHandle);
+                       GL.DeleteBuffer (texVboHandle);
+                       GL.DeleteBuffer (eboHandle);
+                       GL.DeleteVertexArray (vaoHandle);
+               }
+               #endregion
+
+       }
+}
\ No newline at end of file
diff --git a/Tests/OpenTK.dll.config b/Tests/OpenTK.dll.config
deleted file mode 100644 (file)
index 23689f6..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<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="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"/>
-</configuration>
diff --git a/Tests/OpenTKGameWindow.cs b/Tests/OpenTKGameWindow.cs
new file mode 100644 (file)
index 0000000..1dcd606
--- /dev/null
@@ -0,0 +1,331 @@
+//
+//  OpenTKGameWindow.cs
+//
+//  Author:
+//       Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+//  Copyright (c) 2016 jp
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Threading;
+using System.Xml;
+using Cairo;
+using OpenTK;
+using OpenTK.Graphics.OpenGL;
+
+namespace Crow
+{
+       public class OpenTKGameWindow : GameWindow, IValueChange
+    {
+               #region IValueChange implementation
+               public event EventHandler<ValueChangeEventArgs> ValueChanged;
+               public virtual void NotifyValueChanged(string MemberName, object _value)
+               {
+                       if (ValueChanged != null)                               
+                               ValueChanged.Invoke(this, new ValueChangeEventArgs(MemberName, _value));
+               }
+               #endregion
+
+               public Interface CrowInterface;
+
+               #region FPS
+               int frameCpt = 0;
+               int _fps = 0;
+
+               public int fps {
+                       get { return _fps; }
+                       set {
+                               if (_fps == value)
+                                       return;
+
+                               _fps = value;
+
+                               if (_fps > fpsMax) {
+                                       fpsMax = _fps;
+                                       ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMax", fpsMax));
+                               } else if (_fps < fpsMin) {
+                                       fpsMin = _fps;
+                                       ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMin", fpsMin));
+                               }
+
+                               ValueChanged.Raise(this, new ValueChangeEventArgs ("fps", _fps));
+                               #if MEASURE_TIME
+                               ValueChanged.Raise (this, new ValueChangeEventArgs ("update",
+                                       this.CrowInterface.clippingTime.ElapsedTicks.ToString () + " ticks"));
+                               ValueChanged.Raise (this, new ValueChangeEventArgs ("layouting",
+                                       this.CrowInterface.layoutTime.ElapsedTicks.ToString () + " ticks"));
+                               ValueChanged.Raise (this, new ValueChangeEventArgs ("drawing",
+                                       this.CrowInterface.drawingTime.ElapsedTicks.ToString () + " ticks"));
+                               #endif
+                       }
+               }
+
+               public int fpsMin = int.MaxValue;
+               public int fpsMax = 0;
+
+               void resetFps ()
+               {
+                       fpsMin = int.MaxValue;
+                       fpsMax = 0;
+                       _fps = 0;
+               }
+               public string update = "";
+               public string drawing = "";
+               public string layouting = "";
+               #endregion
+
+               #region ctor
+               public OpenTKGameWindow(int _width = 800, int _height = 600, string _title="Crow",
+                       int colors = 32, int depth = 24, int stencil = 0, int samples = 1,
+                       int major=3, int minor=3)
+                       : this(_width, _height, new OpenTK.Graphics.GraphicsMode(colors, depth, stencil, samples),
+                               _title,GameWindowFlags.Default,DisplayDevice.Default,
+                               major,minor,OpenTK.Graphics.GraphicsContextFlags.Default)
+               {
+               }
+               public OpenTKGameWindow (int width, int height, OpenTK.Graphics.GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device, int major, int minor, OpenTK.Graphics.GraphicsContextFlags flags)
+                       : base(width,height,mode,title,options,device,major,minor,flags)
+               {
+                       CrowInterface = new Interface ();
+
+                       Thread t = new Thread (interfaceThread);
+                       t.IsBackground = true;
+                       t.Start ();
+               }
+
+               #endregion
+
+               void interfaceThread()
+               {
+                       CrowInterface.Quit += Quit;
+                       CrowInterface.MouseCursorChanged += CrowInterface_MouseCursorChanged;
+                       while (CrowInterface.ClientRectangle.Size.Width == 0)
+                               Thread.Sleep (5);
+                       
+                       while (true) {
+                               CrowInterface.Update ();
+                               Thread.Sleep (1);
+                       }
+               }
+
+               public void Quit (object sender, EventArgs e)
+               {
+                       this.Exit ();
+               }
+               void CrowInterface_MouseCursorChanged (object sender, MouseCursorChangedEventArgs e)
+               {
+                       this.Cursor = new MouseCursor(
+                               (int)e.NewCursor.Xhot,
+                               (int)e.NewCursor.Yhot,
+                               (int)e.NewCursor.Width,
+                               (int)e.NewCursor.Height,
+                               e.NewCursor.data);
+               }
+
+               #region Events
+               //those events are raised only if mouse isn't in a graphic object
+               public event EventHandler<OpenTK.Input.MouseWheelEventArgs> MouseWheelChanged;
+               public event EventHandler<OpenTK.Input.MouseButtonEventArgs> MouseButtonUp;
+               public event EventHandler<OpenTK.Input.MouseButtonEventArgs> MouseButtonDown;
+               public event EventHandler<OpenTK.Input.MouseButtonEventArgs> MouseClick;
+               public event EventHandler<OpenTK.Input.MouseMoveEventArgs> MouseMove;
+               public event EventHandler<OpenTK.Input.KeyboardKeyEventArgs> KeyboardKeyDown;
+               public event EventHandler<OpenTK.Input.KeyboardKeyEventArgs> KeyboardKeyUp;
+
+               #endregion
+
+               #region graphic context
+               int texID;
+               Tetra.Shader shader;
+               public static Crow.vaoMesh quad;
+
+               void createContext()
+               {
+                       #region Create texture
+                       if (GL.IsTexture(texID))
+                               GL.DeleteTexture (texID);
+                       GL.GenTextures(1, out texID);
+                       GL.ActiveTexture (TextureUnit.Texture0);
+                       GL.BindTexture(TextureTarget.Texture2D, texID);
+
+                       GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba,
+                               ClientRectangle.Width, ClientRectangle.Height, 0,
+                               OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, CrowInterface.bmp);
+
+                       GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
+                       GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
+
+                       GL.BindTexture(TextureTarget.Texture2D, 0);
+                       #endregion
+               }
+               void OpenGLDraw()
+               {
+                       bool blend, depthTest;
+                       GL.GetBoolean (GetPName.Blend, out blend);
+                       GL.GetBoolean (GetPName.DepthTest, out depthTest);
+                       GL.Enable (EnableCap.Blend);
+                       GL.Disable (EnableCap.DepthTest);
+
+                       shader.Enable ();
+                       GL.ActiveTexture (TextureUnit.Texture0);
+                       GL.BindTexture (TextureTarget.Texture2D, texID);
+                       lock (CrowInterface.RenderMutex) {
+                               if (CrowInterface.IsDirty) {
+                                       GL.TexSubImage2D (TextureTarget.Texture2D, 0,
+                                               CrowInterface.DirtyRect.Left, CrowInterface.DirtyRect.Top,
+                                               CrowInterface.DirtyRect.Width, CrowInterface.DirtyRect.Height,
+                                               OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, CrowInterface.dirtyBmp);
+                                       CrowInterface.IsDirty = false;
+                               }
+                       }
+                       quad.Render (BeginMode.TriangleStrip);
+                       GL.BindTexture(TextureTarget.Texture2D, 0);
+                       shader.Disable ();
+                       if (!blend)
+                               GL.Disable (EnableCap.Blend);
+                       if (depthTest)
+                               GL.Enable (EnableCap.DepthTest);
+               }
+               #endregion
+
+               public virtual void OnRender(FrameEventArgs e)
+               {
+               }
+               public virtual void GLClear()
+               {
+                       GL.Clear (ClearBufferMask.ColorBufferBit);
+               }
+
+               #region Game win overrides
+               protected override void OnLoad(EventArgs e)
+               {
+                       base.OnLoad(e);
+
+                       this.KeyPress += new EventHandler<OpenTK.KeyPressEventArgs>(OpenTKGameWindow_KeyPress);
+                       Keyboard.KeyDown += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyDown);
+                       Keyboard.KeyUp += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyUp);
+                       Mouse.WheelChanged += new EventHandler<OpenTK.Input.MouseWheelEventArgs>(Mouse_WheelChanged);
+                       Mouse.ButtonDown += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(Mouse_ButtonDown);
+                       Mouse.ButtonUp += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(Mouse_ButtonUp);
+                       Mouse.Move += new EventHandler<OpenTK.Input.MouseMoveEventArgs>(Mouse_Move);
+
+                       GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+                       Console.WriteLine("\n\n*************************************");
+                       Console.WriteLine("GL version: " + GL.GetString (StringName.Version));
+                       Console.WriteLine("GL vendor: " + GL.GetString (StringName.Vendor));
+                       Console.WriteLine("GLSL version: " + GL.GetString (StringName.ShadingLanguageVersion));
+                       Console.WriteLine("*************************************\n");
+
+                       shader = new Tetra.Shader ();
+                       shader.Enable();
+                       shader.SetMVP(OpenTK.Matrix4.CreateOrthographicOffCenter (-0.5f, 0.5f, -0.5f, 0.5f, 1, -1));
+                       GL.UseProgram(0);
+                       quad = new Crow.vaoMesh (0, 0, 0, 1, 1, 1, -1);
+               }
+
+               protected override void OnUpdateFrame(FrameEventArgs e)
+               {
+                       base.OnUpdateFrame(e);
+                       fps = (int)RenderFrequency;
+
+
+                       if (frameCpt > 50) {
+                               resetFps ();
+                               frameCpt = 0;
+                               GC.Collect();
+                               GC.WaitForPendingFinalizers();
+                               NotifyValueChanged("memory", GC.GetTotalMemory (false).ToString());
+                       }
+                       frameCpt++;
+                       //CrowInterface.Update ();
+               }
+               protected override void OnRenderFrame(FrameEventArgs e)
+               {
+                       GLClear ();
+
+                       base.OnRenderFrame(e);
+
+                       OnRender (e);
+                       OpenGLDraw ();
+
+                       SwapBuffers ();
+               }
+
+               protected override void OnResize(EventArgs e)
+               {
+                       base.OnResize (e);
+                       CrowInterface.ProcessResize(
+                               new Rectangle(
+                               0,
+                               0,
+                               this.ClientRectangle.Width,
+                               this.ClientRectangle.Height));
+                       createContext ();
+                       GL.Viewport (0, 0, ClientRectangle.Width, ClientRectangle.Height);
+               }
+               #endregion
+
+               #region Mouse Handling
+               void update_mouseButtonStates(ref MouseState e, OpenTK.Input.MouseState otk_e){
+                       for (int i = 0; i < MouseState.MaxButtons; i++) {
+                               if (otk_e.IsButtonDown ((OpenTK.Input.MouseButton)i))
+                                       e.EnableBit (i);
+                       }
+               }
+               void Mouse_Move(object sender, OpenTK.Input.MouseMoveEventArgs otk_e)
+        {
+                       if (!CrowInterface.ProcessMouseMove (otk_e.X, otk_e.Y))
+                               MouseMove.Raise (sender, otk_e);
+        }
+               void Mouse_ButtonUp(object sender, OpenTK.Input.MouseButtonEventArgs otk_e)
+        {
+                       if (!CrowInterface.ProcessMouseButtonUp ((int)otk_e.Button))
+                               MouseButtonUp.Raise (sender, otk_e);
+        }
+               void Mouse_ButtonDown(object sender, OpenTK.Input.MouseButtonEventArgs otk_e)
+               {
+                       if (!CrowInterface.ProcessMouseButtonDown ((int)otk_e.Button))
+                               MouseButtonDown.Raise (sender, otk_e);
+        }
+               void Mouse_WheelChanged(object sender, OpenTK.Input.MouseWheelEventArgs otk_e)
+        {
+                       if (!CrowInterface.ProcessMouseWheelChanged (otk_e.DeltaPrecise))
+                               MouseWheelChanged.Raise (sender, otk_e);
+        }
+               #endregion
+
+               #region keyboard Handling
+               void Keyboard_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs otk_e)
+               {
+                       //if (!CrowInterface.ProcessKeyDown((int)otk_e.Key))
+                               KeyboardKeyDown.Raise (this, otk_e);
+        }
+               void Keyboard_KeyUp(object sender, OpenTK.Input.KeyboardKeyEventArgs otk_e)
+               {
+                       //if (!CrowInterface.ProcessKeyUp((int)otk_e.Key))
+                               KeyboardKeyUp.Raise (this, otk_e);
+               }
+               void OpenTKGameWindow_KeyPress (object sender, OpenTK.KeyPressEventArgs e)
+               {
+                       CrowInterface.ProcessKeyPress (e.KeyChar);
+               }
+        #endregion
+    }
+}
index fe7570b35409c2a1c3e4936b8161119b3dbcefa9..ff4e3c785d9bb185a684e71cd718daf4626e6609 100644 (file)
@@ -48,6 +48,9 @@
     <Compile Include="Interfaces\testBorder.goml.cs" />
     <Compile Include="GOLIBTestsOTK.cs" />
     <Compile Include="OTKCrow.cs" />
+    <Compile Include="OpenGL\Shader.cs" />
+    <Compile Include="OpenGL\vaoMesh.cs" />
+    <Compile Include="OpenTKGameWindow.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="image\u.svg">
@@ -68,7 +71,6 @@
     <None Include="Interfaces\tmpDirItem.goml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
-    <None Include="GOLIBTests.cs" />
     <None Include="Interfaces\basicTests\0.crow">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
     <None Include="Interfaces\Splitter\1.crow">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
-    <None Include="OpenTK.dll.config" />
-    <None Include="GLCrow.cs" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Interfaces\" />
       <Project>{C2980F9B-4798-4C05-99E2-E174810F7C7B}</Project>
       <Name>Crow</Name>
     </ProjectReference>
-    <ProjectReference Include="..\OTKCrow\OTKCrow.csproj">
-      <Project>{350D4F49-9901-4998-9903-BCA7D48DA58C}</Project>
-      <Name>OTKCrow</Name>
-    </ProjectReference>
   </ItemGroup>
 </Project>
index 05acf5266be4fd2f148af7379c7c420853e48e2d..a36019e3328def0bd9afd1f9f1fe7cfa8ef12634 100644 (file)
@@ -62,7 +62,7 @@ namespace Crow
                                NotifyValueChanged ("Title", _title);
                        }
                }
-               [XmlAttributeAttribute()][DefaultValue("#Crow.Images.Icons.tetra.png")]
+               [XmlAttributeAttribute()][DefaultValue("#Crow.Images.Icons.crow.png")]
                public string Icon {
                        get { return _icon; } 
                        set {