コード例 #1
0
ファイル: Application.cs プロジェクト: BJDubb/Fury
        public void Run()
        {
            Logger.Info("Welcome to the Fury Engine!");
            Logger.Info("Platform: " + RuntimeInformation.OSDescription);

            ImGuiController.Init(window);

            while (running)
            {
                double time    = GLFW.GetTime();
                float  elapsed = (float)(time - lastFrameTime);
                Time.deltaTime = elapsed;
                lastFrameTime  = time;

                if (!window.Minimised)
                {
                    foreach (Layer layer in layerStack.Layers)
                    {
                        layer.OnUpdate();
                    }

                    ImGuiController.Begin(window);
                    foreach (Layer layer in layerStack.Layers)
                    {
                        layer.OnImGuiRender();
                    }
                    ImGuiController.End();
                }

                window.OnUpdate();
            }
        }
コード例 #2
0
ファイル: MainWindow.cs プロジェクト: EnKdev/UserTCQ
        private void Update()
        {
            lastTime = (float)GLFW.GetTime();

            earlyUpdateEvent?.Invoke();
            updateEvent?.Invoke();

            lateUpdateEvent?.Invoke();

            GameObject.instances.Sort(new ByZPosition());
        }
コード例 #3
0
ファイル: MainWindow.cs プロジェクト: EnKdev/UserTCQ
        private void Draw()
        {
            postProcessor.Begin();

            GL.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            RenderObjects();

            postProcessor.End();
            postProcessor.Render();

            RenderGUI();

            SwapBuffers();

            Time.deltaTimeUnscaled = (float)GLFW.GetTime() - lastTime;
            Time.deltaTime         = Time.deltaTimeUnscaled * Time.timeScale;
        }
コード例 #4
0
        static void Main()
        {
            Console.WriteLine($"Working directory: '{Path.GetFullPath(".")}'.");

            PrepareGLFW();
            PrepareOpenGL();
            PrepareOpenAL();

            //double timePrev = 0d;

            CheckGLErrors();

            float[] points =
            {
                0.0f,   0.5f, 0.0f,
                0.5f,  -0.5f, 0.0f,
                -0.5f, -0.5f, 0.0f
            };

            uint vbo = GL.GenBuffer();

            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
            GL.BufferData(BufferTarget.ArrayBuffer, points.Length * sizeof(float), points, BufferUsageHint.StaticDraw);

            uint vao = GL.GenVertexArray();

            GL.BindVertexArray(vao);
            GL.EnableVertexAttribArray(0);
            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, IntPtr.Zero);

            string vertexShader   = @"#version 330 core
in vec3 vertex;
void main() {
	gl_Position = vec4(vertex,1.0);
}";
            string fragmentShader = @"#version 330 core
out vec4 color;
void main() {
	color = vec4(1.0,0.5,0.0,1.0);
}";

            uint vs = GL.CreateShader(ShaderType.VertexShader);

            GL.ShaderSource(vs, vertexShader);
            GL.CompileShader(vs);

            uint fs = GL.CreateShader(ShaderType.FragmentShader);

            GL.ShaderSource(fs, fragmentShader);
            GL.CompileShader(fs);

            uint program = GL.CreateProgram();

            GL.AttachShader(program, vs);
            GL.AttachShader(program, fs);
            GL.LinkProgram(program);

            while (GLFW.WindowShouldClose(window) == 0)
            {
                GLFW.PollEvents();

                double time = GLFW.GetTime();
                //double deltaTime = time-timePrev;
                //timePrev = time;

                GLFW.GetFramebufferSize(window, out int width, out int height);

                GL.Viewport(0, 0, width, height);

                var(colorR, colorG, colorB) = GetRainbowColor((float)time * 0.75f);

                colorR = Math.Max(colorR, 0.9f);
                colorG = Math.Max(colorG, 0.9f);
                colorB = Math.Max(colorB, 0.9f);

                GL.ClearColor(colorR, colorG, colorB);                 //GL.ClearColor(70/255f,130/255f,180/255f);
                GL.Clear(ClearBufferMask.ColorBufferBit);

                GL.UseProgram(program);
                GL.BindVertexArray(vao);
                GL.DrawArrays(PrimitiveType.Triangles, 0, points.Length / 3);

                GLFW.SwapBuffers(window);

                CheckGLErrors();

                Thread.Sleep(1);
            }

            UnloadOpenAL();
            UnloadGLFW();
        }
コード例 #5
0
ファイル: Time.cs プロジェクト: benanil/Zargo-Engine
 public static void Start()
 {
     StartTime = (float)GLFW.GetTime();
 }