private static void RenderPresetsToFiles() { using (GameWindow gameWindow = OpenTkSharedResources.CreateGameWindowContext(width, height)) { // Resource creation. screenTriangle = ScreenDrawing.CreateScreenTriangle(); shader = OpenTkSharedResources.shaders["NudSphere"]; // Skip thumbnail generation if the shader didn't compile. if (!shader.LinkStatusIsOk) { return; } // HACK: This isn't a very clean way to pass resources around. NudMatSphereDrawing.LoadMaterialSphereTextures(); Dictionary <NudEnums.DummyTexture, Texture> dummyTextures = RenderTools.CreateNudDummyTextures(); CreateNudSphereShader(); foreach (string file in Directory.EnumerateFiles(MainForm.executableDir + "\\materials", "*.nmt", SearchOption.AllDirectories)) { Nud.Material material = NudMaterialEditor.ReadMaterialListFromPreset(file)[0]; string presetName = Path.GetFileNameWithoutExtension(file); RenderMaterialPresetToFile(presetName, material, dummyTextures); } } }
private static Framebuffer DrawTextureToNewFbo(Texture2D texture, int width, int height, bool r, bool g, bool b, bool a) { Mesh3D screenTriangle = ScreenDrawing.CreateScreenTriangle(); Framebuffer framebuffer = new Framebuffer(FramebufferTarget.Framebuffer, width, height, PixelInternalFormat.Rgba); framebuffer.Bind(); // Draw the specified color channels. GL.Viewport(0, 0, width, height); ScreenDrawing.DrawTexturedQuad(texture, 1, 1, screenTriangle, r, g, b, a); return(framebuffer); }