Exemple #1
0
        //Main Methods
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            uModelLocation = GL.GetUniformLocation(mShader.ShaderProgramID, "uModel");

            float viewDistance = 200;

            //Resets matrix
            int     uProjectionLocation = GL.GetUniformLocation(mShader.ShaderProgramID, "uProjection");
            Matrix4 projection          = Matrix4.CreatePerspectiveFieldOfView(1, (float)ClientRectangle.Width / ClientRectangle.Height, 0.5f, viewDistance);

            GL.UniformMatrix4(uProjectionLocation, true, ref projection);

            //Renders the objects to the screen buffer
            Frame_Buffer.Unbind_Buffer();
            Render_Objects();

            GL.BindVertexArray(0);
            this.SwapBuffers();

            projection = Matrix4.CreatePerspectiveFieldOfView(1, Bottom_Portal.mWidth / Bottom_Portal.mHeight, 0.5f, viewDistance);
            GL.UniformMatrix4(uProjectionLocation, true, ref projection);

            //Renders to Texture for the portal
            RenderToTexture_Bottom_Portal();

            RenderToTexture_Top_Portal();
        }  //Draw
Exemple #2
0
        //Renders to Texture
        private void RenderToTexture_Bottom_Portal()
        {
            //Bind
            Bottom_Portal.Bind_Buffer();
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            Portal_ViewportUpdate();

            GL.Enable(EnableCap.CullFace);
            int uView = GL.GetUniformLocation(mShader.ShaderProgramID, "uView");

            Matrix4 previousView = mView;

            mView = mTopPortalView;
            GL.UniformMatrix4(uView, true, ref mView);

            camera.UpdateLightPositions();

            Material.silver.Assign_Material();
            BrickWall.MakeActive();
            //Draws Cubes
            GL.BindVertexArray(mVAO[1]);
            DrawTopBox(mBoxMatrix * mGroundModel * Level.Level0);
            DrawBox(mBoxMatrix * mGroundModel * Level.Level1);
            DrawBox(mBoxMatrix * mGroundModel * Level.Level2);
            DrawBottomBox(mBoxMatrix * mGroundModel * Level.Level3);

            //Draws the Spheres
            GL.BindVertexArray(mVAO[0]);
            foreach (Sphere s in Sphere.DrawList)
            {
                s.Draw();
            }

            //This stops the back of cylinders from not being drawn
            GL.Disable(EnableCap.CullFace);

            //Draws Cylinders
            GL.BindVertexArray(mVAO[2]);
            foreach (Cylinder c in Level.Level1_Cylinders) //LEVEL 1
            {
                Level.Draw_Cylinders(c, Level.Level1);
            }

            mView = previousView;
            GL.UniformMatrix4(uView, true, ref mView);

            //Unbind
            Frame_Buffer.Unbind_Buffer();
        }
Exemple #3
0
        private void RenderToTexture_Top_Portal()
        {
            //Bind
            Top_Portal.Bind_Buffer();
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            Portal_ViewportUpdate();

            GL.Enable(EnableCap.CullFace);
            int uView = GL.GetUniformLocation(mShader.ShaderProgramID, "uView");

            Matrix4 previousView = mView;

            mView = mBottomPortalView;
            GL.UniformMatrix4(uView, true, ref mView);

            camera.UpdateLightPositions();

            //Draws the Spheres
            GL.BindVertexArray(mVAO[0]);
            foreach (Sphere s in Sphere.DrawList)
            {
                s.Draw();
            }

            GL.BindVertexArray(mVAO[1]);
            DrawTopBox(mBoxMatrix * mGroundModel * Level.Level0);
            DrawBox(mBoxMatrix * mGroundModel * Level.Level1);
            DrawBox(mBoxMatrix * mGroundModel * Level.Level2);
            DrawBottomBox(mBoxMatrix * mGroundModel * Level.Level3);

            //SoD
            GL.BindVertexArray(mVAO[0]);
            Level.DoomSphere.Apply_MaterialValues();
            Matrix4 DoomSphereLocation = Matrix4.CreateScale(Level.DoomSphere.mRadius) * Matrix4.CreateTranslation(Level.DoomSphere.mPosition) * Level.Level3 * mGroundModel;

            GL.UniformMatrix4(uModelLocation, true, ref DoomSphereLocation);
            GL.DrawElements(BeginMode.Triangles, mSphereModel.Indices.Length, DrawElementsType.UnsignedInt, 0);

            mView = previousView;
            GL.UniformMatrix4(uView, true, ref mView);

            //Unbind
            Frame_Buffer.Unbind_Buffer();
        }