Exemple #1
0
        /// <summary>Renders an object based background</summary>
        /// <param name="data">The background object</param>
        private void RenderBackgroundObject(BackgroundObject data)
        {
            if (renderer.AvailableNewRenderer)
            {
                renderer.DefaultShader.Activate();
                renderer.DefaultShader.SetCurrentProjectionMatrix(renderer.CurrentProjectionMatrix);

                if (data.Object.Mesh.VAO == null)
                {
                    VAOExtensions.CreateVAO(ref data.Object.Mesh, false, renderer.DefaultShader.VertexLayout);
                }
            }

            foreach (MeshFace face in data.Object.Mesh.Faces)
            {
                OpenGlTextureWrapMode wrap = OpenGlTextureWrapMode.ClampClamp;

                if (data.Object.Mesh.Materials[face.Material].DaytimeTexture != null)
                {
                    if (data.Object.Mesh.Materials[face.Material].WrapMode == null)
                    {
                        foreach (VertexTemplate vertex in data.Object.Mesh.Vertices)
                        {
                            if (vertex.TextureCoordinates.X < 0.0f || vertex.TextureCoordinates.X > 1.0f)
                            {
                                wrap |= OpenGlTextureWrapMode.RepeatClamp;
                            }

                            if (vertex.TextureCoordinates.Y < 0.0f || vertex.TextureCoordinates.Y > 1.0f)
                            {
                                wrap |= OpenGlTextureWrapMode.ClampRepeat;
                            }
                        }

                        data.Object.Mesh.Materials[face.Material].WrapMode = wrap;
                    }
                }

                if (renderer.AvailableNewRenderer)
                {
                    renderer.RenderFace(renderer.DefaultShader, new ObjectState {
                        Prototype = data.Object
                    }, face, Matrix4D.NoTransformation, Matrix4D.Scale(1.0) * renderer.CurrentViewMatrix);
                }
                else
                {
                    renderer.RenderFaceImmediateMode(new ObjectState {
                        Prototype = data.Object
                    }, face, Matrix4D.NoTransformation, Matrix4D.Scale(1.0) * renderer.CurrentViewMatrix);
                }
            }

            if (renderer.AvailableNewRenderer)
            {
                renderer.DefaultShader.Deactivate();
            }
        }
Exemple #2
0
 public void Draw()
 {
     if (Renderer.AvailableNewRenderer)
     {
         Renderer.RenderFace(this);
     }
     else
     {
         Renderer.RenderFaceImmediateMode(this);
     }
 }