private Shader(ShaderType type, string shaderSource, string shaderName) { // Save the file name so we can use it to compare against later this.Name = shaderName; // Get the next available GL handler for a shader Handle = GL.CreateShader(type); // Locate the shader source from the file GL.ShaderSource(Handle, shaderSource); // Compile the shader GL.CompileShader(Handle); // Error Checking string infolog = GL.GetShaderInfoLog(Handle); if (infolog.Length > 0) { Console.WriteLine(type.ToString() + " Compile Error: " + infolog); throw new ShaderException(type.ToString() + " Compile Error: " + infolog); } Console.WriteLine("Sucessfully Compiled " + type.ToString() + " " + this.Name); Console.WriteLine("Assigned Shader Handle " + Handle.ToString()); loadedShaders.Add(this); }
private void GetInput() { if (!load_config) { input = File_input; output = File_output; shader = Shader_shape.ToString(); } else { config = Path.GetFileNameWithoutExtension(config); string jsonIn = path_to_configs + config + ".json"; if (File.Exists(jsonIn)) { list = JsonUtility.FromJson <ConfigList>(File.ReadAllText(jsonIn)); input = list.ModelConfig[index].Input; output = list.ModelConfig[index].Output; shader = list.ModelConfig[index].ShaderShape; } else { Debug.LogError("Config file not found"); EditorApplication.ExecuteMenuItem("Edit/Play"); } } }
private void CompileShader(string code, ShaderType type) { int shaderID = GL.CreateShader(type); string info = ""; int statusCode = -1; TryGL.Call(() => GL.ShaderSource(shaderID, code)); TryGL.Call(() => GL.CompileShader(shaderID)); TryGL.Call(() => GL.GetShaderInfoLog(shaderID, out info)); TryGL.Call(() => GL.GetShader(shaderID, ShaderParameter.CompileStatus, out statusCode)); if (statusCode != 1) { Console.WriteLine("Failed to compile shader source, type: " + type.ToString()); Console.WriteLine(info); Console.WriteLine("Status Code: " + statusCode); TryGL.Call(() => GL.DeleteShader(shaderID)); TryGL.Call(() => GL.DeleteProgram(ProgramID)); ProgramID = 0; throw new Exception("Failed to compile shader source, type: " + type.ToString()); } Console.WriteLine("Compiled shader, type: " + type.ToString()); TryGL.Call(() => GL.AttachShader(ProgramID, shaderID)); TryGL.Call(() => GL.DeleteShader(shaderID)); }
public int initShader(ShaderType shaderTypeToUse, string shaderProgram) { int shaderID = 0; ErrorCode iErrorCodePrior = GL.GetError(); if ( iErrorCodePrior != ErrorCode.NoError ) { throw new Exception ("Warning: An existing problem with the OpenGL state was found. Error code " + iErrorCodePrior.ToString() + ". This means an invalid call was made and not checked for before this part of the program was run."); } shaderID = GL.CreateShader(shaderTypeToUse); ErrorCode iErrorCode = GL.GetError(); if ( iErrorCode != ErrorCode.NoError ) { throw new Exception ("There was a problem creating a shader of type " + shaderTypeToUse.ToString() + ". The error was '" + iErrorCode.ToString() + "'."); } if ( 0 == shaderID ) { throw new Exception ("There was a problem creating a shader of type " + shaderTypeToUse.ToString() + ". We were unable to query for the GL Error code."); } if ( string.Empty == shaderProgram ) { throw new Exception ("The shaderProgram property of ShaderCreate can not be empty. Please review the configuration"); } GL.ShaderSource(shaderID, shaderProgram); ErrorCode iErrorCode2 = GL.GetError(); if ( iErrorCode2 != ErrorCode.NoError ) { switch (iErrorCode2) { case ErrorCode.InvalidOperation: throw new Exception ("Setting the shader source had a problem. The current shader compiler is not supported OR the shader ID, " + shaderID + ", is not a shader object (the handle ID is to something other than a shader."); case ErrorCode.InvalidValue: throw new Exception ("Setting the shader source had a problem. The shaderID provide, " + shaderID + ", was not generated by OpenGL or the shader program was empty (count of string length was 0). Please contact the developers as this should never happen."); default: throw new Exception ("Setting the shader source had a problem. . The error was '" + iErrorCode2.ToString() + "'."); } } GL.CompileShader(shaderID); string logInfo = GL.GetShaderInfoLog(shaderID); if ( string.Empty != logInfo ) { throw new Exception ("There was a problem compiling a shading program. Problems as follows '" + logInfo + "'. If the code looks fine, are you using the right shader type? For example, maybe you passed fragment code to a vertex shader?"); } return shaderID; }
protected GlShaderHandle(string strName, ShaderType type) : base(type.ToString() + "_" + strName) { m_iObject = gl.glCreateShaderObjectARB((uint)type); Register(true); }
public void AddShader(ShaderType type, String source) { _shaders[type] = GL.CreateShader(type); GL.ShaderSource(_shaders[type], source); GL.CompileShader(_shaders[type]); if (OnMessage != null) { OnMessage(GL.GetShaderInfoLog(_shaders[type])); } int compileResult; GL.GetShader(_shaders[type], ShaderParameter.CompileStatus, out compileResult); if (compileResult != 1) { if (OnMessage != null) { OnMessage("Compile Error:" + type.ToString()); } } if (OnMessage != null) { OnMessage("Compiled"); } GL.AttachShader(Program, _shaders[type]); }
private int CompileShader(ShaderType type, string src) { int id = GL.CreateShader(type); GL.ShaderSource(id, src); GL.CompileShader(id); int result; GL.GetShader(id, ShaderParameter.CompileStatus, out result); if (result == 0) { string infoLog; GL.GetShaderInfoLog(id, out infoLog); Console.WriteLine($"Failed to compile {type.ToString()} {infoLog}"); Console.WriteLine("\n" + src); GL.DeleteShader(id); return(0); } return(id); }
private static int LoadShader(ShaderType type, string source) { var shader = GL.CreateShader(type); if (shader == 0) { throw new InvalidOperationException("Unable to create shader:" + type.ToString()); } GL.ShaderSource(shader, 1, new string[] { source }, (int[])null); GL.CompileShader(shader); GL.GetShader(shader, ShaderParameter.CompileStatus, out int compiled); if (compiled == 0) { int length = 0; GL.GetShader(shader, ShaderParameter.InfoLogLength, out length); if (length > 0) { GL.GetShaderInfoLog(shader, length, out length, out string log); } GL.DeleteShader(shader); throw new InvalidOperationException("Unable to compile shader of type : " + type.ToString()); } return(shader); }
bool AttachShader(string source, ShaderType type, Resource resource) { //source = source.Replace(maxNumberOfLights_name, maxNumberOfLights.ToString()); int handle = GL.CreateShader(type); shaderParts.Add(handle); GL.ShaderSource(handle, prependSource + source); GL.CompileShader(handle); int statusCode = 0; GL.GetShader(handle, ShaderParameter.CompileStatus, out statusCode); if (statusCode != 1) { Debug.Error(type.ToString() + " :: " + source + "\n" + GL.GetShaderInfoLog(handle) + "\n in file: " + resource.originalPath); return(false); } GL.AttachShader(shaderProgramHandle, handle); // delete intermediate shader objects foreach (var p in shaderParts) { GL.DeleteShader(p); } shaderParts.Clear(); return(true); }
int LoadShader(ShaderType type, string source) { int shader = GL.CreateShader(type); if (shader == 0) throw new InvalidOperationException("Unable to create shader"); int length = 0; GL.ShaderSource(shader, 1, new string[] { source }, (int[])null); GL.CompileShader(shader); int compiled = 0; GL.GetShader(shader, ShaderParameter.CompileStatus, out compiled); if (compiled == 0) { length = 0; GL.GetShader(shader, ShaderParameter.InfoLogLength, out length); if (length > 0) { var log = new StringBuilder(length); GL.GetShaderInfoLog(shader, length, out length, log); Console.WriteLine("Couldn't compile shader: " + log.ToString()); } GL.DeleteShader(shader); throw new InvalidOperationException("Unable to compile shader of type : " + type.ToString()); } return shader; }
private static int GetShaderID(string shaderPath, ShaderType shaderType) { string shaderSource; try { shaderSource = File.ReadAllText(shaderPath); } catch (Exception) { return(-1); } int shader = GL.CreateShader(shaderType); GL.ShaderSource(shader, shaderSource); GL.CompileShader(shader); // Check the compilation status int ok; GL.GetShader(shader, ShaderParameter.CompileStatus, out ok); if (ok == 0) { string shaderInfo = GL.GetShaderInfoLog(shader); MessageBox.Show(string.Format("Failed to compile the shader '{0}'. Message: {1}", shaderType.ToString(), shaderInfo)); return(-1); } return(shader); }
private void AddProgram(string text, ShaderType type) { int shader = GL.CreateShader(type); if (shader == 0) { Console.WriteLine("Failed to add Shader."); Environment.Exit(0); } GL.ShaderSource(shader, text); GL.CompileShader(shader); int outs = 0; GL.GetShader(shader, ShaderParameter.CompileStatus, out outs); if (outs == 0) { Console.WriteLine(type.ToString() + ":"); Console.WriteLine(GL.GetShaderInfoLog(shader)); Environment.Exit(0); } GL.AttachShader(program, shader); }
private void LoadShader(int program, string data, ShaderType t) { int s = GL.CreateShader(t); switch (t) { case ShaderType.VertexShader: LocVertex = s; break; case ShaderType.GeometryShader: LocGeometry = s; break; case ShaderType.FragmentShader: LocFragment = s; break; } GL.ShaderSource(s, data); GL.CompileShader(s); string err = GL.GetShaderInfoLog(s); Log.Error(t.ToString() + ": " + err); GL.AttachShader(program, s); }
protected override bool CreateShader(byte[] data, ShaderType type) { switch (type) { case ShaderType.VS: vs = new Shader(deviceD3D12, type); return(vs.Init(data)); case ShaderType.PS: ps = new Shader(deviceD3D12, type); return(ps.Init(data)); case ShaderType.HS: ps = new Shader(deviceD3D12, type); return(ps.Init(data)); case ShaderType.DS: ps = new Shader(deviceD3D12, type); return(ps.Init(data)); case ShaderType.GS: ps = new Shader(deviceD3D12, type); return(ps.Init(data)); default: throw new NotSupportedException("Shader type not supported: " + type.ToString()); } }
public static Shader GetShader(ShaderType type) { if (shaders.TryGetValue(type, out Shader shader)) return shader; Log.Warn(ShaderManager.type, $"Can't load Shader {type.ToString()}"); return null; }
public override string ToString() { if (SrcFile != null) { return(SrcFile); } return(ShaderType.ToString()); }
public void Compile(string sShader, ShaderType type) { isLinked = false; int shaderObject = GL.CreateShader(type); if (0 == shaderObject) throw new ShaderException(type.ToString(), "Could not create shader object", string.Empty, sShader); // Compile vertex shader GL.ShaderSource(shaderObject, sShader); GL.CompileShader(shaderObject); int status_code; GL.GetShader(shaderObject, ShaderParameter.CompileStatus, out status_code); LastLog = GL.GetShaderInfoLog(shaderObject); if (1 != status_code) { throw new ShaderException(type.ToString(), "Error compiling shader", LastLog, sShader); } GL.AttachShader(m_ProgramID, shaderObject); //shaderIDs.Add(shaderObject); }
/// <summary> /// Initializes a new instance of the <see cref="Shader"/> class. /// </summary> /// <param name="type">The type of this shader.</param> /// <param name="shaderName">The name of the shader. Typically the filename.</param> /// <param name="shaderSource">(Optional) The GLSL source for this shader. </param> private Shader(ShaderType type, string shaderName, string shaderSource = null) { // Check Loaded Shaders to see if this one has already been read in. object s = loadedShaders.FirstOrDefault(x => x.Name.Equals(shaderName)); if (s != null) { // If it has, grab the handle and name and ignore everything else here this.Handle = ((Shader)s).Handle; this.Name = ((Shader)s).Name; return; } // Save the file name so we can use it to compare against later this.Name = shaderName; // Get the next available GL handler for a shader this.Handle = GL.CreateShader(type); // If there was no source provided, lets see if the shader name is actually a filename if (shaderSource == null) { shaderSource = LoadSourceFromFile(shaderName); } // Locate the shader source from the file GL.ShaderSource(this.Handle, shaderSource); // Compile the shader GL.CompileShader(this.Handle); // Error Checking string infolog = GL.GetShaderInfoLog(this.Handle); if (infolog.Length > 0) { Console.WriteLine(type.ToString() + " Compile Error: " + infolog); throw new ShaderException(type.ToString() + " Compile Error: " + infolog); } Console.WriteLine("Sucessfully Compiled " + type.ToString() + " " + this.Name); Console.WriteLine("Assigned Shader Handle " + this.Handle.ToString()); loadedShaders.Add(this); }
public ShaderProgram AddShader(ShaderType type, string source) { Shader s = new Shader(string.Format("{0}:{1}", this.Name, type.ToString())); s.Type = type; s.Source = source; s.Compile(); this.Shaders.Add(s); return(this); }
private bool checkCompileErr(int shader, ShaderType type) { GL.GetShader(shader, ShaderParameter.CompileStatus, out int success); if (success != 1) { string infoLog = GL.GetShaderInfoLog(shader); Log.Error("Could not compile {0}: {1}", type.ToString(), Name); Log.Error("Info log: {0}", infoLog); } return(success == 1); }
public bool Compile() { shader = new GlShader(); if (!shader.CompileShader(type, sourceFile, hintDir)) { Util.LogFormat("{0} compile error: {1} .. giving up", type.ToString(), shader.Message); shader.Dispose(); shader = null; return(false); } return(true); }
public Shader(ShaderType type, string src) { mHandle = GL.CreateShader(type); mSrc = src; this.Type = type; GL.ShaderSource(mHandle, src); GL.CompileShader(mHandle); string status = GL.GetShaderInfoLog(mHandle); if (status != "") { Console.WriteLine(type.ToString() + " " + status); } //throw new ApplicationException(status); else { Console.WriteLine(type.ToString() + " erfolgreich"); } }
/// <summary> /// Compiles the specified s shader. /// </summary> /// <param name="sShader">The s shader.</param> /// <param name="type">The type.</param> /// <exception cref="ShaderCompileException"> /// Could not create " + type.ToString() + " object /// or /// Error compiling " + type.ToString() /// </exception> public void Compile(string sShader, ShaderType type) { IsLinked = false; int shaderObject = GL.CreateShader(ConvertType(type)); if (0 == shaderObject) { throw new ShaderCompileException(type, "Could not create " + type.ToString() + " object", string.Empty, sShader); } // Compile vertex shader GL.ShaderSource(shaderObject, sShader); GL.CompileShader(shaderObject); GL.GetShader(shaderObject, ShaderParameter.CompileStatus, out int status_code); LastLog = GL.GetShaderInfoLog(shaderObject); if (1 != status_code) { GL.DeleteShader(shaderObject); throw new ShaderCompileException(type, "Error compiling " + type.ToString(), LastLog, sShader); } GL.AttachShader(ProgramID, shaderObject); shaderIDs.Add(shaderObject); }
public D3D11Shader CreateShader(ShaderType type) { var source = GetShaderSource(type); var shader = new D3D11Shader(type.ToString()); source .Subscribe(x => { shader.SetShader(x, x); }); return(shader); }
public void Compile(string sShader, ShaderType type) { IsLinked = false; int shaderObject = GL.CreateShader(type); if (0 == shaderObject) { throw new ShaderException(type.ToString(), "Could not create shader object", string.Empty, sShader); } // Compile vertex shader GL.ShaderSource(shaderObject, sShader); GL.CompileShader(shaderObject); int statusCode; GL.GetShader(shaderObject, ShaderParameter.CompileStatus, out statusCode); if (1 != statusCode) { throw new ShaderException(type.ToString(), "Error compiling shader", GL.GetShaderInfoLog(shaderObject), sShader); } GL.AttachShader(_mProgramId, shaderObject); //shaderIDs.Add(shaderObject); }
public void Compile(string sShader, ShaderType type) { isLinked = false; int shaderObject = GL.CreateShader(type); if (0 == shaderObject) { throw new ShaderException(type.ToString(), "Could not create."); } // Compile vertex shader GL.ShaderSource(shaderObject, sShader); GL.CompileShader(shaderObject); int status_code; GL.GetShader(shaderObject, ShaderParameter.CompileStatus, out status_code); if (1 != status_code) { string log = CorrectLineEndings(GL.GetShaderInfoLog(shaderObject)); throw new ShaderException(type.ToString(), log); } GL.AttachShader(m_ProgramID, shaderObject); //shaderIDs.Add(shaderObject); }
public Shader(string fileName, ShaderType shaderType) { string data = File.ReadAllText(fileName); id = GL.CreateShader(shaderType); GL.ShaderSource(id, data); GL.CompileShader(id); string errLog = GL.GetShaderInfoLog(id); if (!string.IsNullOrWhiteSpace(errLog)) { Debug.WriteLine("GL.CompileShader [" + shaderType.ToString() + "] had info log: " + errLog); } }
private static int LoadShader(string shaderPath, ShaderType shaderType) { string shaderText = null; if (File.Exists(shaderPath)) { shaderText = File.ReadAllText(shaderPath); } else { Logger.Log("Shader file " + shaderPath + " not found."); return(0); } int shaderIndex = GL.CreateShader(shaderType); if (shaderIndex == 0) { Logger.Log("Failed to create shader object for " + shaderType.ToString()); return(0); } GL.ShaderSource(shaderIndex, shaderText); GL.CompileShader(shaderIndex); int compileStatus; GL.GetShader(shaderIndex, ShaderParameter.CompileStatus, out compileStatus); if (compileStatus == 0) { Logger.Log("Failed to compile " + shaderType.ToString() + " shader. Compilation error: " + GL.GetShaderInfoLog(shaderIndex)); GL.DeleteShader(shaderIndex); return(0); } return(shaderIndex); }
public void LoadAndParse(FileExisting file) { string source = file.ReadAllText(); source = AddLineMarkers(source, file); source = ReplaceIncludeDirectiveWithFileContents(source, file.Folder); // the contents above first shader part (program) [VertexShader] are shared amongs all parts (prepended to all parts) string prependContents = ""; { ShaderType shaderType = ShaderType.VertexShader; int startOfTag = GetClosestShaderTypeTagPosition(source, 0, ref shaderType); if (startOfTag > 0) { prependContents += source.Substring(0, startOfTag - 1); source = source.Substring(startOfTag); } } foreach (ShaderType type in Enum.GetValues(typeof(ShaderType))) { ShaderType shaderType = ShaderType.VertexShader; int startOfTag = GetClosestShaderTypeTagPosition(source, 0, ref shaderType); if (startOfTag != -1) { var tagLength = shaderType.ToString().Length + 2; ShaderType notUsed = ShaderType.VertexShader; int endOfShaderPart = GetClosestShaderTypeTagPosition(source, startOfTag + tagLength, ref notUsed); if (endOfShaderPart == -1) { endOfShaderPart = source.Length; } var startOfShaderPart = startOfTag + tagLength; string shaderPart = source.Substring( startOfShaderPart, endOfShaderPart - startOfShaderPart ); AttachShader(prependContents + shaderPart, shaderType, file.VirtualPath); source = source.Substring(endOfShaderPart); } } }
public Shader(ShaderType type, string code) { Handle = GL.CreateShader(type); GL.ShaderSource(Handle, code); GL.CompileShader(Handle); GL.GetShader(Handle, ShaderParameter.CompileStatus, out int status); Compiled = status == 1; if (!Compiled) { Logger.Error($"Error compiling {type.ToString()} shader: {GL.GetShaderInfoLog(Handle)}"); } }
public void AddShader(ShaderType type, String source) { _shaders[type] = GL.CreateShader(type); GL.ShaderSource(_shaders[type], source); GL.CompileShader(_shaders[type]); if (OnMessage != null) OnMessage(GL.GetShaderInfoLog(_shaders[type])); int compileResult; GL.GetShader(_shaders[type], ShaderParameter.CompileStatus, out compileResult); if (compileResult != 1) { if (OnMessage != null) OnMessage("Compile Error:" + type.ToString()); } if (OnMessage != null) OnMessage("Compiled"); GL.AttachShader(Program, _shaders[type]); }
private static int CompileShader(string shaderSource, ShaderType shaderType) { int shader = GL.CreateShader(shaderType); GL.ShaderSource(shader, shaderSource); GL.CompileShader(shader); string compileStatus = GL.GetShaderInfoLog(shader); Console.WriteLine( compileStatus != string.Empty ? compileStatus : string.Format("{0} compiled successfully.", shaderType.ToString())); return(shader); }
private void checkCompStatus(int id, ShaderType type) { int compileStatus = 0; GL.GetShader(id, ShaderParameter.CompileStatus, out compileStatus); if (compileStatus == COMPILATION_ERROR) { string errorMsg = String.Format("COMPILE ERROR #{0} ({1}): {2}", id, type.ToString(), GL.GetShaderInfoLog(id)); #if DEBUG Console.WriteLine(errorMsg); #endif throw new ShaderCompilationException(errorMsg); } }
private static unsafe BlobAssetReference <PrecompiledShaderData> AddShaderData(EntityManager em, Entity e, ShaderType type, bgfx.RendererType[] types, string prefix) { using (var allocator = new BlobBuilder(Allocator.Temp)) { ref var root = ref allocator.ConstructRoot <PrecompiledShaderData>(); foreach (bgfx.RendererType sl in types) { string path = Path.GetFullPath(kBinaryShaderFolderPath); string fsFileName = GetShaderFileName(prefix, type.ToString(), sl.ToString()).ToLower(); using (var data = new NativeArray <byte>(File.ReadAllBytes(Path.Combine(path, fsFileName)), Allocator.Temp)) { byte *dest = (byte *)(allocator.Allocate(ref root.DataForBackend(sl), data.Length).GetUnsafePtr()); UnsafeUtility.MemCpy(dest, (byte *)data.GetUnsafePtr(), data.Length); } } return(allocator.CreateBlobAssetReference <PrecompiledShaderData>(Allocator.Persistent)); }
private void checkCompilationErrors(int shaderID, ShaderType type) { int compileStatus = 0; GL.GetShader(shaderID, ShaderParameter.CompileStatus, out compileStatus); if (compileStatus == COMPILE_ERROR) { //Shader compilation failed. Output compilation error to console and throw new exception string shaderInfo = String.Empty; GL.GetShaderInfoLog(shaderID, out shaderInfo); Console.WriteLine(String.Format("ERROR::SHADER: Compile-time error: Type: {0}\n{1}", type.ToString(), shaderInfo)); throw new ShaderCompilationErrorException( String.Format("Shader #{0} ({1}) failed to compile. Check debug console for error message.", shaderID, type.ToString())); } }
public int Load(SceneNode _node, ShaderType type) { BaseShader shader = null; switch (type) { case ShaderType.Sky: if (Reference.Viewer.IsDrawSky) { shader = new Sky(Reference.Viewer, ParentNode); } break; case ShaderType.Sea: if (Reference.Viewer.IsDrawSea) { if (Reference.Viewer.SeaQuality == Viewer.ShaderLevelType.Low) shader = new Sea(Reference.Viewer, ParentNode); } break; case ShaderType.AdvancedSea: if (Reference.Viewer.IsDrawSea) { if (Reference.Viewer.SeaQuality == Viewer.ShaderLevelType.High) shader = new AdvancedSea(Reference.Viewer, ParentNode); } break; case ShaderType.Shadow: if (Reference.Viewer.IsDrawSky) { } break; } int res = -1; if (shader != null) { // Load shader. //Reference.Device.FileSystem.WorkingDirectory = Util.ApplicationDataDirectory + @"\media"; res = shader.Load(); if (res > 0) { if (shaders.ContainsKey(type)) { Reference.Log.Debug("[SHADER]: " + type.ToString() + " Read multi."); } else { lock (shaders) { shaders.Add(type, shader); } lock (shaderIndex) { shaderIndex.Add(type, res); } } } else { Reference.Log.Debug("[SHADER]: " + type.ToString() + " Shader don't load."); } } return res; }
/// <summary> /// Build the shaders /// </summary> private int LoadShader(ShaderType type, string source) { int shader = GL20.CreateShader (type); if (shader == 0) throw new InvalidOperationException (string.Format ( "Unable to create shader: {0}", GL20.GetError ()) ); // Load the shader source int length = 0; GL20.ShaderSource (shader, 1, new string[] {source}, (int[])null); // Compile the shader GL20.CompileShader (shader); int compiled = 0; GL20.GetShader (shader, ShaderParameter.CompileStatus, out compiled); if (compiled == 0) { length = 0; GL20.GetShader (shader, ShaderParameter.InfoLogLength, out length); if (length > 0) { var log = new StringBuilder (length); GL20.GetShaderInfoLog (shader, length, out length, log); #if DEBUG Console.WriteLine("GL2" + log.ToString ()); #endif } GL20.DeleteShader (shader); throw new InvalidOperationException ("Unable to compile shader of type : " + type.ToString ()); } return shader; }
protected void CompileShader(ShaderType type, string source) { _shaderId = GL.CreateShader(type); GL.ShaderSource(ID, source); GL.CompileShader(ID); int status; GL.GetShader(ID, ShaderParameter.CompileStatus, out status); if (status == 0) throw new GraphicsException( String.Format("Error compiling {0} shader: {1}", type.ToString(), GL.GetShaderInfoLog(ID))); }
protected void CompileShader(ShaderType type, string[] source) { _shaderId = GL.CreateShader(type); int[] lens = new int[source.Length]; for (int i = 0; i < lens.Length; i++) lens[i] = -1; GL.ShaderSource(ID, source.Length, source, ref lens[0]); GL.CompileShader(ID); int status; GL.GetShader(ID, ShaderParameter.CompileStatus, out status); if (status == 0) throw new GraphicsException( String.Format("Error compiling {0} shader: {1}", type.ToString(), GL.GetShaderInfoLog(ID))); }