Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
 private static Bitmap DrawTextureToBitmap(Texture2D texture, int width, int height, bool r, bool g, bool b, bool a)
 {
     using (GameWindow gameWindow = OpenTkSharedResources.CreateGameWindowContext(width, height))
     {
         Framebuffer framebuffer = DrawTextureToNewFbo(texture, width, height, r, g, b, a);
         return(framebuffer.ReadImagePixels(a));
     }
 }