mirror of
				https://github.com/Ryujinx/Opentk.git
				synced 2025-11-04 11:04:58 +00:00 
			
		
		
		
	Added static GetExtensionDelegate implementation
This commit is contained in:
		
							parent
							
								
									2ace001203
								
							
						
					
					
						commit
						ffe934fa5d
					
				| 
						 | 
					@ -26,6 +26,7 @@
 | 
				
			||||||
#endregion
 | 
					#endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Runtime.InteropServices;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenTK.Graphics
 | 
					namespace OpenTK.Graphics
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -56,5 +57,24 @@ namespace OpenTK.Graphics
 | 
				
			||||||
                throw new GraphicsContextMissingException();
 | 
					                throw new GraphicsContextMissingException();
 | 
				
			||||||
            return context != null ? context.GetAddress(funcname) : IntPtr.Zero;
 | 
					            return context != null ? context.GetAddress(funcname) : IntPtr.Zero;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        internal static Delegate GetExtensionDelegateStatic(string funcname, Type signature)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var context = GraphicsContext.CurrentContext as IGraphicsContextInternal;
 | 
				
			||||||
 | 
					            if (context == null)
 | 
				
			||||||
 | 
					                throw new GraphicsContextMissingException();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            IntPtr address = context.GetAddress(funcname);
 | 
				
			||||||
 | 
					            if (address == IntPtr.Zero ||
 | 
				
			||||||
 | 
					                address == new IntPtr(1) ||     // Workaround for buggy nvidia drivers which return
 | 
				
			||||||
 | 
					                address == new IntPtr(2))       // 1 or 2 instead of IntPtr.Zero for some extensions.
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return Marshal.GetDelegateForFunctionPointer(address, signature);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue