Exemplo n.º 1
0
        public GLRenderer(bool rendererVisible)
        {
            var mode = new GraphicsMode(new ColorFormat(32), 24, 0, 0, ColorFormat.Empty, 1);
            var win  = new GameWindow(1920, 1080, mode, "NightcoreStudio Renderer", GameWindowFlags.FixedWindow, DisplayDevice.Default, 3, 3, GraphicsContextFlags.Default);

            win.Visible = rendererVisible;
            if (!rendererVisible)
            {
                win.WindowBorder = WindowBorder.Hidden;
            }
            win.MakeCurrent();
            window = win;

            ImageShader = new ImageShader();
            FlatShader  = new FlatShader();

            GL.Enable(EnableCap.Texture2D);
            GL.ClearColor(Color.Purple);

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

            ProjectionMatrix = Matrix4.CreateOrthographicOffCenter(0f, 1920f, 1080f, 0f, 0.0f, 1.0f);

            Models.BuildModels();
        }
Exemplo n.º 2
0
        private static void RenderFlatShader(this Image <Rgba32> screen, float[,] zBuffer)
        {
            var viewPort = CreateViewPort(0, 0, ScreenWidth, ScreenHeight);
            var light    = new Vector3(0, 0, -1).Normalize();

            var shader = new FlatShader
            {
                Transform = viewPort,
                Light     = light
            };

            var model = ModelUtils.LoadModel(@"Resources\Head\Model.obj");

            screen.Render(model, shader, zBuffer);
        }