Commits

Tobias Bohnen committed 1dfd045

  • Participants
  • Parent commits 503bbdc

Comments (0)

Files changed (12)

 
         protected override void Dispose(bool disposing)
         {
-            if (this.Handle != IntPtr.Zero)
+            if (this.OwnsHandle && this.Handle != IntPtr.Zero)
             {
                 CgNativeMethods.cgDestroyBuffer(this.Handle);
             }
     /// </summary>
     public static class Cg
     {
+        #region Constructors
+
+        static Cg()
+        {
+            DefaultOrder = Order.RowMajor;
+        }
+
+        #endregion Constructors
+
         #region Delegates
 
         /// <summary>
 
         #region Public Static Properties
 
+        public static Order DefaultOrder
+        {
+            get;
+            set;
+        }
+
         public static CgErrorCallbackFuncDelegate ErrorCallback
         {
             get
         #endregion Properties
 
         #region Methods
-        static Cg()
-        {
-            DefaultOrder = Order.RowMajor;
-        }
 
         #region Public Static Methods
 
-        public static Order DefaultOrder
-        {
-            get;
-            set;
-        }
-
         public static Behavior GetBehavior(string behaviorString)
         {
             return CgNativeMethods.cgGetBehavior(behaviorString);
         ProgramProfile = 4107, /* GetProgramString                       */
     }
 
+    public enum Variabilty
+    {
+        Varying = 4101,
+        Uniform = 4102,
+        Literal = 4118,
+        Constant = 4103,
+        Mixed = 4100,
+    }
+
     #endregion Enumerations
 }

CgNet/CgNativeMethods.cs

         // CGDLL_API CGenum cgGetParameterVariability(CGparameter param);
         [DllImport(CgNativeLibrary, CallingConvention = Convention)]
         [SuppressUnmanagedCodeSecurity]
-        internal static extern int cgGetParameterVariability(IntPtr param);
+        internal static extern Variabilty cgGetParameterVariability(IntPtr param);
 
         /// <summary>
         /// 
         // CGDLL_API void cgSetParameterVariability(CGparameter param, CGenum vary);
         [DllImport(CgNativeLibrary, CallingConvention = Convention)]
         [SuppressUnmanagedCodeSecurity]
-        internal static extern void cgSetParameterVariability(IntPtr param, int vary);
+        internal static extern void cgSetParameterVariability(IntPtr param, Variabilty vary);
 
         /// <summary>
         /// 
             get
             {
                 var ptr = CgNativeMethods.cgGetFirstProgram(this.Handle);
-
                 return ptr == IntPtr.Zero ? null : new Program(ptr)
                                                    {
                                                        OwnsHandle = false
 
         protected override void Dispose(bool disposing)
         {
-            if (this.Handle != IntPtr.Zero)
+            if (this.OwnsHandle && this.Handle != IntPtr.Zero && this.IsContext)
             {
                 CgNativeMethods.cgDestroyContext(this.Handle);
             }
 
         protected override void Dispose(bool disposing)
         {
-            if (this.Handle != IntPtr.Zero)
+            if (this.OwnsHandle && this.Handle != IntPtr.Zero && this.IsEffect)
             {
                 CgNativeMethods.cgDestroyEffect(this.Handle);
             }
 
         protected override void Dispose(bool disposing)
         {
-            if (this.Handle != IntPtr.Zero)
+            if (this.OwnsHandle && this.Handle != IntPtr.Zero)
             {
                 CgNativeMethods.cgDestroyObj(this.Handle);
             }

CgNet/Parameter.cs

             }
         }
 
-        public ResourceType BaseResourceType
+        public ResourceType BaseResource
         {
             get
             {
             }
         }
 
-        public int Variability
+        public Variabilty Variability
         {
             get
             {
 
         protected override void Dispose(bool disposing)
         {
-            if (this.Handle != IntPtr.Zero)
+            if (this.OwnsHandle && this.Handle != IntPtr.Zero && this.IsParameter)
             {
                 CgNativeMethods.cgDestroyParameter(this.Handle);
             }
         /// <filterpriority>2</filterpriority>
         protected override void Dispose(bool disposing)
         {
-            if (this.Handle != IntPtr.Zero)
+            if (this.OwnsHandle && this.Handle != IntPtr.Zero && this.IsProgram)
             {
                 CgNativeMethods.cgDestroyProgram(this.Handle);
             }

CgNet/WrapperObject.cs

         /// </summary>
         ~WrapperObject()
         {
-            if (this.OwnsHandle)
-            {
-                this.Dispose(false);
-            }
+            this.Dispose(false);
         }
 
         #endregion Constructors
 
         #endregion Public Properties
 
-        #region Protected Internal Properties
+        #region Internal Properties
 
         /// <summary>
         /// Gets or sets a value indicating whether the WrapperObject owns the handle.
         /// </summary>
-        protected internal bool OwnsHandle
+        internal bool OwnsHandle
         {
             get;
             set;
         }
 
-        #endregion Protected Internal Properties
+        #endregion Internal Properties
 
         #endregion Properties
 

ExampleBrowser/ExampleBrowser.csproj

     <ProductVersion>8.0.30703</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{33E464A2-1599-4D09-9D07-E2FB1B82AD1E}</ProjectGuid>
-    <OutputType>WinExe</OutputType>
+    <OutputType>Exe</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>ExampleBrowser</RootNamespace>
     <AssemblyName>ExampleBrowser</AssemblyName>
     <WarningLevel>4</WarningLevel>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
   </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject />
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="OpenTK, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL" />
     <Reference Include="OpenTK.Compatibility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL" />

ExampleBrowser/Examples/OpenTK/Example.cs

 
             if (error != ErrorType.NoError)
             {
-                MessageBox.Show(s);
-                this.Close();
-
-                var x = this.CgContext.LastListing;
+                Console.WriteLine(error);
+                Console.WriteLine(s);
+                Console.WriteLine(this.CgContext.LastListing);
             }
             //  printf("%s: %s: %s\n",
             //    myProgramName, situation, string);