Abstract class Device.

Contains Standard Rendering Methods and State Management.

상속: IDisposable
예제 #1
0
        public IndexBuffer(Device device, BufferUsage usage)  
        {
            this.device = device;

            this.usage = usage;

            Gl.glGenBuffersARB(1, out this.handle);
        }
예제 #2
0
        public RenderBuffer(Device device, int width, int height, int samples)
        {
            this.device  = device;
            this.width   = width;
            this.height  = height;
            this.samples = samples;

            Gl.glGenRenderbuffersEXT(1, out this.handle);
        }
예제 #3
0
        public Shader(Device device)
        {
            this.device            = device;
            this.texturecount      = 0;
            this.programHandle     = Gl.glCreateProgram();
            this.vertexHandle      = 0;
            this.fragmentHandle    = 0;
            this.geometryHandle    = 0;
            
            this.vertexSource      = string.Empty;
            this.fragmentSource    = string.Empty;
            this.geometrySource    = string.Empty;

            this.inputTopology     = Topology.Triangles;
            this.outputTopology    = Topology.Triangles;
            this.outputVertexCount = 3;
        }
예제 #4
0
 public RenderBuffer(Device device, int width, int height) : this(device, width, height, 1) { }
예제 #5
0
        public DepthBuffer(Device device, int width, int height, Depth depth, int samples) : base(device, width, height, samples)
        {
            this.depth = depth;

            Gl.glBindRenderbufferEXT              (Gl.GL_RENDERBUFFER_EXT, this.Handle);

            if (samples == 0)
            {
                Gl.glRenderbufferStorageEXT(Gl.GL_RENDERBUFFER_EXT, (int)this.depth, this.Width, this.Height);
            }
            else
            {
                Gl.glRenderbufferStorageMultisampleEXT(Gl.GL_RENDERBUFFER_EXT, this.Samples, (int)this.depth, this.Width, this.Height);
            }
        }
예제 #6
0
 public DepthBuffer(Device device, int width, int height, Depth depth) : this(device, width, height, depth, 0) { }
예제 #7
0
        public ColorBuffer(Device device, int width, int height, TextureFormat format, int samples) : base(device, width, height, samples)
        {
            this.format = format;
            
            Gl.glBindRenderbufferEXT              (Gl.GL_RENDERBUFFER_EXT, this.Handle);

            if (samples == 0)
            {
                Gl.glRenderbufferStorageEXT(Gl.GL_RENDERBUFFER_EXT, (int)format, this.Width, this.Height);
            }
            else
            {
                Gl.glRenderbufferStorageMultisampleEXT(Gl.GL_RENDERBUFFER_EXT, this.Samples, (int)this.format, this.Width, this.Height);
            }
        }
예제 #8
0
 public ColorBuffer(Device device, int width, int height, TextureFormat format) : this(device, width, height, format, 0) { }
예제 #9
0
        public FrameBuffer(Device device)
        {
            this.device   = device;

            Gl.glGenFramebuffersEXT(1, out this.handle);
        }
예제 #10
0
        /// <summary>
        /// Compiles Shaders related to this effect.
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public static List<Shader> CompileAll(Device device, ShaderLibrary library)
        {
            List<Shader> shaders = new List<Shader>();

            foreach (Program program in library.Programs)
            {
                Shader shader = new Shader(device);

                if (program.VertexShader != null)
                {
                    foreach (Source source in from   n in program.VertexShader.Includes
                                              from   m in library.Sources
                                              where  n.Source == m.ID
                                              select m)

                        shader.AppendVertexSource(source.Code);
                }

                if (program.GeometryShader != null)
                {
                    shader.InputTopology     = program.GeometryShader.InputTopology;
                    shader.OutputTopology    = program.GeometryShader.OutputTopology;
                    shader.OutputVertexCount = program.GeometryShader.OutputVertexCount;
                    foreach (Source source in from   n in program.GeometryShader.Includes
                                              from   m in library.Sources
                                              where  n.Source == m.ID
                                              select m)

                        shader.AppendGeometrySource(source.Code);

                }

                if (program.FragmentShader != null)
                {
                    foreach (Source source in from   n in program.FragmentShader.Includes
                                              from   m in library.Sources
                                              where  n.Source == m.ID
                                              select m)

                        shader.AppendFragmentSource(source.Code);
                }


                ShaderCompileResult compileResult = shader.Compile();

                if (!compileResult.HasError)
                {
                    shaders.Add(shader);
                }
                else
                {
                    throw new Exception(compileResult.Summary);
                }
            }

            return shaders;
        }