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();
                GetOpenGLSystemInfo();
                ShaderTools.SetUpShaders();

                setupStatus = SharedResourceStatus.Initialized;
            }
            catch (AccessViolationException)
            {
                // Context creation failed.
                setupStatus = SharedResourceStatus.Failed;
            }
        }
 private static void CreateNudSphereShader()
 {
     // HACK: Recreating static resources is dumb.
     // Don't add this to the main shaders to begin with.
     string[] nudMatShaders = new string[]
     {
         "Nud\\NudSphere.frag",
         "Nud\\NudSphere.vert",
         "Nud\\StageLighting.frag",
         "Nud\\Bayo.frag",
         "Nud\\SmashShader.frag",
         "Utility\\Utility.frag"
     };
     OpenTKSharedResources.shaders.Remove("NudSphere");
     ShaderTools.CreateAndAddShader("NudSphere", nudMatShaders);
 }
示例#3
0
        public static void DrawScreenQuadPostProcessing(int texture0, int texture1, VertexArrayObject screenVao)
        {
            // Draws RGB and alpha channels of texture to screen quad.
            Shader shader = OpenTKSharedResources.shaders["ScreenQuad"];

            shader.UseProgram();

            shader.SetTexture("image0", texture0, TextureTarget.Texture2D, 0);
            shader.SetTexture("image1", texture1, TextureTarget.Texture2D, 1);

            shader.SetBoolToInt("renderBloom", Runtime.renderBloom);
            shader.SetFloat("bloomIntensity", Runtime.bloomIntensity);

            ShaderTools.SystemColorVector3Uniform(shader, Runtime.backgroundGradientBottom, "backgroundBottomColor");
            ShaderTools.SystemColorVector3Uniform(shader, Runtime.backgroundGradientTop, "backgroundTopColor");

            // Draw full screen "quad" (big triangle)
            DrawScreenTriangle(shader, screenVao);
        }