Esempio n. 1
0
        public static void SavingAlgorithm()
        {
            Scene.SS.env.player.coords.Player_precise_position.Save("PlayerPosition");
            Scene.SS.env.player.coords.Player_rotational_view.Save("PlayerRotationalView");

            vec3things.Save(Projectile.jp.hposition1, "hposition1");
            vec3things.Save(Projectile.jp.hposition2, "hposition2");

            SaveAndLoad.Save("default");
        }
Esempio n. 2
0
        //Создание шейдеров более in Old Fashioned Way чтобы использовать Geomtry Shader
        //https://www.codeproject.com/Articles/1167387/OpenGL-with-OpenTK-in-Csharp-Part-Compiling-Shader
        public void Initialise(OpenGL gl, float width, float height)
        {
            this.width = width; this.height = height;
            try
            {
                _gl             = gl;
                SS              = new ShaderedScene(gl);
                newThread_ghost = new Thread(Scene.DoWork_ghost);

                Console.WriteLine("Starting My");
                newThread = new Thread(Scene.DoWork);
                newThread.Start(42);

                while (newThread.IsAlive)
                {
                }
                Console.WriteLine("Finished My");
                SS.Main.CopyToReady();

                //  Set a blue clear colour.
                gl.ClearColor(0.4f, 0.6f, 0.9f, 0.0f);


                //gl.Hint(OpenGL.WGL_CONTEXT_DEBUG_BIT_ARB, OpenGL.GL_TRUE);
                //  Create the shader program.

                var Header      = ManifestResourceLoader.LoadTextFile(@"Shaders\VertexModules\Header.vert");
                var Cuter       = ManifestResourceLoader.LoadTextFile(@"Shaders\VertexModules\Cuter.vert");
                var Sun         = ManifestResourceLoader.LoadTextFile(@"Shaders\VertexModules\Sun.vert");
                var Rotator     = ManifestResourceLoader.LoadTextFile(@"Shaders\VertexModules\Rotator.vert");
                var Translation = ManifestResourceLoader.LoadTextFile(@"Shaders\VertexModules\Translation.vert");
                var Sizer       = ManifestResourceLoader.LoadTextFile(@"Shaders\VertexModules\Sizer.vert");
                var Explosion   = ManifestResourceLoader.LoadTextFile(@"Shaders\VertexModules\Explosion.vert");

                var Main            = ManifestResourceLoader.LoadTextFile(@"Shaders\Main\Main.vert");
                var Adv_main        = ManifestResourceLoader.LoadTextFile(@"Shaders\Main\Adv_main.vert");
                var Projectile_main = ManifestResourceLoader.LoadTextFile(@"Shaders\Main\Projectile_main.vert");


                var vertexShaderSource =
                    Header +
                    Rotator +
                    Cuter +
                    Sun +
                    Main;

                var FragmentalShader = ManifestResourceLoader.LoadTextFile(@"Shaders\OtherShaders\FragmentalShader.frag");
                var GeometryShader   = ManifestResourceLoader.LoadTextFile(@"Shaders\OtherShaders\GeometryShader.geom");
                shaderProgram = new ModifiedShaderProgram();
                shaderProgram.Create(gl, vertexShaderSource, FragmentalShader, GeometryShader, null);
                shaderProgram.BindAttributeLocation(gl, attributeIndexPosition, "in_Position");
                shaderProgram.BindAttributeLocation(gl, attributeIndexColour, "in_Color");
                shaderProgram.AssertValid(gl);

                var vertexShaderSource2 =
                    Header +
                    Rotator +
                    Cuter +
                    Sun +
                    Translation +
                    Sizer +
                    Explosion +
                    Adv_main;

                shaderProgram_secondary = new ModifiedShaderProgram();
                shaderProgram_secondary.Create(gl, vertexShaderSource2, FragmentalShader, GeometryShader, null);
                shaderProgram_secondary.BindAttributeLocation(gl, attributeIndexPosition, "in_Position");
                shaderProgram_secondary.BindAttributeLocation(gl, attributeIndexColour, "in_Color");
                shaderProgram_secondary.BindAttributeLocation(gl, 2, "in_Center");
                shaderProgram_secondary.BindAttributeLocation(gl, 3, "in_Angles");
                shaderProgram_secondary.BindAttributeLocation(gl, 4, "in_Size");
                shaderProgram_secondary.AssertValid(gl);

                var vertexShaderSource3 =
                    Header +
                    Rotator +
                    Cuter +
                    Sun +
                    Translation +
                    Sizer +
                    Explosion +
                    Projectile_main;

                shaderProgram_projectile = new ModifiedShaderProgram();
                shaderProgram_projectile.Create(gl, vertexShaderSource3, FragmentalShader, GeometryShader, null);
                shaderProgram_projectile.BindAttributeLocation(gl, attributeIndexPosition, "in_Position");
                shaderProgram_projectile.BindAttributeLocation(gl, attributeIndexColour, "in_Color");
                shaderProgram_projectile.BindAttributeLocation(gl, 2, "in_Center");
                shaderProgram_projectile.BindAttributeLocation(gl, 3, "in_Angles");
                shaderProgram_projectile.BindAttributeLocation(gl, 4, "in_Size");
                shaderProgram_projectile.AssertValid(gl);
            }
            catch (ShaderCompilationException ShadersMessageError)
            {
                ShadersInitializated = false;
                ShadersWereNotInitializatedMessage = ShadersMessageError.CompilerOutput;
                MessageBox.Show(ShadersWereNotInitializatedMessage);
                //Environment.Exit(123);
            }

            if (ShadersInitializated)
            {
                //  Create a perspective projection matrix.

                //  Create a model matrix to make the model a little bigger.
                modelMatrix = glm.scale(new mat4(1.0f), new vec3(Environment.SizeView));

                //  Now create the geometry for the square.
                SS.Main.scene_info.CreateVerticesForSquare_not_angled();

                var handle = GetConsoleWindow();
                if (!StaticSettings.S.ConsoleIsEnabled)
                {
                    ShowWindow(handle, SW_HIDE);
                }

                Scene.SS.env.player.coords.Player_precise_position.TryLoad("PlayerPosition");
                Scene.SS.env.player.coords.Player_rotational_view.TryLoad("PlayerRotationalView");
                SaveAndLoad.Load("default");

                Reloader_SunAndMoon();

                gl.Enable(OpenGL.GL_BLEND);
                gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA);
            }

            if (StaticSettings.S.LoadProjectile)
            {
                Projectile.jp.LoadFromFile();
            }
        }