Beispiel #1
0
        // --------------------------------------------------------------------

        public void RenderScene(Scene scene, Camera cam, int w, int h)
        {
            Onyx3D.MakeCurrent();

            GL.Viewport(0, 0, w, h);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            cam.UpdateUBO();

            scene.Lighting.UpdateUBO(scene);

            if (scene.IsDirty)
            {
                scene.UpdateRenderData();
                BakeReflectionProbes(scene, false);
            }

            PrepareMaterials(scene, cam.UBO, scene.Lighting.UBO);

            RenderSky(scene, cam);
            RenderMeshes(scene);
            RenderEntities(scene);

            GL.Flush();
        }
Beispiel #2
0
        // ----------------------------------------------------------------  Getters

        private T GetResource <T>(int id, Dictionary <int, T> map, Func <OnyxProjectAsset, T> loadFallback, int defaultAsset) where T : GameAsset
        {
            if (!map.ContainsKey(id))
            {
                OnyxProjectAsset asset = ProjectManager.Instance.Content.GetAsset(id);
                if (asset == null)
                {
                    if (defaultAsset > 0)
                    {
                        return(GetResource(defaultAsset, map, loadFallback, 0));
                    }
                    else
                    {
                        return(null);
                    }
                }

                Onyx3D.MakeCurrent();
                map[id] = loadFallback(asset);
                map[id].LinkedProjectAsset = asset;
            }

            return(map[id]);
        }