private void button1_Click(object sender, RoutedEventArgs e) { CreateProgram winTool = new CreateProgram(trener); winTool.Owner = this; winTool.Show(); addd.Visibility = Visibility.Hidden; }
//------------------------------------------------------------------------------ //This method shows the dialog on the screen //------------------------------------------------------------------------------ public NXOpen.UIStyler.DialogResponse Show() { try { Part workPart = theSession.Parts.Work; if (!theSession.ApplicationName.Equals("UG_APP_MANUFACTURING", StringComparison.CurrentCultureIgnoreCase)) { theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "请切换到加工模块"); return(0); } NXOpen.CAM.NCGroup parent = (NXOpen.CAM.NCGroup)workPart.CAMSetup.CAMGroupCollection.FindObject("AAA"); program = new CreateProgram(parent); theDialog.Show(); } catch (Exception ex) { //---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return(0); }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.ShowDialog(); string mensaje = ""; bool required = true; Dictionary <string, string[]> SetsVar = new Dictionary <string, string[]>(); Regex regex = new Regex("([\r\n|\n|\t| ]*[A-Z]+[ ]*[=][ ]*(((['][A-Z|0-9|a-z|_]['])|(CHR[(][0-9]+[)]))([\\.][\\.])?[+]?)+[ |\r\n|\n|\t]*)*"); Regex tokens = new Regex("([\r\n|\n|\t| ]*TOKEN[\t| ]*[0-9]+[\t| ]*[=][\t| ]*((([(|\\{]?[A-Z|a-z|0-9| ]+[()]?[)|\\}]?)|(['].[']))+[\\*|\\+|\\?|\\|]*)+[ |\r\n|\n|\t]*)*"); Regex actions = new Regex("((RESERVADAS|[A-Z]+)[(][)][ ]*[\t]*[\r\n|\n| ]*([{][\r\n|\n| ]*([\t]*[ ]*[0-9]+[ ]*[=][ ]*(['][A-Z]+['])[\r\n|\n| ]*)+[\r\n|\n| ]*[}][\r\n|\n| ]*)*)"); Regex Error = new Regex("([\r\n|\n|\t| ]*ERROR[ ]*[=][ ]*[0-9]+[\r\n|\n|\t| ]*)*"); Dictionary <string, string> TokensDic = new Dictionary <string, string>(); Dictionary <string, int> Precedencias = new Dictionary <string, int>(); Precedencias.Add("*", 3); Precedencias.Add("+", 3); Precedencias.Add("?", 3); Precedencias.Add(".", 2); Precedencias.Add("|", 1); if (openFile.FileName != "") { using (var file = new FileStream(openFile.FileName, FileMode.Open)) { using (var reader = new StreamReader(file)) { string Texto = reader.ReadToEnd(); if (Regex.IsMatch(Texto, "SETS")) { string inbetween = Between(Texto, "SETS", "TOKENS"); var matches = regex.Match(inbetween); if (matches.Value.CompareTo("") != 0) { var aux = matches.Value.Replace("\r\n", string.Empty); if (aux.EndsWith("..")) { mensaje += "Gramatica de los SETS ERRONEA"; required = false; } else if (aux.EndsWith("+")) { mensaje += "Gramatica de los SETS ERRONEA"; required = false; } else { mensaje += "Gramatica de los SETS Aceptada ,"; string[] stringSeparators = new string[] { "\r\n" }; string[] lines = inbetween.Split(stringSeparators, StringSplitOptions.None); for (int i = 0; i < lines.Length; i++) { lines[i] = lines[i].Trim('\t'); } foreach (var item in lines) { var itemreplaced = item.Replace(" ", string.Empty); if (itemreplaced == "") { if (itemreplaced != "") { var auxArray = item.Split('='); var Variable = auxArray[0].Trim(new Char[] { ' ', '\t' }); var Valor = auxArray[1].Trim(new Char[] { ' ', '\t' }); string[] auxValor; if (Valor.Contains("+")) { auxValor = Valor.Split('+'); } else { auxValor = new string[] { Valor }; } SetsVar.Add(Variable, auxValor); } } else { if (item != "") { var auxArray = item.Split('='); var Variable = auxArray[0].Trim(new Char[] { ' ', '\t' }); var Valor = auxArray[1].Trim(new Char[] { ' ', '\t' }); string[] auxValor; if (Valor.Contains("+")) { auxValor = Valor.Split('+'); } else { auxValor = new string[] { Valor }; } SetsVar.Add(Variable, auxValor); } } } } } else { mensaje += "Gramatica de los SETS ERRONEA"; required = false; } } else { mensaje += "No se encontro sets, "; } if (Regex.IsMatch(Texto, "TOKENS") && required == true) { string inbetween = Between(Texto, "TOKENS", "ACTIONS"); var matches = tokens.Match(inbetween); var aux = matches.Value.Replace("\r\n", string.Empty); if (matches.Value.CompareTo("") != 0) { var lmao = aux.ToCharArray(); string aux2 = ""; aux = aux.Trim(); if (!aux.EndsWith("'") && !aux.EndsWith("}") && !aux.EndsWith("*") && !aux.EndsWith("?") && !aux.EndsWith("+") && !aux.EndsWith(")")) { mensaje = "Gramatica de los TOKENS Erronea"; required = false; } for (int i = 0; i < lmao.Count(); i++) { var cha = Convert.ToChar("'"); if (lmao[i] == '(' && lmao[i + 1] != cha) { bool salida = true; while (salida) { if (i < lmao.Count()) { if (lmao[i] == ')') { salida = false; required = true; } else if (aux2.Contains("TOKEN")) { salida = false; required = false; i = lmao.Count() - 1; } aux2 += lmao[i]; } else { salida = false; } i++; } } } if (required == true) { mensaje += "Gramatica de los TOKENS Aceptada ,"; string[] stringSeparators = new string[] { "\r\n", "\n" }; string[] lines = inbetween.Split(stringSeparators, StringSplitOptions.None); string auxString = ""; for (int i = 0; i < lines.Length; i++) { lines[i] = lines[i].Replace("\t", string.Empty); } foreach (var item in lines) { if (item != "") { if (item.Contains("=")) { var auxArray = item.Split(new Char[] { '=' }, 2); if (auxArray[0].Contains("TOKEN")) { var Variable = auxArray[0].Trim(new Char[] { ' ', '\t', '\n' }); var Valor = auxArray[1].Trim(new Char[] { ' ', '\t', '\n' }); if (Valor.Contains("{ RESERVADAS() }")) { Valor = Valor.Replace("{ RESERVADAS() }", ""); } else if (Valor.Contains("{ VALUES() }")) { Valor = Valor.Replace("{ VALUES() }", ""); } TokensDic.Add(Valor, auxArray[0]); auxString += Valor; auxString += "|"; } } } } if (auxString.EndsWith("|")) { auxString = auxString.Remove(auxString.Length - 1); auxString = auxString.Trim(new Char[] { ' ', '\t' }); } auxString = "(" + auxString + ")#"; ExpressionTree tokensExpression = new ExpressionTree(); var TokensTreeWithFirstAndLast = tokensExpression.FirstStep(auxString); var asd = tokensExpression.GetSimbols(); var TablaFollows = tokensExpression.GetFollows(); var TablaTransiciones = tokensExpression.Tabla(); foreach (var item in asd) { if (!item.Contains("'") && item != "#") { if (!SetsVar.ContainsKey(item)) { mensaje = "Gramatica de los TOKENS Erronea"; required = false; break; } } } var Reservadas = Between(Texto, "ACTIONS", "ERROR"); string[] separadores = new string[] { "\r\n", "\n" }; string[] Lineas = Reservadas.Split(stringSeparators, StringSplitOptions.None); for (int i = 0; i < lines.Length; i++) { lines[i] = lines[i].Replace("\t", string.Empty); } Dictionary <string, string> ReservadasP = new Dictionary <string, string>(); foreach (var item in Lineas) { if (!item.Equals("")) { if (!item.Equals("{") && !item.Equals("}")) { if (item.Contains("=")) { var auxSplit = item.Split('='); auxSplit[1] = auxSplit[1].Trim(new Char[] { ' ', '\t', '\'' }); ReservadasP.Add(auxSplit[1], auxSplit[0]); } } } } Dictionary <string, string> TokensCompare = new Dictionary <string, string>(); foreach (var item in TokensDic) { string auxTokens = ""; var auxArray = item.Key.ToCharArray(); for (int i = 0; i < auxArray.Length; i++) { if (auxArray[i].Equals('\'')) { if (auxArray[i + 2].Equals('\'')) { if (auxArray[i + 1].CompareTo('"') == 0) { auxTokens += '\\'; } auxTokens += auxArray[i + 1]; i += 2; } } else { auxTokens += auxArray[i]; } } TokensCompare.Add(auxTokens, item.Value); } FillGridFollows(TablaFollows); FillGridViewRecursive(TokensTreeWithFirstAndLast); FillGridViewTablaTransiciones(tokensExpression.GetSimbols(), TablaTransiciones); CreateProgram ejecutable = new CreateProgram(); ejecutable.CrearPrograma(TablaTransiciones, SetsVar, TablaFollows, ReservadasP, TokensCompare); } else { mensaje = "Gramatica de los TOKENS Erronea"; } } else { mensaje = "Gramatica de los TOKENS Erronea"; required = false; } } else if (required == true) { mensaje = "No se encontro TOKENS "; required = false; } if (Regex.IsMatch(Texto, "ACTIONS") && required == true) { string inbetween = Between(Texto, "ACTIONS", "ERROR"); var matches = actions.Match(inbetween); if (matches.Value.CompareTo("") != 0) { if (matches.Value.Contains("RESERVADAS()")) { mensaje += "Gramatica de las ACTIONS Aceptada ,"; } else { mensaje = "Gramatica de las ACTIONS ERRONEA, no contiene RESERVADAS ()"; required = false; } } else { mensaje = "Gramatica de las ACTIONS ERRONEA"; required = false; } } else if (required == true) { mensaje = "No se encontro ACTIONS "; required = false; } if (Regex.IsMatch(Texto, "ERROR") && required == true) { string after = After(Texto, "}"); var matches = Error.Match(after); if (matches.Value.CompareTo("") != 0) { mensaje += "Gramatica de los ERRORES Aceptada."; } else { mensaje = "Gramatica de los ERRRORES ERRONEA"; } } else if (required == true) { mensaje = "No se encontro ERRORES "; } MensajeGramatica.Text = mensaje; } } } }
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 }
public static void InitGL_2_0(OpenGLContext ctx) { glBlendEquationSeparate = ctx.GetProc<BlendEquationSeparate>("glBlendEquationSeparate"); glDrawBuffers = ctx.GetProc<DrawBuffers>("glDrawBuffers"); glStencilOpSeparate = ctx.GetProc<StencilOpSeparate>("glStencilOpSeparate"); glStencilFuncSeparate = ctx.GetProc<StencilFuncSeparate>("glStencilFuncSeparate"); glStencilMaskSeparate = ctx.GetProc<StencilMaskSeparate>("glStencilMaskSeparate"); glAttachShader = ctx.GetProc<AttachShader>("glAttachShader"); glBindAttribLocation = ctx.GetProc<BindAttribLocation>("glBindAttribLocation"); glCompileShader = ctx.GetProc<CompileShader>("glCompileShader"); glCreateProgram = ctx.GetProc<CreateProgram>("glCreateProgram"); glCreateShader = ctx.GetProc<CreateShader>("glCreateShader"); glDeleteProgram = ctx.GetProc<DeleteProgram>("glDeleteProgram"); glDeleteShader = ctx.GetProc<DeleteShader>("glDeleteShader"); glDetachShader = ctx.GetProc<DetachShader>("glDetachShader"); glDisableVertexAttribArray = ctx.GetProc<DisableVertexAttribArray>("glDisableVertexAttribArray"); glEnableVertexAttribArray = ctx.GetProc<EnableVertexAttribArray>("glEnableVertexAttribArray"); glGetActiveAttrib = ctx.GetProc<GetActiveAttrib>("glGetActiveAttrib"); glGetActiveUniform = ctx.GetProc<GetActiveUniform>("glGetActiveUniform"); glGetAttachedShaders = ctx.GetProc<GetAttachedShaders>("glGetAttachedShaders"); glGetAttribLocation = ctx.GetProc<GetAttribLocation>("glGetAttribLocation"); glGetProgramiv = ctx.GetProc<GetProgramiv>("glGetProgramiv"); glGetProgramInfoLog = ctx.GetProc<GetProgramInfoLog>("glGetProgramInfoLog"); glGetShaderiv = ctx.GetProc<GetShaderiv>("glGetShaderiv"); glGetShaderInfoLog = ctx.GetProc<GetShaderInfoLog>("glGetShaderInfoLog"); glGetShaderSource = ctx.GetProc<GetShaderSource>("glGetShaderSource"); glGetUniformLocation = ctx.GetProc<GetUniformLocation>("glGetUniformLocation"); glGetUniformfv = ctx.GetProc<GetUniformfv>("glGetUniformfv"); glGetUniformiv = ctx.GetProc<GetUniformiv>("glGetUniformiv"); glGetVertexAttribdv = ctx.GetProc<GetVertexAttribdv>("glGetVertexAttribdv"); glGetVertexAttribfv = ctx.GetProc<GetVertexAttribfv>("glGetVertexAttribfv"); glGetVertexAttribiv = ctx.GetProc<GetVertexAttribiv>("glGetVertexAttribiv"); glGetVertexAttribPointerv = ctx.GetProc<GetVertexAttribPointerv>("glGetVertexAttribPointerv"); glIsProgram = ctx.GetProc<IsProgram>("glIsProgram"); glIsShader = ctx.GetProc<IsShader>("glIsShader"); glLinkProgram = ctx.GetProc<LinkProgram>("glLinkProgram"); glShaderSource = ctx.GetProc<ShaderSource>("glShaderSource"); glUseProgram = ctx.GetProc<UseProgram>("glUseProgram"); glUniform1f = ctx.GetProc<Uniform1f>("glUniform1f"); glUniform2f = ctx.GetProc<Uniform2f>("glUniform2f"); glUniform3f = ctx.GetProc<Uniform3f>("glUniform3f"); glUniform4f = ctx.GetProc<Uniform4f>("glUniform4f"); glUniform1i = ctx.GetProc<Uniform1i>("glUniform1i"); glUniform2i = ctx.GetProc<Uniform2i>("glUniform2i"); glUniform3i = ctx.GetProc<Uniform3i>("glUniform3i"); glUniform4i = ctx.GetProc<Uniform4i>("glUniform4i"); glUniform1fv = ctx.GetProc<Uniform1fv>("glUniform1fv"); glUniform2fv = ctx.GetProc<Uniform2fv>("glUniform2fv"); glUniform3fv = ctx.GetProc<Uniform3fv>("glUniform3fv"); glUniform4fv = ctx.GetProc<Uniform4fv>("glUniform4fv"); glUniform1iv = ctx.GetProc<Uniform1iv>("glUniform1iv"); glUniform2iv = ctx.GetProc<Uniform2iv>("glUniform2iv"); glUniform3iv = ctx.GetProc<Uniform3iv>("glUniform3iv"); glUniform4iv = ctx.GetProc<Uniform4iv>("glUniform4iv"); glUniformMatrix2fv = ctx.GetProc<UniformMatrix2fv>("glUniformMatrix2fv"); glUniformMatrix3fv = ctx.GetProc<UniformMatrix3fv>("glUniformMatrix3fv"); glUniformMatrix4fv = ctx.GetProc<UniformMatrix4fv>("glUniformMatrix4fv"); glValidateProgram = ctx.GetProc<ValidateProgram>("glValidateProgram"); glVertexAttrib1d = ctx.GetProc<VertexAttrib1d>("glVertexAttrib1d"); glVertexAttrib1dv = ctx.GetProc<VertexAttrib1dv>("glVertexAttrib1dv"); glVertexAttrib1f = ctx.GetProc<VertexAttrib1f>("glVertexAttrib1f"); glVertexAttrib1fv = ctx.GetProc<VertexAttrib1fv>("glVertexAttrib1fv"); glVertexAttrib1s = ctx.GetProc<VertexAttrib1s>("glVertexAttrib1s"); glVertexAttrib1sv = ctx.GetProc<VertexAttrib1sv>("glVertexAttrib1sv"); glVertexAttrib2d = ctx.GetProc<VertexAttrib2d>("glVertexAttrib2d"); glVertexAttrib2dv = ctx.GetProc<VertexAttrib2dv>("glVertexAttrib2dv"); glVertexAttrib2f = ctx.GetProc<VertexAttrib2f>("glVertexAttrib2f"); glVertexAttrib2fv = ctx.GetProc<VertexAttrib2fv>("glVertexAttrib2fv"); glVertexAttrib2s = ctx.GetProc<VertexAttrib2s>("glVertexAttrib2s"); glVertexAttrib2sv = ctx.GetProc<VertexAttrib2sv>("glVertexAttrib2sv"); glVertexAttrib3d = ctx.GetProc<VertexAttrib3d>("glVertexAttrib3d"); glVertexAttrib3dv = ctx.GetProc<VertexAttrib3dv>("glVertexAttrib3dv"); glVertexAttrib3f = ctx.GetProc<VertexAttrib3f>("glVertexAttrib3f"); glVertexAttrib3fv = ctx.GetProc<VertexAttrib3fv>("glVertexAttrib3fv"); glVertexAttrib3s = ctx.GetProc<VertexAttrib3s>("glVertexAttrib3s"); glVertexAttrib3sv = ctx.GetProc<VertexAttrib3sv>("glVertexAttrib3sv"); glVertexAttrib4Nbv = ctx.GetProc<VertexAttrib4Nbv>("glVertexAttrib4Nbv"); glVertexAttrib4Niv = ctx.GetProc<VertexAttrib4Niv>("glVertexAttrib4Niv"); glVertexAttrib4Nsv = ctx.GetProc<VertexAttrib4Nsv>("glVertexAttrib4Nsv"); glVertexAttrib4Nub = ctx.GetProc<VertexAttrib4Nub>("glVertexAttrib4Nub"); glVertexAttrib4Nubv = ctx.GetProc<VertexAttrib4Nubv>("glVertexAttrib4Nubv"); glVertexAttrib4Nuiv = ctx.GetProc<VertexAttrib4Nuiv>("glVertexAttrib4Nuiv"); glVertexAttrib4Nusv = ctx.GetProc<VertexAttrib4Nusv>("glVertexAttrib4Nusv"); glVertexAttrib4bv = ctx.GetProc<VertexAttrib4bv>("glVertexAttrib4bv"); glVertexAttrib4d = ctx.GetProc<VertexAttrib4d>("glVertexAttrib4d"); glVertexAttrib4dv = ctx.GetProc<VertexAttrib4dv>("glVertexAttrib4dv"); glVertexAttrib4f = ctx.GetProc<VertexAttrib4f>("glVertexAttrib4f"); glVertexAttrib4fv = ctx.GetProc<VertexAttrib4fv>("glVertexAttrib4fv"); glVertexAttrib4iv = ctx.GetProc<VertexAttrib4iv>("glVertexAttrib4iv"); glVertexAttrib4s = ctx.GetProc<VertexAttrib4s>("glVertexAttrib4s"); glVertexAttrib4sv = ctx.GetProc<VertexAttrib4sv>("glVertexAttrib4sv"); glVertexAttrib4ubv = ctx.GetProc<VertexAttrib4ubv>("glVertexAttrib4ubv"); glVertexAttrib4uiv = ctx.GetProc<VertexAttrib4uiv>("glVertexAttrib4uiv"); glVertexAttrib4usv = ctx.GetProc<VertexAttrib4usv>("glVertexAttrib4usv"); glVertexAttribPointer = ctx.GetProc<VertexAttribPointer>("glVertexAttribPointer"); }