public void GraphicsCapabilitiesIsBlendEquationSupported() { tlog.Debug(tag, $"GraphicsCapabilitiesIsBlendEquationSupported START"); try { GraphicsCapabilities.IsBlendEquationSupported(BlendEquationType.Color); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception: Failed!"); } tlog.Debug(tag, $"GraphicsCapabilitiesIsBlendEquationSupported END (OK)"); }
public GraphicsDevice(IGameWindow window, IWindowContainer container, GraphicsContext context, DeviceCreationFlags creationFlags) { if (window == null) { throw new ArgumentNullException("window"); } if (container == null) { throw new ArgumentNullException("container"); } if (context == null) { throw new ArgumentNullException("context"); } if (context.IsDisposed) { throw new ArgumentException("context is disposed.", "context"); } this.DefaultWindow = window; this.container = container; this.Context = context; this.CreationFlags = creationFlags; Log.Debug("Got context: [ColorFormat: {0}, Depth: {1}, Stencil: {2}, FSAA Samples: {3}, AccumulatorFormat: {4}, Buffers: {5}, Stereo: {6}]", Context.GraphicsMode.ColorFormat, Context.GraphicsMode.Depth, Context.GraphicsMode.Stencil, Context.GraphicsMode.Samples, Context.GraphicsMode.AccumulatorFormat, Context.GraphicsMode.Buffers, Context.GraphicsMode.Stereo); Context.LoadAll(); capabilities = new GraphicsCapabilities(); CheckGraphicsCapabilities(LogLevel.Verbose); Factory = new GraphicsFactory(this); BindManager = new OpenGL4.BindManager(this); this.RenderContext = new RenderContext(this); Context.MakeCurrent(null); }
private void CheckGraphicsCapabilities(LogLevel logLevel) { openGLCapabilities = new OpenGLGraphicsCapabilities(); capabilities = new GraphicsCapabilities(); openGLCapabilities.OpenGLVersion = new Version(GL.GetInteger(GetPName.MajorVersion), GL.GetInteger(GetPName.MinorVersion)); Log.Write(logLevel, "OpenGL Diagnostics:"); Log.Write(logLevel, "\tOpenGL Version: {0}", openGLCapabilities.OpenGLVersion.ToString()); //GLSL Version string auslesen string glslVersionString = ""; if (openGLCapabilities.OpenGLVersion >= new Version(4, 3) && !string.IsNullOrWhiteSpace(glslVersionString = GL.GetString(StringName.ShadingLanguageVersion))) { string glslVersionStringMajor = glslVersionString.Substring(0, glslVersionString.IndexOf('.')); string glslVersionStringMinor = glslVersionString.Substring(glslVersionString.IndexOf('.') + 1, 1); int glslVersionMajor; int glslVersionMinor; if (!int.TryParse(glslVersionStringMajor, out glslVersionMajor) || !int.TryParse(glslVersionStringMinor, out glslVersionMinor)) { throw new DotGame.Graphics.GraphicsException("Could not determine supported GLSL version"); } //Nicht Version mit String initialisieren da 4.40 als Major 4 und Minor 40 aufgefasst wird openGLCapabilities.GLSLVersion = new Version(glslVersionMajor, glslVersionMinor); } else if (glslVersions.ContainsKey(openGLCapabilities.OpenGLVersion)) { openGLCapabilities.GLSLVersion = glslVersions[openGLCapabilities.OpenGLVersion]; } else { throw new Exception("Could not determine supported GLSL version"); } CheckGLError("Init Version"); Log.Write(logLevel, "\tGLSL Version: {0}", openGLCapabilities.GLSLVersion.ToString()); Log.Write(logLevel, "\tExtensions supported:"); //Extensions überprüfen int extensionCount = GL.GetInteger(GetPName.NumExtensions); var extensions = new List <string>(); if (GL.GetError() == ErrorCode.NoError) { for (int i = 0; i < extensionCount; i++) { extensions.Add(GL.GetString(StringNameIndexed.Extensions, i)); } } else { var extensionString = GL.GetString(StringName.Extensions); extensions.AddRange(extensionString.Split(' ')); } foreach (var extension in extensions) { switch (extension) { case "GL_EXT_texture_compression_s3tc": openGLCapabilities.SupportsS3TextureCompression = true; Log.Write(logLevel, "\t\t" + "GL_EXT_texture_compression_s3tc"); break; case "GL_EXT_texture_filter_anisotropic": openGLCapabilities.SupportsAnisotropicFiltering = true; openGLCapabilities.MaxAnisotropicFiltering = (int)GL.GetFloat((GetPName)OpenTK.Graphics.OpenGL.ExtTextureFilterAnisotropic.MaxTextureMaxAnisotropyExt); Log.Write(logLevel, "\t\t" + "GL_EXT_texture_filter_anisotropic"); CheckGLError("Init GL_EXT_texture_filter_anisotropic"); break; case "GL_ARB_debug_output": openGLCapabilities.SupportsDebugOutput = true; if (CreationFlags.HasFlag(DeviceCreationFlags.Debug)) { onDebugMessage = new DebugProc(OnDebugMessage); GL.Enable(EnableCap.DebugOutput); GL.DebugMessageCallback(onDebugMessage, IntPtr.Zero); GL.DebugMessageControl(DebugSourceControl.DontCare, DebugTypeControl.DontCare, DebugSeverityControl.DontCare, 0, new int[0], true); } Log.Write(logLevel, "\t\t" + "GL_ARB_debug_output"); CheckGLError("Init GL_ARB_debug_output"); break; case "GL_ARB_get_program_binary": capabilities.SupportsBinaryShaders = true; Log.Write(logLevel, "\t\t" + "GL_ARB_get_program_binary"); break; case "GL_ARB_texture_storage": openGLCapabilities.SupportsTextureStorage = true; Log.Write(logLevel, "\t\t" + "GL_ARB_texture_storage"); break; case "GL_ARB_buffer_storage": openGLCapabilities.SupportsBufferStorage = true; Log.Write(logLevel, "\t\t" + "GL_ARB_buffer_storage"); break; case "GL_ARB_invalidate_subdata": openGLCapabilities.SupportsResourceValidation = true; Log.Write(logLevel, "\t\t" + "GL_ARB_invalidate_subdata"); break; case "GL_EXT_direct_state_access": if (openGLCapabilities.DirectStateAccess == DirectStateAccess.None) { openGLCapabilities.DirectStateAccess = DirectStateAccess.Extension; } Log.Write(logLevel, "\t\t" + "GL_EXT_direct_state_access"); break; case "GL_ARB_direct_state_access": //openGLCapabilities.DirectStateAccess = DirectStateAccess.Core; Log.Write(logLevel, "\t\t" + "GL_ARB_direct_state_access"); break; case "GL_ARB_vertex_attrib_binding": openGLCapabilities.VertexAttribBinding = true; openGLCapabilities.MaxVertexAttribBindings = GL.GetInteger((GetPName)All.MaxVertexAttribBindings); openGLCapabilities.MaxVertexAttribBindingOffset = GL.GetInteger((GetPName)All.MaxVertexAttribRelativeOffset); openGLCapabilities.MaxVertexAttribStride = GL.GetInteger((GetPName)All.MaxVertexAttribStride); Log.Write(logLevel, "\t\t" + "GL_ARB_vertex_attrib_binding"); CheckGLError("Init GL_ARB_vertex_attrib_binding"); break; } } openGLCapabilities.TextureUnits = GL.GetInteger(GetPName.MaxCombinedTextureImageUnits); CheckGLError("Init MaxCombinedTextureImageUnits"); openGLCapabilities.MaxTextureLoDBias = GL.GetInteger(GetPName.MaxTextureLodBias); CheckGLError("Init MaxTextureLodBias"); openGLCapabilities.MaxTextureSize = GL.GetInteger(GetPName.MaxTextureSize); CheckGLError("Init MaxTextureSize"); openGLCapabilities.MaxVertexAttribs = GL.GetInteger(GetPName.MaxVertexAttribs); CheckGLError("Init MaxVertexAttribs"); openGLCapabilities.MaxUniformBlockSize = GL.GetInteger(GetPName.MaxUniformBlockSize); CheckGLError("Init MaxUniformBlockSize"); openGLCapabilities.MaxUniformBufferBindings = GL.GetInteger(GetPName.MaxUniformBufferBindings); CheckGLError("Init MaxUniformBufferBindings"); }
internal static void Initialize(GraphicsDevice device) { GraphicsCapabilities.NonPowerOfTwo = GraphicsCapabilities.GetNonPowerOfTwo(device); GraphicsCapabilities.TextureFilterAnisotric = true; }