Beispiel #1
0
        private void HelloVRWindow_Load(object sender, EventArgs e)
        {
            GL.ClearColor(Color.White);
            scene.InitGraphics(new GLVRGraphics(scene, true));

            // setup input handling
            KeyDown += HelloVRWindow_KeyDown;
        }
Beispiel #2
0
        private void BasicVis_Load(object sender, EventArgs e)
        {
            GL.ClearColor(Color.White);
            GL.Enable(EnableCap.DepthTest);                                                // enable depth testing
            GL.DepthFunc(DepthFunction.Less);                                              // only accept fragment if it is closer to the camera than whats in there already
            GL.Enable(EnableCap.Multisample);                                              // standard AA
            GL.Enable(EnableCap.Blend);                                                    // transparency
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); // transparency func

            if (VRFlag)
            {
                WindowState = WindowState.Minimized;
                vrScene.InitGraphics(new GLVRGraphics(vrScene, true)); // always use GL graphics
            }
            else
            {
                WindowBorder    = WindowBorder.Hidden;
                WindowState     = WindowState.Fullscreen;
                CursorVisible   = false;
                Camera.IsLocked = false;
            }

            mainProgram    = new LitMaterialProgram();
            depthProgram   = new DepthMapProgram();
            textureProgram = new SimpleTextureProgram();
            vertexBufferID = OpenGLUtil.CreateBufferObject();

            UpdateBodiesCollection(); // incase any bodies were added/removed before the window loaded
            PopulateVertexBuffer();

            // create and frame buffer and shadow map for each light source if they cast shadows
            // this only occurs once
            foreach (var light in LightSources)
            {
                OpenGLLightSource glLight = light.ToGLLight();
                if (light.CastsDynamicShadows)
                {
                    glLight.FrameBufferID = OpenGLUtil.CreateFrameBuffer();
                    glLight.ShadowMapID   = OpenGLUtil.CreateDepthTexture(glLight.FrameBufferID, ShadowMapSize);
                }
                openGLLights.Add(glLight);
            }
        }