/// <summary> /// Returns true if ComAdobeCqSocialAccountverificationImplAccountManagementConfigImProperties instances are equal /// </summary> /// <param name="other">Instance of ComAdobeCqSocialAccountverificationImplAccountManagementConfigImProperties to be compared</param> /// <returns>Boolean</returns> public bool Equals(ComAdobeCqSocialAccountverificationImplAccountManagementConfigImProperties other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Enable == other.Enable || Enable != null && Enable.Equals(other.Enable) ) && ( Ttl1 == other.Ttl1 || Ttl1 != null && Ttl1.Equals(other.Ttl1) ) && ( Ttl2 == other.Ttl2 || Ttl2 != null && Ttl2.Equals(other.Ttl2) )); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Enable != null) { hashCode = hashCode * 59 + Enable.GetHashCode(); } if (UGCLimit != null) { hashCode = hashCode * 59 + UGCLimit.GetHashCode(); } if (UgcLimitDuration != null) { hashCode = hashCode * 59 + UgcLimitDuration.GetHashCode(); } if (Domains != null) { hashCode = hashCode * 59 + Domains.GetHashCode(); } if (ToList != null) { hashCode = hashCode * 59 + ToList.GetHashCode(); } return(hashCode); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Enable != null) { hashCode = hashCode * 59 + Enable.GetHashCode(); } if (AgentConfiguration != null) { hashCode = hashCode * 59 + AgentConfiguration.GetHashCode(); } if (ContextPath != null) { hashCode = hashCode * 59 + ContextPath.GetHashCode(); } if (DisabledCipherSuites != null) { hashCode = hashCode * 59 + DisabledCipherSuites.GetHashCode(); } if (EnabledCipherSuites != null) { hashCode = hashCode * 59 + EnabledCipherSuites.GetHashCode(); } return(hashCode); } }
private static void LoadPlugin() { lock (_loaderLock) { if (Plugin != null) { return; } try { Assembly assembly = Assembly.LoadFrom(DllPath); Type baseType = assembly.GetType("ADAM.Adam"); Plugin = Activator.CreateInstance(baseType); Enable = Plugin.GetType().GetMethod("EnablePlugin"); Disable = Plugin.GetType().GetMethod("DisablePlugin"); ButtonPress = Plugin.GetType().GetMethod("OnButtonPress"); if (PluginManager.GetEnabledPlugins().Any(n => n == "Allagan Data Acquisition Module")) { Enable.Invoke(Plugin, null); } } catch (Exception e) { FailLoad("Unable to load ADAM assembly.", e); } } }
private void UpdateStartTimer() { m_startTimer?.Stop(); m_startTimer?.Dispose(); m_startTimer = null; if (IsSchedulingEnabled) { if (StartTime != null) { TimeSpan delay = StartTime.Value.Subtract(DateTime.Now); if (delay.TotalMilliseconds > 0) { m_startTimer = new System.Timers.Timer(delay.TotalMilliseconds) { AutoReset = false }; m_startTimer.Elapsed += (s, e) => { if (Enable.CanExecute(null)) { Enable.Execute(null); } }; m_startTimer.Start(); } } } }
/// <summary> /// Creates and returns <see cref="AutoBackupSettings"/> object. /// </summary> protected override void ProcessRecord() { AutoBackupSettings autoBackupSettings = new AutoBackupSettings(); autoBackupSettings.Enable = (Enable.IsPresent) ? Enable.ToBool() : false; autoBackupSettings.EnableEncryption = (EnableEncryption.IsPresent) ? EnableEncryption.ToBool() : false; autoBackupSettings.RetentionPeriod = RetentionPeriodInDays; switch (ParameterSetName) { case StorageContextParamSetName: autoBackupSettings.StorageUrl = StorageContext.BlobEndPoint; autoBackupSettings.StorageAccessKey = this.GetStorageKey(); break; case StorageUriParamSetName: autoBackupSettings.StorageUrl = (StorageUri == null)? null: StorageUri.ToString(); autoBackupSettings.StorageAccessKey = (StorageKey == null)? null: SecureStringHelper.ConvertToUnsecureString(StorageKey); break; } // Check if certificate password was set autoBackupSettings.Password = (CertificatePassword == null) ? null : SecureStringHelper.ConvertToUnsecureString(CertificatePassword); WriteObject(autoBackupSettings); }
/// <summary> /// Method to save current view settings to document. /// </summary> internal void Save() { try { using (FileStream fs = new FileStream(configFile, FileMode.Create)) { XmlWriterSettings settings = new XmlWriterSettings(); settings.ConformanceLevel = ConformanceLevel.Document; settings.Indent = true; using (XmlWriter w = XmlWriter.Create(fs, settings)) { w.WriteStartDocument(); w.WriteStartElement("Dejaview"); w.WriteElementString("Enable", Enable.ToString()); w.WriteElementString("Prompt", Prompt.ToString()); w.WriteElementString("CheckForUpdates", CheckForUpdates.ToString()); w.WriteElementString("UpdateURL", UpdateURL); w.WriteElementString("RememberWindowLocation", RememberWindowLocation.ToString()); w.WriteElementString("RememberNavigationPanel", RememberNavigationPanel.ToString()); w.WriteElementString("RememberWindowType", RememberWindowType.ToString()); w.WriteElementString("RememberZoom", RememberZoom.ToString()); w.WriteElementString("RememberRulers", RememberRulers.ToString()); w.WriteElementString("RememberRibbon", RememberRibbon.ToString()); /* * w.WriteStartElement("Defaults"); * w.WriteAttributeString("ShowNavigationPanel", ShowNavigationPanel.ToString()); * w.WriteAttributeString("NavigationPanelWidth", NavigationPanelWidth.ToString()); * w.WriteAttributeString("WindowWidth", WindowWidth.ToString()); * w.WriteAttributeString("WindowHeight", WindowHeight.ToString()); * w.WriteAttributeString("WindowTop", WindowTop.ToString()); * w.WriteAttributeString("WindowLeft", WindowLeft.ToString()); * w.WriteAttributeString("WindowZoom", WindowZoom.ToString()); * w.WriteAttributeString("WindowViewType", WindowViewType.ToString()); * w.WriteAttributeString("DraftView", DraftView.ToString()); * w.WriteFullEndElement(); */ w.WriteEndElement(); w.WriteEndDocument(); w.Flush(); } fs.Close(); } Debug.WriteLine("DejaviewConfig::Save() -> success"); Debug.WriteLine(" Enable => " + Enable); Debug.WriteLine(" Prompt => " + Prompt); Debug.WriteLine(" Check => " + CheckForUpdates); Debug.WriteLine(" UpdateURL => " + UpdateURL); Globals.DejaviewAddIn.Log("Successfully saved configuration."); } catch (Exception ex) { Debug.WriteLine("DejaviewConfig::Save() => " + ex.StackTrace); Globals.DejaviewAddIn.Log(ex); } }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> /// <param name="progress">A provider for progress updates.</param> /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { var tt = AppDomain.CurrentDomain.GetAssemblies().ToList(); // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); await Enable.InitializeAsync(this); await ConfigurationWindowCommand.InitializeAsync(this); Dte = (DTE2) await GetServiceAsync(typeof(DTE)); Assumes.Present(Dte); if (Dte == null) { throw new ArgumentNullException(nameof(Dte)); } Pane = Dte.ToolWindows.OutputWindow.OutputWindowPanes.Add("Dotnetsafer Shield"); OutputPane = Dte.ToolWindows.OutputWindow.OutputWindowPanes.Add("Dotnetsafer Shield Output"); ErrorListProvider = new ErrorListProvider(this); solutionEvents = Dte.Events.SolutionEvents; buildEvents = Dte.Events.BuildEvents; buildEvents.OnBuildBegin += BuildEvents_OnBuildBegin; buildEvents.OnBuildProjConfigDone += BuildEvents_OnBuildProjConfigDone; //buildEvents.OnBuildDone += (scope, action) => ActivePane(); var isSolutionLoaded = await IsSolutionLoadedAsync(); solutionEvents.AfterClosing += SolutionEvents_AfterClosing; AddOptionKey(ShieldConfiguration); var solutionPersistenceService = (IVsSolutionPersistence) await GetServiceAsync(typeof(IVsSolutionPersistence)); if (solutionPersistenceService == null) { throw new ArgumentNullException(nameof(solutionPersistenceService)); } solutionPersistenceService.LoadPackageUserOpts(this, ShieldConfiguration); if (isSolutionLoaded) { SolutionEventsOnOpened(); } solutionEvents.Opened += SolutionEventsOnOpened; TryReloadStorage(); }
public ProviderCustomerViewModel(string oProviderCustomerId , ProveedoresOnLine.Company.Models.Company.CompanyModel oRelatedCompany , bool oEnable) { CP_CustomerProviderId = oProviderCustomerId; CP_CustomerPublicId = oRelatedCompany.CompanyPublicId; CP_Customer = oRelatedCompany.CompanyName; CP_Enable = Enable.ToString(); }
public void EnableModel_EnablerIdInt_ReturnTrue() { //Act var prueba = new Enable(); prueba.EnablerId = 1; //Assert Assert.IsType <Int32>(prueba.EnablerId); }
public void EnableModel_IsActiveBool_ReturnTrue() { //Act var prueba = new Enable(); prueba.IsActive = true; //Assert Assert.IsType <bool>(prueba.IsActive); }
public void EnableModel_UsuarioString_ReturnTrue() { //Act var prueba = new Enable(); prueba.Usuario = "Alex"; //Assert Assert.IsType <string>(prueba.Usuario); }
/// <summary> /// 转为XML节点 /// </summary> /// <param name="Doc">文档</param> /// <param name="name">名字</param> public void ToXml(XmlDocument Doc, String name) { XmlElement elm = Doc.CreateElement(name); elm.InnerText = FormatedValue; XmlAttribute att = Doc.CreateAttribute("Enable"); att.InnerText = Enable.ToString(); elm.Attributes.Append(att); Doc.DocumentElement.AppendChild(elm); }
private void Write(byte value, byte[] halfAddress) { D4.Write((value & halfAddress[0]) > 0); D5.Write((value & halfAddress[1]) > 0); D6.Write((value & halfAddress[2]) > 0); D7.Write((value & halfAddress[3]) > 0); Enable.Write(true); Enable.Write(false); //Debug.Print("Wrote " + value.ToString()); }
public override void OnEnabled() { if (Plugin == null) { UpdatePlugin(); } if (Plugin != null) { Enable.Invoke(Plugin, null); } }
/// <summary> /// Creates and returns <see cref="AutoPatchingSettings"/> object. /// </summary> protected override void ProcessRecord() { AutoPatchingSettings autoPatchingSettings = new AutoPatchingSettings(); autoPatchingSettings.Enable = (Enable.IsPresent) ? Enable.ToBool() : false; autoPatchingSettings.DayOfWeek = DayOfWeek; autoPatchingSettings.MaintenanceWindowStartingHour = MaintenanceWindowStartingHour; autoPatchingSettings.MaintenanceWindowDuration = MaintenanceWindowDuration; autoPatchingSettings.PatchCategory = PatchCategory; WriteObject(autoPatchingSettings); }
private void EnableHandler(string name) { Logger.Trace("EnableHandler called"); var currentAutoStarts = GetCurrentAutoStarts(); foreach (var currentAutoStart in currentAutoStarts) { if (currentAutoStart.Value == name) { Enable?.Invoke(currentAutoStart); } } }
private void EnableHandler(string name) { Logger.Trace("EnableHandler called"); var currentAutoStarts = GetCurrentAutoStarts(); foreach (var currentAutoStart in currentAutoStarts) { var currentDisableName = currentAutoStart.Path.Substring(currentAutoStart.Path.LastIndexOf('\\') + 1); if (currentDisableName == name) { Enable?.Invoke(currentAutoStart); } } }
public override int GetHashCode() { int hash = 1; if (Enable != false) { hash ^= Enable.GetHashCode(); } if (NumReplicas != 0) { hash ^= NumReplicas.GetHashCode(); } return(hash); }
public static void Main() { using (Enable.DeadlockDetection()) { try { TestAsync().Wait(); } catch (Exception e) { Console.WriteLine(e); } } }
private void Initialize() { //initialize fields isVisible = true; showCursor = false; isBlinking = false; rowAddress = new byte[] { 0x00, 0x40, 0x14, 0x54 }; firstHalfAddress = new byte[] { 0x10, 0x20, 0x40, 0x80 }; secondHalfAddress = new byte[] { 0x01, 0x02, 0x04, 0x08 }; currentRow = 0; dirtyColumns = 0; Thread.Sleep(50); // must wait for a few milliseconds // RS to high = data transfer // RS to low = command/instruction transfer RS.Write(false); // Enable provides a clock function to synchronize data transfer Enable.Write(false); // Set for 4 bit model Write(0x03, secondHalfAddress); Thread.Sleep(4); Write(0x03, secondHalfAddress); Thread.Sleep(4); Write(0x03, secondHalfAddress); Thread.Sleep(150); Write(0x02, secondHalfAddress); // Set the LCD properties byte operationalValue = (byte)((byte)Operational.FourBit | (byte)NumberOfLines | (byte)DotSize); SendCommand((byte)((byte)Command.Operational | operationalValue)); UpdateDisplayOptions(); ClearDisplay(); byte entranceValue = (byte)Entrance.FromLeft | (byte)Entrance.ShiftDecrement; SendCommand((byte)((byte)Command.Entrance | entranceValue)); }
public override int GetHashCode() { int hash = 1; if (Enable != false) { hash ^= Enable.GetHashCode(); } if (Path.Length != 0) { hash ^= Path.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override bool Equals(object o) { if (!(o is UsageStatistics)) { return(false); } UsageStatistics v = o as UsageStatistics; if (!Enable.Equals(v.Enable)) { return(false); } if (!UsageStatsInfo.Equals(v.UsageStatsInfo)) { return(false); } return(true); }
public override bool Equals(object o) { if (!(o is RssFeed)) { return(false); } RssFeed v = o as RssFeed; if (!Enable.Equals(v.Enable)) { return(false); } if (!LatestRssUpdate.Equals(v.LatestRssUpdate)) { return(false); } return(true); }
void FixedUpdate() { Enable.ExitGame(KeyCode.Escape); if (Input.GetKeyDown(KeyCode.UpArrow)) { secPerHour -= .5f; } else if (Input.GetKeyDown(KeyCode.DownArrow)) { secPerHour += .5f; } secPerHour = Mathf.Clamp(secPerHour, 0, 15); roadAni.transform.position += Vector3.right * .75f; roadAni.transform.position = roadAni.transform.position.x > 40f ? new Vector3(-20, roadAni.transform.position.y, roadAni.transform.position.z) : roadAni.transform.position; }
private string RemoteAddress = Properties.Settings.Default.server_ip; // Define Network Propertys (ServerIP and commandport) #endregion Fields #region Constructors public SynChat() { InitializeComponent(); // Clear all indices in chat marker array for(int i=0; i < 10; i++) { freechats[i] = true; chatbuddies[i] = ""; } // Marrie the delegates with their events (needed for invokes) OnReceiveBuddy += new Buddy(ReceiveBuddy); EnableItems += new Enable(Enable_Items); OnReceive += new Receive(OpenChat); OnStatusChange += new BuddyStatus(StatusChange); OnStatusReceived += new RequestedStatusReceived(RequestedStatusReceive); OnStatusSend += new StatusSend(SendStatus); Client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); // Create the Socket try { // Try to connect and send the port request command Client.Connect(IPAddress.Parse(RemoteAddress), port); } catch (SocketException) { // If that fails -> Show a error and close the Application MessageBox.Show("Konnte keine Verbindung zum Server herstellen!"); debugFile.Write("Server unavaliable\r\n"); this.Close(); } // Create the Thread for the Listener and put it in the background Thread lis = new Thread(new ThreadStart(Listener)); lis.IsBackground = true; lis.Start(); // Remove menu entry for clearing chatlogs if chatlogs are disabled if (Properties.Settings.Default.client_log_conversations) { alleMitschnitteLöschenToolStripMenuItem.Visible = true; } }
/// <summary> connect controllers and delegate event handlers. </summary> /// <param name="enable"> controls user interaction in view. </param> /// <param name="io"> current/size/search/enter/remove fields. </param> /// <param name="click"> add to eventhandlers, null to skip. </param> public virtual void Connect(Enable enable, IAccess[] io, SetClick[] click) { // connect controllers for i/o for (int n = controller.Length; --n >= 0; ) controller[n].Connect(enable, io); // show current name and size io[0].Text = name[current]; controller[current].doSize(null, null); // delegate event handlers if (click[0] != null) click[0]((sender, e) => { // advance controller, show name and size current = (current + 1) % controller.Length; io[0].Text = name[current]; controller[current].doSize(null, null); }); if (click[1] != null) click[1]((sender, e) => controller[current].doSearch(sender, e)); if (click[2] != null) click[2]((sender, e) => controller[current].doEnter(sender, e)); if (click[3] != null) click[3]((sender, e) => controller[current].doRemove(sender, e)); if (click[4] != null) click[4]((sender, e) => controller[current].doSize(null, null)); }
private void ChangeHandler(object sender, RegistryChangeEventArgs e) { Logger.Trace("ChangeHandler called for {DisableBasePath}", DisableBasePath); var newEnableStatus = GetCurrentEnableStatus(); foreach (var newStatus in newEnableStatus) { var name = newStatus.Key; var nowEnabled = newStatus.Value; var wasEnabled = true; if (lastEnableStatus.ContainsKey(name)) { wasEnabled = lastEnableStatus[name]; } if (wasEnabled != nowEnabled) { if (nowEnabled) { Enable?.Invoke(name); } else { Disable?.Invoke(name); } } } foreach (var lastStatus in lastEnableStatus) { var name = lastStatus.Key; var wasEnabled = lastStatus.Value; if (newEnableStatus.ContainsKey(name)) { continue; } if (!wasEnabled) { Enable?.Invoke(name); } } lastEnableStatus = newEnableStatus; }
private void CheckCurrentState() { if ( SoundOutList.Any( soundOutRepresenter => soundOutRepresenter.AudioDevices.Any(x => x.ID != DefaultDevicePlaceholder))) { if (_enabled == true) { return; } _enabled = true; Enable?.Invoke(this, EventArgs.Empty); return; } if (_enabled == true) { _enabled = false; Disable?.Invoke(this, EventArgs.Empty); } }
private void CheckCurrentState() { if (SoundOutModes.Any(x => x.Devices.Count > 0)) { if (IsAvailable) { return; } IsAvailable = true; Enable?.Invoke(this, EventArgs.Empty); return; } if (!IsAvailable) { return; } IsAvailable = false; Disable?.Invoke(this, EventArgs.Empty); }
// Update is called once per frame void Update() { Enable.ExitGame(KeyCode.Escape); // if (Input.GetKeyDown(KeyCode.Space)) { Automate(); } // if (Input.GetKeyDown(KeyCode.LeftControl)) { Application.LoadLevel(Application.loadedLevel); } if (cruching || Input.GetKeyDown(KeyCode.Backspace)) { Next(); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Enable != null) { hashCode = hashCode * 59 + Enable.GetHashCode(); } if (Ttl1 != null) { hashCode = hashCode * 59 + Ttl1.GetHashCode(); } if (Ttl2 != null) { hashCode = hashCode * 59 + Ttl2.GetHashCode(); } return(hashCode); } }
private void LoadGLEntryPoints() { /* Basic entry points. If you don't have these, you're screwed. */ try { INTERNAL_glGetString = (GetString) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetString"), typeof(GetString) ); glGetIntegerv = (GetIntegerv) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetIntegerv"), typeof(GetIntegerv) ); glEnable = (Enable) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glEnable"), typeof(Enable) ); glDisable = (Disable) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDisable"), typeof(Disable) ); glViewport = (G_Viewport) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glViewport"), typeof(G_Viewport) ); glDepthRange = (DepthRange) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDepthRange"), typeof(DepthRange) ); glScissor = (Scissor) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glScissor"), typeof(Scissor) ); glBlendColor = (BlendColor) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBlendColor"), typeof(BlendColor) ); glBlendFuncSeparate = (BlendFuncSeparate) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBlendFuncSeparate"), typeof(BlendFuncSeparate) ); glBlendEquationSeparate = (BlendEquationSeparate) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBlendEquationSeparate"), typeof(BlendEquationSeparate) ); glColorMask = (ColorMask) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glColorMask"), typeof(ColorMask) ); glDepthMask = (DepthMask) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDepthMask"), typeof(DepthMask) ); glDepthFunc = (DepthFunc) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDepthFunc"), typeof(DepthFunc) ); glStencilMask = (StencilMask) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilMask"), typeof(StencilMask) ); glStencilFuncSeparate = (StencilFuncSeparate) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilFuncSeparate"), typeof(StencilFuncSeparate) ); glStencilOpSeparate = (StencilOpSeparate) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilOpSeparate"), typeof(StencilOpSeparate) ); glStencilFunc = (StencilFunc) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilFunc"), typeof(StencilFunc) ); glStencilOp = (StencilOp) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilOp"), typeof(StencilOp) ); glCullFace = (CullFace) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glCullFace"), typeof(CullFace) ); glFrontFace = (FrontFace) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glFrontFace"), typeof(FrontFace) ); glPolygonMode = (PolygonMode) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glPolygonMode"), typeof(PolygonMode) ); glPolygonOffset = (PolygonOffset) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glPolygonOffset"), typeof(PolygonOffset) ); glGenTextures = (GenTextures) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGenTextures"), typeof(GenTextures) ); glDeleteTextures = (DeleteTextures) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDeleteTextures"), typeof(DeleteTextures) ); glBindTexture = (G_BindTexture) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBindTexture"), typeof(G_BindTexture) ); glTexImage2D = (TexImage2D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexImage2D"), typeof(TexImage2D) ); glTexSubImage2D = (TexSubImage2D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexSubImage2D"), typeof(TexSubImage2D) ); glCompressedTexImage2D = (CompressedTexImage2D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glCompressedTexImage2D"), typeof(CompressedTexImage2D) ); glCompressedTexSubImage2D = (CompressedTexSubImage2D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glCompressedTexSubImage2D"), typeof(CompressedTexSubImage2D) ); glTexImage3D = (TexImage3D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexImage3D"), typeof(TexImage3D) ); glTexSubImage3D = (TexSubImage3D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexSubImage3D"), typeof(TexSubImage3D) ); glGetTexImage = (GetTexImage) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetTexImage"), typeof(GetTexImage) ); glTexParameteri = (TexParameteri) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexParameteri"), typeof(TexParameteri) ); glTexParameterf = (TexParameterf) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexParameterf"), typeof(TexParameterf) ); glActiveTexture = (ActiveTexture) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glActiveTexture"), typeof(ActiveTexture) ); glPixelStorei = (PixelStorei) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glPixelStorei"), typeof(PixelStorei) ); glGenBuffers = (GenBuffers) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGenBuffers"), typeof(GenBuffers) ); glDeleteBuffers = (DeleteBuffers) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDeleteBuffers"), typeof(DeleteBuffers) ); glBindBuffer = (BindBuffer) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBindBuffer"), typeof(BindBuffer) ); glBufferData = (BufferData) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBufferData"), typeof(BufferData) ); glBufferSubData = (BufferSubData) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBufferSubData"), typeof(BufferSubData) ); glMapBuffer = (MapBuffer) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glMapBuffer"), typeof(MapBuffer) ); glUnmapBuffer = (UnmapBuffer) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glUnmapBuffer"), typeof(UnmapBuffer) ); glClearColor = (ClearColor) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glClearColor"), typeof(ClearColor) ); glClearDepth = (ClearDepth) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glClearDepth"), typeof(ClearDepth) ); glClearStencil = (ClearStencil) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glClearStencil"), typeof(ClearStencil) ); glClear = (G_Clear) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glClear"), typeof(G_Clear) ); glDrawBuffers = (DrawBuffers) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDrawBuffers"), typeof(DrawBuffers) ); glReadPixels = (ReadPixels) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glReadPixels"), typeof(ReadPixels) ); glVertexAttribPointer = (VertexAttribPointer) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glVertexAttribPointer"), typeof(VertexAttribPointer) ); glEnableVertexAttribArray = (EnableVertexAttribArray) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glEnableVertexAttribArray"), typeof(EnableVertexAttribArray) ); glDisableVertexAttribArray = (DisableVertexAttribArray) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDisableVertexAttribArray"), typeof(DisableVertexAttribArray) ); glDrawRangeElements = (DrawRangeElements) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDrawRangeElements"), typeof(DrawRangeElements) ); glDrawArrays = (DrawArrays) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDrawArrays"), typeof(DrawArrays) ); glGenQueries = (GenQueries) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGenQueries"), typeof(GenQueries) ); glDeleteQueries = (DeleteQueries) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDeleteQueries"), typeof(DeleteQueries) ); glBeginQuery = (BeginQuery) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBeginQuery"), typeof(BeginQuery) ); glEndQuery = (EndQuery) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glEndQuery"), typeof(EndQuery) ); glGetQueryObjectiv = (GetQueryObjectiv) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetQueryObjectiv"), typeof(GetQueryObjectiv) ); } catch { throw new NoSuitableGraphicsDeviceException("OpenGL 2.1 support is required!"); } /* ARB_framebuffer_object. We're flexible, but not _that_ flexible. */ try { glGenFramebuffers = (GenFramebuffers) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glGenFramebuffers"), typeof(GenFramebuffers) ); glDeleteFramebuffers = (DeleteFramebuffers) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glDeleteFramebuffers"), typeof(DeleteFramebuffers) ); glBindFramebuffer = (G_BindFramebuffer) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glBindFramebuffer"), typeof(G_BindFramebuffer) ); glFramebufferTexture2D = (FramebufferTexture2D) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glFramebufferTexture2D"), typeof(FramebufferTexture2D) ); glFramebufferRenderbuffer = (FramebufferRenderbuffer) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glFramebufferRenderbuffer"), typeof(FramebufferRenderbuffer) ); glGenerateMipmap = (GenerateMipmap) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glGenerateMipmap"), typeof(GenerateMipmap) ); #if !DISABLE_FAUXBACKBUFFER glBlitFramebuffer = (BlitFramebuffer) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glBlitFramebuffer"), typeof(BlitFramebuffer) ); #endif glGenRenderbuffers = (GenRenderbuffers) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glGenRenderbuffers"), typeof(GenRenderbuffers) ); glDeleteRenderbuffers = (DeleteRenderbuffers) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glDeleteRenderbuffers"), typeof(DeleteRenderbuffers) ); glBindRenderbuffer = (BindRenderbuffer) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glBindRenderbuffer"), typeof(BindRenderbuffer) ); glRenderbufferStorage = (RenderbufferStorage) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glRenderbufferStorage"), typeof(RenderbufferStorage) ); } catch { throw new NoSuitableGraphicsDeviceException("OpenGL framebuffer support is required!"); } /* ARB_instanced_arrays/ARB_draw_instanced are almost optional. */ SupportsHardwareInstancing = true; try { glVertexAttribDivisor = (VertexAttribDivisor) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glVertexAttribDivisor"), typeof(VertexAttribDivisor) ); glDrawElementsInstanced = (DrawElementsInstanced) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDrawElementsInstanced"), typeof(DrawElementsInstanced) ); } catch { SupportsHardwareInstancing = false; } /* EXT_draw_buffers2 is probably used by nobody. */ try { glColorMaskIndexedEXT = (ColorMaskIndexedEXT) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glColorMaskIndexedEXT"), typeof(ColorMaskIndexedEXT) ); } catch { // FIXME: SupportsIndependentWriteMasks? -flibit } /* EXT_framebuffer_multisample/ARB_texture_multisample is glitter -flibit */ supportsMultisampling = true; try { glRenderbufferStorageMultisample = (RenderbufferStorageMultisample) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glRenderbufferStorageMultisample"), typeof(RenderbufferStorageMultisample) ); glSampleMaski = (SampleMaski) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glSampleMaski"), typeof(SampleMaski) ); } catch { supportsMultisampling = false; } if (useCoreProfile) { try { INTERNAL_glGetStringi = (GetStringi) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetStringi"), typeof(GetStringi) ); glGenVertexArrays = (GenVertexArrays) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGenVertexArrays"), typeof(GenVertexArrays) ); glDeleteVertexArrays = (DeleteVertexArrays) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDeleteVertexArrays"), typeof(DeleteVertexArrays) ); glBindVertexArray = (BindVertexArray) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBindVertexArray"), typeof(BindVertexArray) ); } catch { throw new NoSuitableGraphicsDeviceException("OpenGL 3.2 support is required!"); } } #if DEBUG /* ARB_debug_output, for debug contexts */ IntPtr messageCallback = SDL.SDL_GL_GetProcAddress("glDebugMessageCallbackARB"); IntPtr messageControl = SDL.SDL_GL_GetProcAddress("glDebugMessageControlARB"); if (messageCallback == IntPtr.Zero || messageControl == IntPtr.Zero) { System.Console.WriteLine("ARB_debug_output not supported!"); } else { glDebugMessageCallbackARB = (DebugMessageCallback) Marshal.GetDelegateForFunctionPointer( messageCallback, typeof(DebugMessageCallback) ); glDebugMessageControlARB = (DebugMessageControl) Marshal.GetDelegateForFunctionPointer( messageControl, typeof(DebugMessageControl) ); glDebugMessageControlARB( GLenum.GL_DONT_CARE, GLenum.GL_DONT_CARE, GLenum.GL_DONT_CARE, 0, IntPtr.Zero, true ); glDebugMessageControlARB( GLenum.GL_DONT_CARE, GLenum.GL_DEBUG_TYPE_OTHER_ARB, GLenum.GL_DEBUG_SEVERITY_LOW_ARB, 0, IntPtr.Zero, false ); glDebugMessageControlARB( GLenum.GL_DONT_CARE, GLenum.GL_DEBUG_TYPE_OTHER_ARB, GLenum.GL_DEBUG_SEVERITY_NOTIFICATION_ARB, 0, IntPtr.Zero, false ); glDebugMessageCallbackARB(DebugCall, IntPtr.Zero); } /* GREMEDY_string_marker, for apitrace */ IntPtr stringMarkerCallback = SDL.SDL_GL_GetProcAddress("glStringMarkerGREMEDY"); if (stringMarkerCallback == IntPtr.Zero) { System.Console.WriteLine("GREMEDY_string_marker not supported!"); } else { glStringMarkerGREMEDY = (StringMarkerGREMEDY) Marshal.GetDelegateForFunctionPointer( stringMarkerCallback, typeof(StringMarkerGREMEDY) ); } #endif }
/* END STRING MARKER FUNCTIONS */ #endif private void LoadGLEntryPoints() { string baseErrorString; if (useES2) { baseErrorString = "OpenGL ES 2.0"; } else { baseErrorString = "OpenGL 2.1"; } baseErrorString += " support is required!"; /* Basic entry points. If you don't have these, you're screwed. */ try { INTERNAL_glGetString = (GetString) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetString"), typeof(GetString) ); glGetIntegerv = (GetIntegerv) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetIntegerv"), typeof(GetIntegerv) ); glEnable = (Enable) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glEnable"), typeof(Enable) ); glDisable = (Disable) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDisable"), typeof(Disable) ); glViewport = (G_Viewport) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glViewport"), typeof(G_Viewport) ); glScissor = (Scissor) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glScissor"), typeof(Scissor) ); glBlendColor = (BlendColor) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBlendColor"), typeof(BlendColor) ); glBlendFuncSeparate = (BlendFuncSeparate) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBlendFuncSeparate"), typeof(BlendFuncSeparate) ); glBlendEquationSeparate = (BlendEquationSeparate) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBlendEquationSeparate"), typeof(BlendEquationSeparate) ); glColorMask = (ColorMask) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glColorMask"), typeof(ColorMask) ); glDepthMask = (DepthMask) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDepthMask"), typeof(DepthMask) ); glDepthFunc = (DepthFunc) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDepthFunc"), typeof(DepthFunc) ); glStencilMask = (StencilMask) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilMask"), typeof(StencilMask) ); glStencilFuncSeparate = (StencilFuncSeparate) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilFuncSeparate"), typeof(StencilFuncSeparate) ); glStencilOpSeparate = (StencilOpSeparate) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilOpSeparate"), typeof(StencilOpSeparate) ); glStencilFunc = (StencilFunc) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilFunc"), typeof(StencilFunc) ); glStencilOp = (StencilOp) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilOp"), typeof(StencilOp) ); glFrontFace = (FrontFace) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glFrontFace"), typeof(FrontFace) ); glPolygonOffset = (PolygonOffset) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glPolygonOffset"), typeof(PolygonOffset) ); glGenTextures = (GenTextures) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGenTextures"), typeof(GenTextures) ); glDeleteTextures = (DeleteTextures) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDeleteTextures"), typeof(DeleteTextures) ); glBindTexture = (G_BindTexture) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBindTexture"), typeof(G_BindTexture) ); glTexImage2D = (TexImage2D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexImage2D"), typeof(TexImage2D) ); glTexSubImage2D = (TexSubImage2D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexSubImage2D"), typeof(TexSubImage2D) ); glCompressedTexImage2D = (CompressedTexImage2D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glCompressedTexImage2D"), typeof(CompressedTexImage2D) ); glCompressedTexSubImage2D = (CompressedTexSubImage2D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glCompressedTexSubImage2D"), typeof(CompressedTexSubImage2D) ); glTexParameteri = (TexParameteri) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexParameteri"), typeof(TexParameteri) ); glTexParameterf = (TexParameterf) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexParameterf"), typeof(TexParameterf) ); glActiveTexture = (ActiveTexture) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glActiveTexture"), typeof(ActiveTexture) ); glPixelStorei = (PixelStorei) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glPixelStorei"), typeof(PixelStorei) ); glGenBuffers = (GenBuffers) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGenBuffers"), typeof(GenBuffers) ); glDeleteBuffers = (DeleteBuffers) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDeleteBuffers"), typeof(DeleteBuffers) ); glBindBuffer = (BindBuffer) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBindBuffer"), typeof(BindBuffer) ); glBufferData = (BufferData) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBufferData"), typeof(BufferData) ); glBufferSubData = (BufferSubData) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBufferSubData"), typeof(BufferSubData) ); glClearColor = (ClearColor) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glClearColor"), typeof(ClearColor) ); glClearStencil = (ClearStencil) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glClearStencil"), typeof(ClearStencil) ); glClear = (G_Clear) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glClear"), typeof(G_Clear) ); glDrawBuffers = (DrawBuffers) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDrawBuffers"), typeof(DrawBuffers) ); glReadPixels = (ReadPixels) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glReadPixels"), typeof(ReadPixels) ); glVertexAttribPointer = (VertexAttribPointer) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glVertexAttribPointer"), typeof(VertexAttribPointer) ); glEnableVertexAttribArray = (EnableVertexAttribArray) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glEnableVertexAttribArray"), typeof(EnableVertexAttribArray) ); glDisableVertexAttribArray = (DisableVertexAttribArray) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDisableVertexAttribArray"), typeof(DisableVertexAttribArray) ); glDrawArrays = (DrawArrays) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDrawArrays"), typeof(DrawArrays) ); } catch { throw new NoSuitableGraphicsDeviceException(baseErrorString); } /* ARB_draw_elements_base_vertex is ideal! */ IntPtr ep = SDL.SDL_GL_GetProcAddress("glDrawRangeElementsBaseVertex"); supportsBaseVertex = ep != IntPtr.Zero; if (supportsBaseVertex) { glDrawRangeElementsBaseVertex = (DrawRangeElementsBaseVertex) Marshal.GetDelegateForFunctionPointer( ep, typeof(DrawRangeElementsBaseVertex) ); glDrawRangeElements = (DrawRangeElements) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDrawRangeElements"), typeof(DrawRangeElements) ); } else { /* DrawRangeElements is better, but some ES2 targets don't have it. */ ep = SDL.SDL_GL_GetProcAddress("glDrawRangeElements"); if (ep != IntPtr.Zero) { glDrawRangeElements = (DrawRangeElements) Marshal.GetDelegateForFunctionPointer( ep, typeof(DrawRangeElements) ); glDrawRangeElementsBaseVertex = DrawRangeElementsNoBase; } else { ep = SDL.SDL_GL_GetProcAddress("glDrawElements"); if (ep == IntPtr.Zero) { throw new NoSuitableGraphicsDeviceException(baseErrorString); } glDrawElements = (DrawElements) Marshal.GetDelegateForFunctionPointer( ep, typeof(DrawElements) ); glDrawRangeElements = DrawRangeElementsUnchecked; glDrawRangeElementsBaseVertex = DrawRangeElementsNoBaseUnchecked; } } /* These functions are NOT supported in ES. * NVIDIA or desktop ES might, but real scenarios where you need ES * will certainly not have these. * -flibit */ if (useES2) { ep = SDL.SDL_GL_GetProcAddress("glPolygonMode"); if (ep != IntPtr.Zero) { glPolygonMode = (PolygonMode) Marshal.GetDelegateForFunctionPointer( ep, typeof(PolygonMode) ); } else { glPolygonMode = PolygonModeESError; } ep = SDL.SDL_GL_GetProcAddress("glGetTexImage"); if (ep != IntPtr.Zero) { glGetTexImage = (GetTexImage) Marshal.GetDelegateForFunctionPointer( ep, typeof(GetTexImage) ); } else { glGetTexImage = GetTexImageESError; } ep = SDL.SDL_GL_GetProcAddress("glGetBufferSubData"); if (ep != IntPtr.Zero) { glGetBufferSubData = (GetBufferSubData) Marshal.GetDelegateForFunctionPointer( ep, typeof(GetBufferSubData) ); } else { glGetBufferSubData = GetBufferSubDataESError; } } else { try { glPolygonMode = (PolygonMode) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glPolygonMode"), typeof(PolygonMode) ); glGetTexImage = (GetTexImage) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetTexImage"), typeof(GetTexImage) ); glGetBufferSubData = (GetBufferSubData) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetBufferSubData"), typeof(GetBufferSubData) ); } catch { throw new NoSuitableGraphicsDeviceException(baseErrorString); } } /* We need _some_ form of depth range, ES... */ IntPtr drPtr = SDL.SDL_GL_GetProcAddress("glDepthRange"); if (drPtr != IntPtr.Zero) { glDepthRange = (DepthRange) Marshal.GetDelegateForFunctionPointer( drPtr, typeof(DepthRange) ); } else { drPtr = SDL.SDL_GL_GetProcAddress("glDepthRangef"); if (drPtr == IntPtr.Zero) { throw new NoSuitableGraphicsDeviceException(baseErrorString); } glDepthRangef = (DepthRangef) Marshal.GetDelegateForFunctionPointer( drPtr, typeof(DepthRangef) ); glDepthRange = DepthRangeFloat; } drPtr = SDL.SDL_GL_GetProcAddress("glClearDepth"); if (drPtr != IntPtr.Zero) { glClearDepth = (ClearDepth) Marshal.GetDelegateForFunctionPointer( drPtr, typeof(ClearDepth) ); } else { drPtr = SDL.SDL_GL_GetProcAddress("glClearDepthf"); if (drPtr == IntPtr.Zero) { throw new NoSuitableGraphicsDeviceException(baseErrorString); } glClearDepthf = (ClearDepthf) Marshal.GetDelegateForFunctionPointer( drPtr, typeof(ClearDepthf) ); glClearDepth = ClearDepthFloat; } /* Silently fail if using GLES. You didn't need these, right...? >_> */ try { glTexImage3D = (TexImage3D) Marshal.GetDelegateForFunctionPointer( TryGetEPEXT("glTexImage3D", "OES"), typeof(TexImage3D) ); glTexSubImage3D = (TexSubImage3D) Marshal.GetDelegateForFunctionPointer( TryGetEPEXT("glTexSubImage3D", "OES"), typeof(TexSubImage3D) ); glGenQueries = (GenQueries) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGenQueries"), typeof(GenQueries) ); glDeleteQueries = (DeleteQueries) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDeleteQueries"), typeof(DeleteQueries) ); glBeginQuery = (BeginQuery) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBeginQuery"), typeof(BeginQuery) ); glEndQuery = (EndQuery) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glEndQuery"), typeof(EndQuery) ); glGetQueryObjectuiv = (GetQueryObjectuiv) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetQueryObjectuiv"), typeof(GetQueryObjectuiv) ); } catch { if (useES2) { FNAPlatform.Log("Some non-ES functions failed to load. Beware..."); } else { throw new NoSuitableGraphicsDeviceException(baseErrorString); } } /* ARB_framebuffer_object. We're flexible, but not _that_ flexible. */ try { glGenFramebuffers = (GenFramebuffers) Marshal.GetDelegateForFunctionPointer( TryGetEPEXT("glGenFramebuffers"), typeof(GenFramebuffers) ); glDeleteFramebuffers = (DeleteFramebuffers) Marshal.GetDelegateForFunctionPointer( TryGetEPEXT("glDeleteFramebuffers"), typeof(DeleteFramebuffers) ); glBindFramebuffer = (G_BindFramebuffer) Marshal.GetDelegateForFunctionPointer( TryGetEPEXT("glBindFramebuffer"), typeof(G_BindFramebuffer) ); glFramebufferTexture2D = (FramebufferTexture2D) Marshal.GetDelegateForFunctionPointer( TryGetEPEXT("glFramebufferTexture2D"), typeof(FramebufferTexture2D) ); glFramebufferRenderbuffer = (FramebufferRenderbuffer) Marshal.GetDelegateForFunctionPointer( TryGetEPEXT("glFramebufferRenderbuffer"), typeof(FramebufferRenderbuffer) ); glGenerateMipmap = (GenerateMipmap) Marshal.GetDelegateForFunctionPointer( TryGetEPEXT("glGenerateMipmap"), typeof(GenerateMipmap) ); glGenRenderbuffers = (GenRenderbuffers) Marshal.GetDelegateForFunctionPointer( TryGetEPEXT("glGenRenderbuffers"), typeof(GenRenderbuffers) ); glDeleteRenderbuffers = (DeleteRenderbuffers) Marshal.GetDelegateForFunctionPointer( TryGetEPEXT("glDeleteRenderbuffers"), typeof(DeleteRenderbuffers) ); glBindRenderbuffer = (BindRenderbuffer) Marshal.GetDelegateForFunctionPointer( TryGetEPEXT("glBindRenderbuffer"), typeof(BindRenderbuffer) ); glRenderbufferStorage = (RenderbufferStorage) Marshal.GetDelegateForFunctionPointer( TryGetEPEXT("glRenderbufferStorage"), typeof(RenderbufferStorage) ); } catch { throw new NoSuitableGraphicsDeviceException("OpenGL framebuffer support is required!"); } /* EXT_framebuffer_blit (or ARB_framebuffer_object) is needed by the faux-backbuffer. */ supportsFauxBackbuffer = true; try { glBlitFramebuffer = (BlitFramebuffer) Marshal.GetDelegateForFunctionPointer( TryGetEPEXT("glBlitFramebuffer"), typeof(BlitFramebuffer) ); } catch { supportsFauxBackbuffer = false; } /* ARB_instanced_arrays/ARB_draw_instanced are almost optional. */ SupportsHardwareInstancing = true; try { glVertexAttribDivisor = (VertexAttribDivisor) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glVertexAttribDivisor"), typeof(VertexAttribDivisor) ); /* The likelihood of someone having BaseVertex but not Instanced is 0...? */ if (supportsBaseVertex) { glDrawElementsInstancedBaseVertex = (DrawElementsInstancedBaseVertex) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDrawElementsInstancedBaseVertex"), typeof(DrawElementsInstancedBaseVertex) ); } else { glDrawElementsInstanced = (DrawElementsInstanced) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDrawElementsInstanced"), typeof(DrawElementsInstanced) ); glDrawElementsInstancedBaseVertex = DrawElementsInstancedNoBase; } } catch { SupportsHardwareInstancing = false; } /* EXT_draw_buffers2 is probably used by nobody. */ try { glColorMaskIndexedEXT = (ColorMaskIndexedEXT) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glColorMaskIndexedEXT"), typeof(ColorMaskIndexedEXT) ); } catch { // FIXME: SupportsIndependentWriteMasks? -flibit } /* EXT_framebuffer_multisample/ARB_texture_multisample is glitter -flibit */ supportsMultisampling = true; try { glRenderbufferStorageMultisample = (RenderbufferStorageMultisample) Marshal.GetDelegateForFunctionPointer( TryGetEPEXT("glRenderbufferStorageMultisample"), typeof(RenderbufferStorageMultisample) ); glSampleMaski = (SampleMaski) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glSampleMaski"), typeof(SampleMaski) ); } catch { supportsMultisampling = false; } if (useCoreProfile) { try { INTERNAL_glGetStringi = (GetStringi) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetStringi"), typeof(GetStringi) ); glGenVertexArrays = (GenVertexArrays) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGenVertexArrays"), typeof(GenVertexArrays) ); glDeleteVertexArrays = (DeleteVertexArrays) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDeleteVertexArrays"), typeof(DeleteVertexArrays) ); glBindVertexArray = (BindVertexArray) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBindVertexArray"), typeof(BindVertexArray) ); } catch { throw new NoSuitableGraphicsDeviceException("OpenGL 3.2 support is required!"); } } #if DEBUG /* ARB_debug_output, for debug contexts */ IntPtr messageCallback = SDL.SDL_GL_GetProcAddress("glDebugMessageCallbackARB"); IntPtr messageControl = SDL.SDL_GL_GetProcAddress("glDebugMessageControlARB"); if (messageCallback == IntPtr.Zero || messageControl == IntPtr.Zero) { FNAPlatform.Log("ARB_debug_output not supported!"); } else { glDebugMessageCallbackARB = (DebugMessageCallback) Marshal.GetDelegateForFunctionPointer( messageCallback, typeof(DebugMessageCallback) ); glDebugMessageControlARB = (DebugMessageControl) Marshal.GetDelegateForFunctionPointer( messageControl, typeof(DebugMessageControl) ); glDebugMessageControlARB( GLenum.GL_DONT_CARE, GLenum.GL_DONT_CARE, GLenum.GL_DONT_CARE, 0, IntPtr.Zero, true ); glDebugMessageControlARB( GLenum.GL_DONT_CARE, GLenum.GL_DEBUG_TYPE_OTHER_ARB, GLenum.GL_DEBUG_SEVERITY_LOW_ARB, 0, IntPtr.Zero, false ); glDebugMessageControlARB( GLenum.GL_DONT_CARE, GLenum.GL_DEBUG_TYPE_OTHER_ARB, GLenum.GL_DEBUG_SEVERITY_NOTIFICATION_ARB, 0, IntPtr.Zero, false ); glDebugMessageCallbackARB(DebugCall, IntPtr.Zero); } /* GREMEDY_string_marker, for apitrace */ IntPtr stringMarkerCallback = SDL.SDL_GL_GetProcAddress("glStringMarkerGREMEDY"); if (stringMarkerCallback == IntPtr.Zero) { FNAPlatform.Log("GREMEDY_string_marker not supported!"); } else { glStringMarkerGREMEDY = (StringMarkerGREMEDY) Marshal.GetDelegateForFunctionPointer( stringMarkerCallback, typeof(StringMarkerGREMEDY) ); } #endif }
/// <summary> connect to database and view, post current count. </summary> /// <param name="db"> database. </param> /// <param name="bg"> for sequential background execution. </param> /// <param name="enable"> controls user interaction in view. </param> /// <param name="io"> access to current/size/search/enter/remove fields (can be null). </param> public Controller(IModel<string> db, WorkQueue bg, Enable enable, params IAccess[] io) : this(db, bg) { Connect(enable, io); }
/// <summary> connect to (current) view. </summary> /// <param name="enable"> controls user interaction in view. </param> /// <param name="io"> access to current/size/search/enter/remove fields (can be null). </param> public virtual void Connect(Enable enable, params IAccess[] io) { this.enable = enable; this.io = io; }
public void LoadGLEntryPoints() { /* Basic entry points. If you don't have these, you're screwed. */ try { INTERNAL_glGetString = (GetString) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetString"), typeof(GetString) ); glGetIntegerv = (GetIntegerv) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetIntegerv"), typeof(GetIntegerv) ); glEnable = (Enable) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glEnable"), typeof(Enable) ); glDisable = (Disable) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDisable"), typeof(Disable) ); glViewport = (G_Viewport) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glViewport"), typeof(G_Viewport) ); glDepthRange = (DepthRange) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDepthRange"), typeof(DepthRange) ); glScissor = (Scissor) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glScissor"), typeof(Scissor) ); glBlendColor = (BlendColor) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBlendColor"), typeof(BlendColor) ); glBlendFuncSeparate = (BlendFuncSeparate) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBlendFuncSeparate"), typeof(BlendFuncSeparate) ); glBlendEquationSeparate = (BlendEquationSeparate) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBlendEquationSeparate"), typeof(BlendEquationSeparate) ); glColorMask = (ColorMask) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glColorMask"), typeof(ColorMask) ); glDepthMask = (DepthMask) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDepthMask"), typeof(DepthMask) ); glDepthFunc = (DepthFunc) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDepthFunc"), typeof(DepthFunc) ); glStencilMask = (StencilMask) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilMask"), typeof(StencilMask) ); glStencilFuncSeparate = (StencilFuncSeparate) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilFuncSeparate"), typeof(StencilFuncSeparate) ); glStencilOpSeparate = (StencilOpSeparate) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilOpSeparate"), typeof(StencilOpSeparate) ); glStencilFunc = (StencilFunc) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilFunc"), typeof(StencilFunc) ); glStencilOp = (StencilOp) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glStencilOp"), typeof(StencilOp) ); glCullFace = (CullFace) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glCullFace"), typeof(CullFace) ); glFrontFace = (FrontFace) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glFrontFace"), typeof(FrontFace) ); glPolygonMode = (PolygonMode) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glPolygonMode"), typeof(PolygonMode) ); glPolygonOffset = (PolygonOffset) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glPolygonOffset"), typeof(PolygonOffset) ); glGenTextures = (GenTextures) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGenTextures"), typeof(GenTextures) ); glDeleteTextures = (DeleteTextures) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDeleteTextures"), typeof(DeleteTextures) ); glBindTexture = (G_BindTexture) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBindTexture"), typeof(G_BindTexture) ); glTexImage2D = (TexImage2D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexImage2D"), typeof(TexImage2D) ); glTexSubImage2D = (TexSubImage2D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexSubImage2D"), typeof(TexSubImage2D) ); glCompressedTexImage2D = (CompressedTexImage2D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glCompressedTexImage2D"), typeof(CompressedTexImage2D) ); glCompressedTexSubImage2D = (CompressedTexSubImage2D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glCompressedTexSubImage2D"), typeof(CompressedTexSubImage2D) ); glTexImage3D = (TexImage3D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexImage3D"), typeof(TexImage3D) ); glTexSubImage3D = (TexSubImage3D) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexSubImage3D"), typeof(TexSubImage3D) ); glGetTexImage = (GetTexImage) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetTexImage"), typeof(GetTexImage) ); glTexParameteri = (TexParameteri) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexParameteri"), typeof(TexParameteri) ); glTexParameterf = (TexParameterf) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glTexParameterf"), typeof(TexParameterf) ); glActiveTexture = (ActiveTexture) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glActiveTexture"), typeof(ActiveTexture) ); glGetTexLevelParameteriv = (GetTexLevelParameteriv) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetTexLevelParameteriv"), typeof(GetTexLevelParameteriv) ); glPixelStorei = (PixelStorei) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glPixelStorei"), typeof(PixelStorei) ); glGenBuffers = (GenBuffers) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGenBuffers"), typeof(GenBuffers) ); glDeleteBuffers = (DeleteBuffers) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDeleteBuffers"), typeof(DeleteBuffers) ); glBindBuffer = (BindBuffer) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBindBuffer"), typeof(BindBuffer) ); glBufferData = (BufferData) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBufferData"), typeof(BufferData) ); glBufferSubData = (BufferSubData) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBufferSubData"), typeof(BufferSubData) ); glMapBuffer = (MapBuffer) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glMapBuffer"), typeof(MapBuffer) ); glUnmapBuffer = (UnmapBuffer) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glUnmapBuffer"), typeof(UnmapBuffer) ); glEnableVertexAttribArray = (EnableVertexAttribArray) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glEnableVertexAttribArray"), typeof(EnableVertexAttribArray) ); glDisableVertexAttribArray = (DisableVertexAttribArray) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDisableVertexAttribArray"), typeof(DisableVertexAttribArray) ); glVertexAttribPointer = (G_VertexAttribPointer) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glVertexAttribPointer"), typeof(G_VertexAttribPointer) ); glClearColor = (ClearColor) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glClearColor"), typeof(ClearColor) ); glClearDepth = (ClearDepth) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glClearDepth"), typeof(ClearDepth) ); glClearStencil = (ClearStencil) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glClearStencil"), typeof(ClearStencil) ); glClear = (G_Clear) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glClear"), typeof(G_Clear) ); glDrawBuffers = (DrawBuffers) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDrawBuffers"), typeof(DrawBuffers) ); glReadPixels = (ReadPixels) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glReadPixels"), typeof(ReadPixels) ); glDrawRangeElements = (DrawRangeElements) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDrawRangeElements"), typeof(DrawRangeElements) ); glDrawArrays = (DrawArrays) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDrawArrays"), typeof(DrawArrays) ); glGenQueries = (GenQueries) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGenQueries"), typeof(GenQueries) ); glDeleteQueries = (DeleteQueries) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDeleteQueries"), typeof(DeleteQueries) ); glBeginQuery = (BeginQuery) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBeginQuery"), typeof(BeginQuery) ); glEndQuery = (EndQuery) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glEndQuery"), typeof(EndQuery) ); glGetQueryObjectiv = (GetQueryObjectiv) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetQueryObjectiv"), typeof(GetQueryObjectiv) ); glCreateShader = (CreateShader) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glCreateShader"), typeof(CreateShader) ); glDeleteShader = (DeleteShader) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDeleteShader"), typeof(DeleteShader) ); glShaderSource = (ShaderSource) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glShaderSource"), typeof(ShaderSource) ); glCompileShader = (CompileShader) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glCompileShader"), typeof(CompileShader) ); glCreateProgram = (CreateProgram) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glCreateProgram"), typeof(CreateProgram) ); glDeleteProgram = (DeleteProgram) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDeleteProgram"), typeof(DeleteProgram) ); glAttachShader = (AttachShader) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glAttachShader"), typeof(AttachShader) ); glDetachShader = (DetachShader) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDetachShader"), typeof(DetachShader) ); glLinkProgram = (LinkProgram) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glLinkProgram"), typeof(LinkProgram) ); glUseProgram = (UseProgram) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glUseProgram"), typeof(UseProgram) ); glUniform1i = (Uniform1i) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glUniform1i"), typeof(Uniform1i) ); glUniform4fv = (Uniform4fv) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glUniform4fv"), typeof(Uniform4fv) ); glGetShaderiv = (GetShaderiv) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetShaderiv"), typeof(GetShaderiv) ); glGetProgramiv = (GetProgramiv) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetProgramiv"), typeof(GetProgramiv) ); glGetUniformLocation = (GetUniformLocation) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetUniformLocation"), typeof(GetUniformLocation) ); glGetAttribLocation = (GetAttribLocation) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetAttribLocation"), typeof(GetAttribLocation) ); glBindAttribLocation = (BindAttribLocation) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glBindAttribLocation"), typeof(BindAttribLocation) ); glIsShader = (IsShader) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glIsShader"), typeof(IsShader) ); glIsProgram = (IsProgram) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glIsProgram"), typeof(IsProgram) ); glGetShaderInfoLog = (GetShaderInfoLog) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetShaderInfoLog"), typeof(GetShaderInfoLog) ); glGetProgramInfoLog = (GetProgramInfoLog) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glGetProgramInfoLog"), typeof(GetProgramInfoLog) ); glFlush = (Flush) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glFlush"), typeof(Flush) ); } catch { throw new NoSuitableGraphicsDeviceException("OpenGL 2.1 support is required!"); } /* ARB_framebuffer_object. We're flexible, but not _that_ flexible. */ try { glGenFramebuffers = (GenFramebuffers) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glGenFramebuffers"), typeof(GenFramebuffers) ); glDeleteFramebuffers = (DeleteFramebuffers) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glDeleteFramebuffers"), typeof(DeleteFramebuffers) ); glBindFramebuffer = (G_BindFramebuffer) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glBindFramebuffer"), typeof(G_BindFramebuffer) ); glFramebufferTexture2D = (FramebufferTexture2D) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glFramebufferTexture2D"), typeof(FramebufferTexture2D) ); glFramebufferRenderbuffer = (FramebufferRenderbuffer) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glFramebufferRenderbuffer"), typeof(FramebufferRenderbuffer) ); #if !DISABLE_FAUXBACKBUFFER glBlitFramebuffer = (BlitFramebuffer) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glBlitFramebuffer"), typeof(BlitFramebuffer) ); #endif glGenRenderbuffers = (GenRenderbuffers) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glGenRenderbuffers"), typeof(GenRenderbuffers) ); glDeleteRenderbuffers = (DeleteRenderbuffers) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glDeleteRenderbuffers"), typeof(DeleteRenderbuffers) ); glBindRenderbuffer = (BindRenderbuffer) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glBindRenderbuffer"), typeof(BindRenderbuffer) ); glRenderbufferStorage = (RenderbufferStorage) Marshal.GetDelegateForFunctionPointer( TryGetFramebufferEP("glRenderbufferStorage"), typeof(RenderbufferStorage) ); } catch { throw new NoSuitableGraphicsDeviceException("OpenGL framebuffer support is required!"); } /* ARB_instanced_arrays/ARB_draw_instanced are almost optional. */ SupportsHardwareInstancing = true; try { glVertexAttribDivisor = (VertexAttribDivisor) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glVertexAttribDivisor"), typeof(VertexAttribDivisor) ); glDrawElementsInstanced = (DrawElementsInstanced) Marshal.GetDelegateForFunctionPointer( SDL.SDL_GL_GetProcAddress("glDrawElementsInstanced"), typeof(DrawElementsInstanced) ); } catch { SupportsHardwareInstancing = false; } #if DEBUG /* ARB_debug_output, for debug contexts */ IntPtr messageCallback = SDL.SDL_GL_GetProcAddress("glDebugMessageCallbackARB"); IntPtr messageControl = SDL.SDL_GL_GetProcAddress("glDebugMessageControlARB"); if (messageCallback == IntPtr.Zero || messageControl == IntPtr.Zero) { System.Console.WriteLine("ARB_debug_output not supported!"); } else { glDebugMessageCallbackARB = (DebugMessageCallback) Marshal.GetDelegateForFunctionPointer( messageCallback, typeof(DebugMessageCallback) ); glDebugMessageControlARB = (DebugMessageControl) Marshal.GetDelegateForFunctionPointer( messageControl, typeof(DebugMessageControl) ); glDebugMessageCallbackARB(DebugCall, IntPtr.Zero); glDebugMessageControlARB( GLenum.GL_DONT_CARE, GLenum.GL_DONT_CARE, GLenum.GL_DONT_CARE, 0, IntPtr.Zero, true ); glDebugMessageControlARB( GLenum.GL_DONT_CARE, GLenum.GL_DEBUG_TYPE_OTHER_ARB, GLenum.GL_DEBUG_SEVERITY_LOW_ARB, 0, IntPtr.Zero, false ); } /* GREMEDY_string_marker, for apitrace */ IntPtr stringMarkerCallback = SDL.SDL_GL_GetProcAddress("glStringMarkerGREMEDY"); if (stringMarkerCallback == IntPtr.Zero) { System.Console.WriteLine("GREMEDY_string_marker not supported!"); } else { glStringMarkerGREMEDY = (StringMarkerGREMEDY) Marshal.GetDelegateForFunctionPointer( stringMarkerCallback, typeof(StringMarkerGREMEDY) ); } #endif }
/// <summary> create and connect controllers. </summary> /// <param name="enable"> controls user interaction in view. </param> /// <param name="io"> current/size/search/enter/remove fields. </param> /// <param name="click"> add to eventhandlers, null to skip. </param> /// <param name="bg"> for sequential background execution. </param> /// <param name="nameModel"> one or more name/db model pairs. </param> public Switcher(Enable enable, IAccess[] io, SetClick[] click, WorkQueue bg, params object[] nameModel) : this(bg, nameModel) { Connect(enable, io, click); }