public void AttachRenderTexture(RenderTexture texture, FramebufferAttachment?attachmentType = null) { Rendering.CheckGLErrors($"At the start of '{nameof(Framebuffer)}.{nameof(AttachRenderTexture)}'."); Bind(this); var attachment = attachmentType ?? nextDefaultAttachment++; GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, attachment, TextureTarget.Texture2D, texture.Id, 0); renderTextures.Add(texture); textureToAttachment[texture] = attachment; var drawBuffersEnum = (DrawBuffersEnum)attachment; if (Enum.IsDefined(typeof(DrawBuffersEnum), drawBuffersEnum)) { ArrayUtils.Add(ref drawBuffers, drawBuffersEnum); } maxTextureWidth = Math.Max(maxTextureWidth, texture.Width); maxTextureHeight = Math.Max(maxTextureHeight, texture.Height); Rendering.CheckFramebufferStatus(); Rendering.CheckGLErrors($"At the end of '{nameof(Framebuffer)}.{nameof(AttachRenderTexture)}'."); }
public bool CompileShader(string code) { code = code.Trim(); //Some broken Nvidia drivers don't support 'f' suffix, even though it was added in GLSL 1.2 decades ago. Zoinks. code = RegexFSuffixB.Replace(code, @"$1$2"); code = RegexFSuffixA.Replace(code, @"$1$2.0"); GL.ShaderSource(Id, code); GL.CompileShader(Id); string info = GL.GetShaderInfoLog(Id); if (!string.IsNullOrEmpty(info)) { Debug.Log($"Error compilling {Type} '{Name}':\r\n{info}\r\n\r\n{code}"); return(false); } if (Rendering.CheckGLErrors(throwException: false)) { throw new GraphicsException($"Unable to compile {Type} '{Name}'."); } return(true); }