コード例 #1
0
        private static void RenderPresetsToFiles()
        {
            using (GameWindow gameWindow = OpenTKSharedResources.CreateGameWindowContext(width, height))
            {
                // Resource creation.
                screenVbo = ScreenDrawing.CreateScreenQuadBuffer();
                shader    = OpenTKSharedResources.shaders["NudSphere"];

                // Skip thumbnail generation if the shader didn't compile.
                if (!shader.ProgramCreatedSuccessfully)
                {
                    return;
                }

                // HACK: This isn't a very clean way to pass resources around.
                NudMatSphereDrawing.LoadMaterialSphereTextures();
                Dictionary <NUD.DummyTextures, 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);
                }
            }
        }
コード例 #2
0
        public static void InitializeSharedResources()
        {
            // Only setup once. This is checked multiple times to prevent crashes.
            if (setupStatus == SharedResourceStatus.Initialized)
            {
                return;
            }

            try
            {
                // Make a permanent context to share resources.
                GraphicsContext.ShareContexts = true;
                dummyResourceWindow           = CreateGameWindowContext();

                if (Runtime.enableOpenTKDebugOutput)
                {
                    EnableOpenTKDebugOutput();
                }

                RenderTools.LoadTextures();
                ScreenDrawing.screenQuadVbo = ScreenDrawing.CreateScreenQuadBuffer();
                GetOpenGLSystemInfo();
                ShaderTools.SetupShaders();

                setupStatus = SharedResourceStatus.Initialized;
            }
            catch (AccessViolationException)
            {
                // Context creation failed.
                setupStatus = SharedResourceStatus.Failed;
            }
        }
コード例 #3
0
        private static Framebuffer DrawTextureToNewFbo(Texture2D texture, int width, int height, bool r, bool g, bool b, bool a)
        {
            BufferObject screenVbo   = ScreenDrawing.CreateScreenQuadBuffer();
            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.Id, 1, 1, r, g, b, a);
            return(framebuffer);
        }