private static void BindNutTexture(NUD.MatTexture matTexture, Texture texture) { // Set the texture's parameters based on the material settings. texture.Bind(); texture.TextureWrapS = NUD.wrapmode[matTexture.wrapModeS]; texture.TextureWrapT = NUD.wrapmode[matTexture.wrapModeT]; texture.MinFilter = NUD.minfilter[matTexture.minFilter]; texture.MagFilter = NUD.magfilter[matTexture.magFilter]; if (OpenGLExtensions.IsAvailable("GL_EXT_texture_filter_anisotropic") && (texture is Texture2D)) { TextureParameterName anisotropy = (TextureParameterName)ExtTextureFilterAnisotropic.TextureMaxAnisotropyExt; GL.TexParameter(TextureTarget.Texture2D, anisotropy, 0.0f); if (matTexture.mipDetail == 0x4 || matTexture.mipDetail == 0x6) { GL.TexParameter(TextureTarget.Texture2D, anisotropy, 4.0f); } } }
private static void SetTextureParameters(Texture target, NUD.MatTexture matTexture) { // TODO: Use a sampler object. // Set the texture's parameters based on the material settings. target.TextureWrapS = NudEnums.wrapModeByMatValue[matTexture.wrapModeS]; target.TextureWrapT = NudEnums.wrapModeByMatValue[matTexture.wrapModeT]; target.MinFilter = NudEnums.minFilterByMatValue[matTexture.minFilter]; target.MagFilter = NudEnums.magFilterByMatValue[matTexture.magFilter]; if (OpenGLExtensions.IsAvailable("GL_EXT_texture_filter_anisotropic") && (target is Texture2D)) { target.Bind(); TextureParameterName anisotropy = (TextureParameterName)ExtTextureFilterAnisotropic.TextureMaxAnisotropyExt; GL.TexParameter(TextureTarget.Texture2D, anisotropy, 0.0f); if (matTexture.mipDetail == 0x4 || matTexture.mipDetail == 0x6) { GL.TexParameter(TextureTarget.Texture2D, anisotropy, 4.0f); } } }
private static Shader CreateShader(string shaderProgramName, string[] shaderRelativePaths) { Shader shader = new Shader(); if (!Directory.Exists(shaderCacheDirectory)) { Directory.CreateDirectory(shaderCacheDirectory); } // Loading precompiled binaries isn't core in 3.30. // Most people will have more modern GPUs that support this, however. bool canLoadBinaries = OpenGLExtensions.IsAvailable("GL_ARB_get_program_binary"); // We can't load the binary without the proper format. string compiledBinaryPath = Path.Combine(shaderCacheDirectory, shaderProgramName + ".bin"); string compiledFormatPath = Path.Combine(shaderCacheDirectory, shaderProgramName + "_format.bin"); if (canLoadBinaries && File.Exists(compiledBinaryPath) && File.Exists(compiledFormatPath)) { LoadFromPrecompiledBinary(shader, compiledBinaryPath, compiledFormatPath); if (!shader.LinkStatusIsOk) { // Load from source and generate binary. LoadShaderFiles(shader, shaderRelativePaths); } } else { // Load from source. // Don't generate binaries for programs that did not link. // Attempting to load them will crash. LoadShaderFiles(shader, shaderRelativePaths); if (canLoadBinaries && shader.LinkStatusIsOk) { SavePrecompiledBinaryAndFormat(shader, compiledBinaryPath, compiledFormatPath); } } return(shader); }
private Shader CreateShader() { Shader shader = new Shader(); string vertShaderSource = ResourceTextFile.GetFileText("SFGraphicsGui.Shaders.screenTexture.vert"); shader.LoadShader(vertShaderSource, ShaderType.VertexShader, "screenTexture"); string fragShaderSource = ResourceTextFile.GetFileText("SFGraphicsGui.Shaders.screenTexture.frag"); shader.LoadShader(fragShaderSource, ShaderType.FragmentShader, "screenTexture"); // An example of how to use precompiled shaders. // The program binary can be saved to a file to avoid compiling shaders // every time the application is run. if (OpenGLExtensions.IsAvailable("GL_ARB_get_program_binary")) { byte[] programBinary = shader.GetProgramBinary(out BinaryFormat binaryFormat); shader.LoadProgramBinary(programBinary, binaryFormat); } return(shader); }
public void CorrectName() { Assert.IsTrue(OpenGLExtensions.IsAvailable("GL_ARB_sampler_objects")); }
public void InvalidName() { Assert.IsFalse(OpenGLExtensions.IsAvailable("GL_dank_memes")); }
public void CorrectNameLowerCase() { Assert.IsTrue(OpenGLExtensions.IsAvailable("gl_arb_sampler_objects")); }