Beispiel #1
0
        public void RenderObject()
        {
            // set up
            float[] vertices = new float[] { -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f, 0.0f, 0.5f, 0.0f };
            int     vao;
            VertexBufferObject <float> vbo;

            GL.GenVertexArrays(1, out vao);
            vbo = new VertexBufferObject <float>(sizeof(float), vertices);
            GL.BindVertexArray(vao);
            vbo.BindBuffer();
            vbo.CreateBuffer(BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 3 * sizeof(float), 0);
            GL.EnableVertexAttribArray(0);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
            GL.BindVertexArray(0);
            //actual renderering
            GL.ClearColor(OpenTK.Graphics.Color4.CornflowerBlue);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            shaderMgr.InitialiseAShader("test1");
            shaderMgr.GetShader("test1").Use();
            GL.BindVertexArray(vao);
            vbo.Draw(PrimitiveType.Triangles);
            GL.BindVertexArray(0);
        }
Beispiel #2
0
        public void RenderObject(VertexBufferObject <Vertex> vbo, VertexArrayObject <Vertex> vao, int shaderIndex, Matrix4 modelTransform, int textureIndex)
        {
            ApplySettingsNow();
            if (!depthteston)
            {
                GL.Enable(EnableCap.DepthTest);
                depthteston = true;
            }
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            shaderMgr.InitialiseAShader(shaderIndex);
            Uniform.Matrix4Uniform model = new Uniform.Matrix4Uniform("model");
            model.Matrix = modelTransform;
            Uniform.Matrix4Uniform view = new Uniform.Matrix4Uniform("view");
            view.Matrix = cameraMgr.GetActiveCamera().GetVeiwMatrix();
            Uniform.Matrix4Uniform projection = new Uniform.Matrix4Uniform("projection");
            projection.Matrix = GetProjectionMatrix();
            Shader shader = shaderMgr.GetShader(shaderIndex);

            shader.Use();
            model.Set(shader);
            view.Set(shader);
            projection.Set(shader);
            GL.ActiveTexture(TextureUnit.Texture0);
            textureMgr.GetTexture(textureIndex).BindTexture();
            textureMgr.GetTexture(textureIndex).ActivateTexture(TextureUnit.Texture0, shader, "theTexture", 0);
            vao.Bind();
            vbo.BindBuffer();
            vbo.Draw(PrimitiveType.Triangles);
        }
Beispiel #3
0
        public void RenderObject(VertexBufferObject <Vertex> item, VertexArrayObject <Vertex> vao, int shaderIndex)
        {
            if (settingschanged)
            {
                ApplySettingsNow();
            }
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            shaderMgr.InitialiseAShader(shaderIndex);
            Shader shader = shaderMgr.GetShader(shaderIndex);

            shader.Use();
            vao.Bind();
            item.BindBuffer();
            item.Draw(PrimitiveType.Triangles);
        }
Beispiel #4
0
        public void RenderObject(VertexBufferObject <Vertex> vbo, VertexArrayObject <Vertex> vao, int shaderIndex, Matrix4 modelTransform)
        {
            ApplySettingsNow();
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            shaderMgr.InitialiseAShader(shaderIndex);
            Uniform.Matrix4Uniform model = new Uniform.Matrix4Uniform("model");
            model.Matrix = modelTransform;
            Uniform.Matrix4Uniform view = new Uniform.Matrix4Uniform("view");
            view.Matrix = cameraMgr.GetActiveCamera().GetVeiwMatrix();
            Uniform.Matrix4Uniform projection = new Uniform.Matrix4Uniform("projection");
            projection.Matrix = GetProjectionMatrix();
            Shader shader = shaderMgr.GetShader(shaderIndex);

            shader.Use();
            model.Set(shader);
            view.Set(shader);
            projection.Set(shader);
            vao.Bind();
            vbo.BindBuffer();
            vbo.Draw(PrimitiveType.Triangles);
        }
Beispiel #5
0
        public void RenderBackGround()
        {
            //create the cylinder if needed
            if (BGvbo == null)
            {
                CreateBackgroundCone();
            }
            if (depthteston)
            {
                GL.Disable(EnableCap.DepthTest);
                depthteston = false;
            }
            Shader shader = null;

            if (BGData.FogStart < BGData.FogEnd & BGData.FogStart < 600.0f)
            {
                shaderMgr.InitialiseAShader("BackgroundFog");
                shader = shaderMgr.GetShader("BackgroundFog");
                BackgroundFog(shader);
            }
            else
            {
                shaderMgr.InitialiseAShader("BackgroundNoFog");
                shader = shaderMgr.GetShader("BackgroundNoFog");
            }
            shader.Use();
            textureMgr.GetTexture(BGData.BackgroundTextureIndex).ActivateTexture(TextureUnit.Texture0, shader, "background", 0);
            BGvao.Bind();
            BGvbo.BindBuffer();
            BGSideWallebo.Bind();
            BGCapsebo.Bind();
            BGSideWallebo.Draw(PrimitiveType.Quads);
            BGCapsebo.Draw(PrimitiveType.Triangles);
            BGvao.UnBind();
            BGvbo.UnBind();
            BGSideWallebo.Unbind();
            BGCapsebo.Unbind();
        }