/// <summary> /// Get name of an image file. /// </summary> private string GetImageFileName(RunMode mode) { string path; if (mode == RunMode.Interactive) { var dialog = new Eto.Forms.OpenFileDialog(); string[] all = { ".bmp", ".gif", ".jpg", ".jpeg", ".png", ".tif", ".tiff" }; dialog.Filters.Add(new Eto.Forms.FileFilter("All image files", all)); dialog.Filters.Add(new Eto.Forms.FileFilter("Bitmap", ".bmp")); dialog.Filters.Add(new Eto.Forms.FileFilter("GIF", ".gif")); string[] jpeg = { ".jpg", ".jpe", ".jpeg" }; dialog.Filters.Add(new Eto.Forms.FileFilter("JPEG", jpeg)); dialog.Filters.Add(new Eto.Forms.FileFilter("PNG", ".png")); string[] tiff = { ".tif", ".tiff" }; dialog.Filters.Add(new Eto.Forms.FileFilter("TIFF", tiff)); var res = dialog.ShowDialog(RhinoEtoApp.MainWindow); if (res != Eto.Forms.DialogResult.Ok) { return(null); } path = dialog.FileName; } else { var gs = new GetString(); gs.SetCommandPrompt("Name of image file to open"); gs.Get(); if (gs.CommandResult() != Result.Success) { return(null); } path = gs.StringResult(); } if (!string.IsNullOrEmpty(path)) { path = path.Trim(); } if (string.IsNullOrEmpty(path)) { return(null); } if (!File.Exists(path)) { RhinoApp.WriteLine("The specified file cannot be found."); return(null); } return(path); }
private async void ButtonBrowser_OnClickAsync(object sender, RoutedEventArgs e) { FileExplorer fileExplorer = new FileExplorer(fileExplorerFilter, true); OpenFile = fileExplorer.Open(Environment.SpecialFolder.Desktop); if (fileExplorer.verificate) { isDataDirty = true; TextBoxPathToPhoto.Text = string.Empty; TextBoxPhotoName.Text = string.Empty; StackPanelPhotoContainer.Children.Clear(); foreach (string fileName in OpenFile.FileNames) { Image image = await CreateImage(fileName); StackPanel stack = new StackPanel(); Grid grid = await CreateGrid(GetString.OneStringFromPath(fileName)); stack.Children.Add(image); stack.Children.Add(grid); StackPanelPhotoContainer.Children.Add(stack); } TextBoxPathToPhoto.Text = await CreateString.StringManyPhotoName(OpenFile.FileNames); TextBoxPhotoName.Text = await CreateString.StringManyPhotoName(await GetString.StringListFromPathListTask(OpenFile.FileNames)); } }
public static Result SetActiveView(RhinoDoc doc) { // view and view names var active_view_name = doc.Views.ActiveView.ActiveViewport.Name; var non_active_views = doc.Views .Where(v => v.ActiveViewport.Name != active_view_name) .ToDictionary(v => v.ActiveViewport.Name, v => v); // get name of view to set active var gs = new GetString(); gs.SetCommandPrompt("Name of view to set active"); gs.AcceptNothing(true); gs.SetDefaultString(active_view_name); foreach (var view_name in non_active_views.Keys) gs.AddOption(view_name); var result = gs.Get(); if (gs.CommandResult() != Result.Success) return gs.CommandResult(); var selected_view_name = result == GetResult.Option ? gs.Option().EnglishName : gs.StringResult(); if (selected_view_name != active_view_name) if (non_active_views.ContainsKey(selected_view_name)) doc.Views.ActiveView = non_active_views[selected_view_name]; else RhinoApp.WriteLine("\"{0}\" is not a view name", selected_view_name); return Rhino.Commands.Result.Success; }
/// <summary> /// Show the mobile construction plane axes. /// </summary> private Result ShowOption(RhinoDoc doc, RhinoObject obj) { if (null == doc || null == obj) { return(Result.Failure); } var data = SampleCsMobilePlaneUserData.DataFromObject(obj); if (null == data) { RhinoApp.WriteLine("No mobile plane attached."); return(Result.Success); } var conduit = new SampleCsMobilePlaneConduit(data.Plane); doc.Views.Redraw(); var gs = new GetString(); gs.SetCommandPrompt("Press <Enter> when done."); gs.Get(); conduit.Enabled = false; doc.Views.Redraw(); return(Result.Success); }
protected Result AddOption() { var gs = new GetString(); gs.SetCommandPrompt("String to add"); gs.AcceptNothing(true); switch (gs.Get()) { case GetResult.String: break; case GetResult.Nothing: return(Result.Nothing); default: return(Result.Cancel); } var str = gs.StringResult().Trim(); if (string.IsNullOrEmpty(str)) { return(Result.Nothing); } var plugin = SampleCsUserDataPlugIn.Instance; if (plugin.StringDocumentDataTable.Add(str) < 0) { RhinoApp.WriteLine("Unable to add string."); } return(Result.Success); }
protected override async Task <UnitFactorData> getData(string id) { var systemOfUnitsId = GetString.Head(id); var unitId = GetString.Tail(id); return(await dbSet.SingleOrDefaultAsync(x => x.SystemOfUnitsId == systemOfUnitsId && x.UnitId == unitId)); }
private static string GetHidString(SafeFileHandle safeFileHandle, GetString getString, ILogger logger, [CallerMemberName] string callMemberName = null) { try { var pointerToBuffer = Marshal.AllocHGlobal(126); var isSuccess = getString(safeFileHandle, pointerToBuffer, 126); if (!isSuccess) { logger.LogWarning(Messages.ErrorMessagesCouldntGetHidString, "", nameof(GetHidString), callMemberName); } var text = Marshal.PtrToStringAuto(pointerToBuffer); Marshal.FreeHGlobal(pointerToBuffer); return(text); } catch (Exception ex) { logger.LogError(ex, Messages.ErrorMessagesCouldntGetHidString, ex.Message, nameof(GetHidString), callMemberName); return(null); } finally { //TODO: Shouldn't this pointer be released? //Marshal.Release(pointerToBuffer); } }
private static string GetHidString(SafeFileHandle safeFileHandle, GetString getString, ILogger logger, [CallerMemberName] string callMemberName = null) { try { var pointerToBuffer = Marshal.AllocHGlobal(126); var isSuccess = getString(safeFileHandle, pointerToBuffer, 126); if (!isSuccess) { logger?.Log($"Could not get Hid string. Caller: {callMemberName}", nameof(WindowsHidApiService), null, LogLevel.Warning); } var text = Marshal.PtrToStringAuto(pointerToBuffer); Marshal.FreeHGlobal(pointerToBuffer); return(text); } catch (Exception ex) { logger?.Log($"Could not get Hid string. Message: {ex.Message}", nameof(WindowsHidApiService), ex, LogLevel.Error); return(null); } finally { //TODO: Shouldn't this pointer be released? //Marshal.Release(pointerToBuffer); } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { const ObjectType filter = ObjectType.AnyObject; ObjRef objref; var rc = RhinoGet.GetOneObject("Select object", false, filter, out objref); if (rc != Result.Success || null == objref) { return(rc); } var obj = objref.Object(); if (null == obj) { return(Result.Failure); } var ud = obj.Attributes.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; if (null != ud) { var gs = new GetString(); gs.SetCommandPrompt("Modify object notes"); gs.GetLiteralString(); if (gs.CommandResult() != Result.Success) { return(gs.CommandResult()); } ud.Notes = gs.StringResult(); } return(Result.Success); }
//this is where the logic of the command is defined protected override Result RunCommand(RhinoDoc doc, RunMode mode) { string filterStr; using (GetString getter = new GetString()) { getter.AcceptString(true); getter.SetCommandPrompt("Enter the boolean filter statement (in quotes)"); if (getter.Get() != GetResult.String) { RhinoApp.WriteLine("Invalid Input for tag"); return(getter.CommandResult()); } filterStr = getter.StringResult(); } Stopwatch watch = new Stopwatch(); watch.Start(); List <Guid> filtered = TagUtil.Evaluate(filterStr, ref doc); Debug.WriteLine(watch.ElapsedMilliseconds, "Time"); watch.Stop(); doc.Objects.UnselectAll(); doc.Objects.Select(filtered); doc.Views.Redraw(); return(Result.Success); }
protected override async Task <ParticipantOfTrainingData> GetData(string participantOfTrainingId) { var clientId = GetString.Head(participantOfTrainingId); var timetableId = GetString.Tail(participantOfTrainingId); return(await dbSet.SingleOrDefaultAsync(x => x.ClientId == clientId && x.TimetableEntryId == timetableId)); }
protected override async Task <UnitTermData> GetData(string id) { var masterId = GetString.Head(id); var termId = GetString.Tail(id); return(await dbSet.SingleOrDefaultAsync(x => x.TermId == termId && x.MasterId == masterId)); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { #if DEBUG /* * setting the document as a globally accessible member, so that the converters can accsess and add * intermediate geometry to the document for examination */ RhinoV6PipeConverter.DebugUtil.Document = doc; #endif string pipeIdentifier; using (GetString getter = new GetString()) { getter.SetCommandPrompt("Enter the name/url for the pipe"); if (_prevPipeName != null) { getter.SetDefaultString(_prevPipeName); } if (getter.Get() != GetResult.String) { RhinoApp.WriteLine("Invalid Input"); return(getter.CommandResult()); } pipeIdentifier = getter.StringResult(); _prevPipeName = pipeIdentifier; } if (PipeDataUtil.IsValidUrl(pipeIdentifier)) { _pipe = new MyWebPipe(pipeIdentifier); } else { _pipe = new LocalNamedPipe(pipeIdentifier); } _pipe.SetEmitter(this); try { _pipe.Update(); } catch (Exception e) { Rhino.UI.Dialogs.ShowMessage(e.Message, "Error"); } if (_objectsReceived.Count > 0) { DeletePulledObjects(pipeIdentifier, ref doc); } List <Guid> received = new List <Guid>(); foreach (var geom in _objectsReceived) { Guid id = doc.Objects.Add(geom); received.Add(id); } doc.Views.Redraw(); SavePulledObjects(pipeIdentifier, received, ref doc); return(Result.Success); }
public static Result ReplaceHatchPattern(RhinoDoc doc) { ObjRef[] obj_refs; var rc = RhinoGet.GetMultipleObjects("Select hatches to replace", false, ObjectType.Hatch, out obj_refs); if (rc != Result.Success || obj_refs == null) return rc; var gs = new GetString(); gs.SetCommandPrompt("Name of replacement hatch pattern"); gs.AcceptNothing(false); gs.Get(); if (gs.CommandResult() != Result.Success) return gs.CommandResult(); var hatch_name = gs.StringResult(); var pattern_index = doc.HatchPatterns.Find(hatch_name, true); if (pattern_index < 0) { RhinoApp.WriteLine("The hatch pattern \"{0}\" not found in the document.", hatch_name); return Result.Nothing; } foreach (var obj_ref in obj_refs) { var hatch_object = obj_ref.Object() as HatchObject; if (hatch_object.HatchGeometry.PatternIndex != pattern_index) { hatch_object.HatchGeometry.PatternIndex = pattern_index; hatch_object.CommitChanges(); } } doc.Views.Redraw(); return Result.Success; }
protected override void setId(MeasureTermData d, string id) { var masterid = GetString.Head(id); var termid = GetString.Tail(id); d.MasterId = masterid; d.TermId = termid; }
protected override void SetId(ParticipantOfTrainingData d, string id) { var clientId = GetString.Head(id); var timetableEntryId = GetString.Tail(id); d.ClientId = clientId; d.TimetableEntryId = timetableEntryId; }
[TestMethod] public void HeadTest() { Assert.AreEqual("a", GetString.Head("a.b.c")); Assert.AreEqual("", GetString.Head(null)); Assert.AreEqual("", GetString.Head(" ")); Assert.AreEqual("abc", GetString.Head("abc")); Assert.AreEqual("a.b", GetString.Head("a.b,c", ',')); }
public void TailTest() { Assert.AreEqual("b.c", GetString.Tail("a.b.c")); Assert.AreEqual("", GetString.Tail(null)); Assert.AreEqual("", GetString.Tail(" ")); Assert.AreEqual("abc", GetString.Tail("abc")); Assert.AreEqual("c", GetString.Tail("a.b,c", ',')); }
protected override void SetId(UnitTermData d, string id) { var masterId = GetString.Head(id); var termId = GetString.Tail(id); d.MasterId = masterId; d.TermId = termId; }
protected override void setId(UnitFactorData d, string id) { var systemOfUnitsId = GetString.Head(id); var unitId = GetString.Tail(id); d.SystemOfUnitsId = systemOfUnitsId; d.UnitId = unitId; }
/// <summary> /// Ковариантность: тип возвращаемого значения метода Method1 — унаследованный тип от типа возвращаемого значения /// делегата /// Контравариантность: тип входного значения метода Method1 — базовый тип для типа входного значения делегата /// </summary> private static void Main(string[] args) { var func = new GetString(Method1); var result = func(new MyClass2()); Console.WriteLine(result); }
// ------------------------------------------------------------------- // InitializeParameters // ------------------------------------------------------------------- public void InitializeParameters(object[] value, List <object> others, Type type, GetString getString) { Value = value; Others = others; DialogKind = type; MethodString = getString; listBox1.Items[0] = MethodString(Value); }
private static string GetHidString(SafeFileHandle safeFileHandle, GetString getString) { var pointerToBuffer = Marshal.AllocHGlobal(126); var isSuccess = getString(safeFileHandle, pointerToBuffer, 126); Marshal.FreeHGlobal(pointerToBuffer); WindowsDeviceBase.HandleError(isSuccess, "Could not get Hid string"); return(Marshal.PtrToStringUni(pointerToBuffer)); }
static void Main(string[] args) { //Lets see how we can make use of the GetString delegate GetString getString = new GetString(DoGettingString); //So we created a new variable, again not much different than saying "Person dude = new Person()"; only in this case the //constructor took a method that returned a string - that is because we specified our delegate returns a string. // - Lets see what happens when we use this delegate - Console.WriteLine(getString()); //Look how it gets called! Just like any other method. Console.ReadKey(); // //OK - that is a wrap on the introduction to delegate as they existed in the days of C# 1 / 1.1 ///////////////////////////////////////////////////////////////////////////////////////////////// GetLen<string, int> getLength; //2.0 also introduced us to some predefined delegates //Action - when you are returning void //Func - when you want to return a value //Predicate - when you want to return a bool // (Notice you see the word predicate all over linq statements, a lot of times the extension methods will take a predicate) //Here is another example of how we could have declared getLength - For fun, uncomment this then comment out lines 18 and 34. //Func<string, int> getLength; //As you can see - we still initialize the delegate by passing a method that matches the in and out parameters. getLength = new GetLen<string, int>(LenghtOfTheString); //C# introduced us to inline delegates. This isn't a lamda expression and it isn't something you se very often today //it was quickly eclipsed by lambdas. getLength = delegate(string word) { return word.Length; }; // There is the world as we understood it in C# 2.0 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // C# 3.0 introduced lambdas //Turn the delegate into a lambda expresion // In the case below we are telling the compiler what the input type is (string) but normally we don't need to do this // it just makes it a little easier to see what is happening. getLength = (string x) => { return x.Length; }; //Use implicitly typed parameters getLength = (x) => { return x.Length; }; //now get rid of the return statement cause the body of the lamba is a //single expression so it knows that we must want to return whatever the result //is - notice the {} are dropped out... getLength = (x) => x.Length; //finally drop out the parentheses getLength = x => x.Length; //It gets more confusing when you start calling methods you have created. //the following statement would look like this as a delegate... // getLength = delegate(string x) { return retunRandomNumber(); }; //In this case we supply the string as an arg however it doesn't get used for anything // - of course we still have to supply it cause that is how the delegate is defined. getLength = x => retunRandomNumber(); Console.WriteLine(getLength("Hi there...")); Console.ReadKey(); //SEE http://msdn.microsoft.com/en-us/library/bb397687.aspx }
public static void Method1(GetString f, IFoo foo) { Console.WriteLine("Method1"); Console.WriteLine("foo: " + foo.Invoke1("clr")); Console.WriteLine("GetString: " + f()); Console.WriteLine("GetString: " + f()); Console.WriteLine("GetString: " + f()); }
/// <summary> /// Called by Rhino when the user wants to run the command. /// </summary> protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var server_host_name = RockfishClientPlugIn.ServerHostName(); for (var i = 0; i < 3; i++) { var gs = new GetString(); gs.SetCommandPrompt("Server host name or IP address"); gs.SetDefaultString(server_host_name); gs.Get(); if (gs.CommandResult() != Result.Success) { return(gs.CommandResult()); } var name = gs.StringResult().Trim(); if (string.IsNullOrEmpty(name)) { RhinoApp.WriteLine("Server host name or IP address cannot be empty."); continue; } var host_name = RockfishClientPlugIn.LookupHostName(name); if (string.IsNullOrEmpty(host_name)) { RhinoApp.WriteLine("Unable to resolve host name \"{0}\".", host_name); continue; } var found = false; try { using (var channel = new RockfishClientChannel()) { channel.Create(); var echo = channel.Echo("Echo"); found = !string.IsNullOrEmpty(echo); } } catch { // ignored } if (!found) { RhinoApp.WriteLine("Unable to connect to server \"{0}\".", host_name); continue; } RockfishClientPlugIn.ThePlugIn.SetServerHostName(host_name); break; } return(Result.Success); }
public static bool CheckStringSDL() { _getString = (GetString)Marshal.GetDelegateForFunctionPointer(SDL.SDL_GL_GetProcAddress("glGetString"), typeof(GetString)); var str = GetString(GL.GL_VERSION); FLLog.Info("GL", "Version String: " + GetString(GL.GL_VERSION)); var major = int.Parse(str[0].ToString()); return(major >= 3); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { string pipeIdentifier; using (GetString getter = new GetString()) { getter.SetCommandPrompt("Enter the name/url for the pipe"); if (_prevPipeName != null) { getter.SetDefaultString(_prevPipeName); } if (getter.Get() != GetResult.String) { RhinoApp.WriteLine("Invalid Input"); return(getter.CommandResult()); } pipeIdentifier = getter.StringResult(); _prevPipeName = pipeIdentifier; } if (PipeDataUtil.IsValidUrl(pipeIdentifier)) { _pipe = new MyWebPipe(pipeIdentifier); } else { _pipe = new LocalNamedPipe(pipeIdentifier); } _pipe.SetEmitter(this); try { _pipe.Update(); } catch (Exception e) { Rhino.UI.Dialogs.ShowMessageBox(e.Message, "Error"); } if (_objectsReceived.Count > 0) { DeletePulledObjects(pipeIdentifier, ref doc); } List <Guid> received = new List <Guid>(); foreach (var geom in _objectsReceived) { Guid id = doc.Objects.Add(geom); received.Add(id); } doc.Views.Redraw(); SavePulledObjects(pipeIdentifier, received, ref doc); return(Result.Success); }
static void Main(string[] args) { //Thread - sequence of execution in parallel with others computer`s tasks // - it is required to identifu where to start that sequence, supply details of method in which it can start // - constructor of the Thread class takes a parameter that defines the method to be invoked by the thread //Delegates are .NET variant of addresses to methods for passing methods around to other methods instead of data // -type-safe classes that define the return types and type of parameters // - delegate class can contain refferences to multiple methods //Declaring delegates - telling the compiler what kind of method a delegate of that type will represent //First - declaring delegates, then - creating 1 or more instances of that delegate (compiler creates class that represents the delegate) //Can be defined inside a class, ouside a class, in a namespace as a top-level object int x = 40; //Instanciating a delegate of type GetString and initializes it so it refers to the ToString methodof the int varibale x GetString firstStringMethod = new GetString(x.ToString); // or GetString firstStringMethod = x.ToString; Console.WriteLine($"String is {firstStringMethod()}"); // it is equivalent to Console.WriteLine($"String is {x.ToString()}"); //method must match the signature with which delegate was originally definied var balance = new Currency(34, 50); //firstStringMethod references to an instance method firstStringMethod = balance.ToString; Console.WriteLine($"String is {firstStringMethod()}"); //firstStringMethod references to an static method firstStringMethod = new GetString(Currency.GetCurrencyUnit); Console.WriteLine($"String is {firstStringMethod()}"); Console.WriteLine("_______________________________________"); Console.WriteLine(); DoubleOp[] mathOperations = { MathOperations.MultiplyByTwo, MathOperations.Square }; for (int i = 0; i < mathOperations.Length; i++) { Console.WriteLine($"Using operations[{i}]:"); ProcessAndDisplayNumber(mathOperations[i], 2.01); ProcessAndDisplayNumber(mathOperations[i], 7.25); ProcessAndDisplayNumber(mathOperations[i], 1.113); Console.WriteLine(); } OwnDoubleDelegate cube = MathOperations.Cube; var cubeResult = cube(2); Console.WriteLine($"Value is 2, cube is {cubeResult}"); }
private static void addHead(Strings l, string s, char separactor = ' ') { if (string.IsNullOrWhiteSpace(s)) { return; } var head = GetString.Head(s, separactor); l.Add(head); addHead(l, s.Replace(head, string.Empty).Trim()); }
/// <summary> /// 连接服务器 /// </summary> /// <param name="message">信息</param> /// <param name="ip">服务器IP</param> /// <param name="port">服务器端口</param> /// <param name="isSSL">是否建立了SSL</param> public void ConnectToServer(string message, string ip, int port) { connectParam.IsConnect = false; connectParam.tcpClient = new TcpClient(); connectParam.Msg = message; //获得Key connectParam.RandomKey = GetString.GetRandomCode(GetString.Code.StrAndNum, 8); connectParam.tcpClient.BeginConnect(ip, port, new AsyncCallback(ConnectCallBackF), connectParam); //异步连接 }
/// <summary> Создание цепочки </summary> private static void Example1() { GetString chain = null; chain += Method1; chain += Method2; chain += new Program().Method3; chain += new Program().Method4; chain(1); }
public string Get(GetString getString) { string str; switch (getString) { case GetString.Estatus: str = GetStatus(); break; default: str = ""; break; } return(str); }
public void Run() { getDele = Say; //0.1同步调用 string strResult = getDele.Invoke("张三"); //0.2异步调用,callback是AsyncCallback委托,参数为IAsyncResult的void类型方法 //注意:使用BeginInvoke方法异步调用的时候,委托本身以及回调函数都是线程池线程执行的方法 IAsyncResult re = getDele.BeginInvoke("李四", SayCallback, "干嘛用的呢");///第三个参数是传给回调函数用的 //0.3指定等待异步操作完成 re.AsyncWaitHandle.WaitOne(); ///使用EndInvoke等待操作完成:注意,回调函数完全有可能没有完成 string result = getDele.EndInvoke(re); Console.WriteLine("结果为:"+result); Console.ReadKey(); }
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 }
public CustomDecoder(Encoding encoding, GetString getString) : base(encoding) { _getString = getString; }
protected string RetString(GetString dlg, int NeededLength) { string Retme = ""; dlg.Text = "Password must be longer than " + NeededLength + " chars"; if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Password.Length > NeededLength) { Retme = dlg.Password; } else { MessageBox.Show("Password must be longer than " + NeededLength + " chars"); dlg.ClearPass(); Retme = RetString(dlg); } } return Retme; }
protected void UsePasswordInsteadOfKeys() { try { string password = ""; int pksize = 0, pvsize = 0; GetString dlg = new GetString(); password = RetString(dlg, 20); myAES = new SimplerAES((SimplerAES.Algo)AlgorithmChoice); pksize = (myAES.kSize) / 8; pvsize = (myAES.vSize) / 8; var key = new Rfc2898DeriveBytes(password, Encoding.ASCII.GetBytes(myAES.CallSalt)); myAES.key = key.GetBytes(pksize); myAES.vector = key.GetBytes(pvsize); myAES = new SimplerAES((SimplerAES.Algo)AlgorithmChoice, myAES.key, myAES.vector); InitArrayBoxes(); password.Remove(0); pksize = 0; pvsize = 0; } catch(Exception Xedout){ } }
/* 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 }
public TestMetadataStringDecoder(Encoding encoding, GetString getString) : base(encoding) { _getString = getString; }
private void GoGoGadget_Click(object sender, EventArgs e) { RTB.Clear(); if (FileMode_checkBox.Checked == false) { if (Mode == "Encrypt") { RTB.AppendText(myAES.Encrypt(InputBox.Text.ToString())); } else if (Mode == "Decrypt") { RTB.AppendText(myAES.Decrypt(InputBox.Text.ToString())); } else { MessageBox.Show("Must Pick a Mode, Encrypt or Decrypt"); } } else { OpenFileDialog myFile = new OpenFileDialog(); GetString Dlg = new GetString(); if ((Mode == "Encrypt") || (Mode == "Decrypt")) { SimplerAES Default = new SimplerAES(); string pass = RetString(Dlg, 20); byte[] Cvted = Encoding.ASCII.GetBytes(Default.Encrypt(pass)); string file = GetFileName(myFile); SimplerAES FileCrypto = new SimplerAES(Cvted, Cvted); RTB.Clear(); try { RTB.AppendText(Mode + (FileCrypto.FileOps(file, Mode, pass) ? " success" : " failed")); } catch (Exception Error) { RTB.AppendText("Error duing file decryption, stack dump as follows:\n" + Error.Message); } } else MessageBox.Show("Must Pick a Mode, Encrypt or Decrypt"); } }
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 }
protected string PromptForBCryptHashGeneration() { string Original="",Retme = ""; GetString dlg = new GetString(); dlg.Text = "Enter Password >20 chars"; dlg.ShowDialog(); if (dlg.DialogResult == DialogResult.OK) { if (dlg.Password.Length > 20) { Retme = dlg.Password; } else { MessageBox.Show("Password must be longer than 20 chars"); dlg.ClearPass(); Retme = RetString(dlg); } string salt = BCrypt.Net.BCrypt.GenerateSalt(12);//4096 iterations Original = Retme; Retme = BCrypt.Net.BCrypt.HashPassword(Retme, salt); bool Check = BCrypt.Net.BCrypt.Verify(Original, Retme); Retme = Retme.TrimStart("$2a$12$".ToArray()); if (Check == false) throw new Exception("BCrypt: original string failed verification check against hash."); } return Retme; }