Ejemplo n.º 1
0
        public static ShaderProgram GetHighlightShaderProgram()
        {
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(GetShaderSource(ShaderType.VertexShader), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(GetShaderSource(ShaderType.FragmentShader), ShaderType.FragmentShader);

            var shaderProgram = new ShaderProgram();
            shaderProgram.Create((from item in shaderCodes select item.CreateShader()).ToArray());

            return shaderProgram;
        }
Ejemplo n.º 2
0
        public static ShaderProgram GetPickingShaderProgram()
        {
            ShaderCode[] shaders = new ShaderCode[2];
            shaders[0] = new ShaderCode(GetShaderSource(ShaderType.VertexShader), ShaderType.VertexShader);
            shaders[1] = new ShaderCode(GetShaderSource(ShaderType.FragmentShader), ShaderType.FragmentShader);

            var shaderProgram = new ShaderProgram();

            shaderProgram.Create((from item in shaders select item.CreateShader()).ToArray());

            return(shaderProgram);
        }
Ejemplo n.º 3
0
        public static ShaderProgram GetPickingShaderProgram()
        {
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(GetShaderSource(ShaderType.VertexShader), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(GetShaderSource(ShaderType.FragmentShader), ShaderType.FragmentShader);

            ShaderProgram program = new ShaderProgram();
            var shaders = (from item in shaderCodes select item.CreateShader()).ToArray();
            program.Create(shaders);
            foreach (var item in shaders) { item.Delete(); }

            return program;
        }
        protected override void DoInitialize()
        {
            // init shader program
            ShaderProgram program = new ShaderProgram();
            var           shaders = (from item in shaderCode select item.CreateShader()).ToArray();

            program.Create(shaders);
            this.shaderProgram = program;
            foreach (var item in shaders)
            {
                item.Delete();
            }

            // init property buffer objects
            var propertyBufferPtrs = new PropertyBufferPtr[propertyNameMap.Count()];
            int index = 0;

            foreach (var item in propertyNameMap)
            {
                PropertyBufferPtr bufferPtr = this.bufferable.GetProperty(
                    item.nameInIBufferable, item.VarNameInShader);
                if (bufferPtr == null)
                {
                    throw new Exception();
                }
                propertyBufferPtrs[index++] = bufferPtr;

                if (item.nameInIBufferable == positionNameInIBufferable)
                {
                    this.positionBufferPtr = new PropertyBufferPtr(
                        "in_Position",// in_Postion same with in the PickingShader.vert shader
                        bufferPtr.BufferID,
                        bufferPtr.DataSize,
                        bufferPtr.DataType,
                        bufferPtr.Length,
                        bufferPtr.ByteLength);
                }
            }
            this.propertyBufferPtrs = propertyBufferPtrs;

            // init index buffer object's renderer
            this.indexBufferPtr = this.bufferable.GetIndex();

            this.bufferable      = null;
            this.shaderCode      = null;
            this.propertyNameMap = null;

            InitializeElementCount();
        }
Ejemplo n.º 5
0
        protected override void DoInitialize()
        {
            // init shader program
            ShaderProgram program = PickingShaderHelper.GetPickingShaderProgram();
            var           shaders = (from item in shaderCodes select item.CreateShader()).ToArray();

            program.Create(shaders);
            this.shaderProgram = program;
            foreach (var item in shaders)
            {
                item.Delete();
            }

            // init property buffer objects
            var propertyBufferPtrs = new PropertyBufferPtr[propertyNameMap.Count()];
            int index = 0;

            foreach (var item in propertyNameMap)
            {
                if (index <= 0)
                {
                    if (item.nameInIBufferable == this.positionNameInIBufferable)
                    {
                        PropertyBufferPtr bufferPtr = this.bufferable.GetProperty(
                            item.nameInIBufferable, item.VarNameInShader);
                        if (bufferPtr == null)
                        {
                            throw new Exception();
                        }
                        propertyBufferPtrs[index++] = bufferPtr;
                        this.positionBufferPtr      = bufferPtr;
                    }
                }
                else
                {
                    if (item.nameInIBufferable == this.positionNameInIBufferable)
                    {
                        throw new Exception("More than 1 property named as position buffer~");
                    }
                }
            }

            this.propertyBufferPtrs = propertyBufferPtrs;
            this.indexBufferPtr     = this.bufferable.GetIndex();
        }
Ejemplo n.º 6
0
        public static ShaderProgram GetPickingShaderProgram()
        {
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(GetShaderSource(ShaderType.VertexShader), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(GetShaderSource(ShaderType.FragmentShader), ShaderType.FragmentShader);

            ShaderProgram program = new ShaderProgram();
            var           shaders = (from item in shaderCodes select item.CreateShader()).ToArray();

            program.Create(shaders);
            foreach (var item in shaders)
            {
                item.Delete();
            }

            return(program);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        protected override void DoInitialize()
        {
            // init shader program
            var program = new ShaderProgram();
            var shaders = (from item in shaderCodes select item.CreateShader()).ToArray();

            program.Create(shaders);
            this.Program = program;
            foreach (var item in shaders)
            {
                item.Delete();
            }

            // init property buffer objects
            var propertyBufferPtrs = new PropertyBufferPtr[propertyNameMap.Count()];
            int index = 0;

            foreach (var item in propertyNameMap)
            {
                PropertyBufferPtr bufferPtr = this.bufferable.GetProperty(
                    item.NameInIBufferable, item.VarNameInShader);
                if (bufferPtr == null)
                {
                    throw new Exception(string.Format("[{0}] returns null buffer pointer!", this.bufferable));
                }
                propertyBufferPtrs[index++] = bufferPtr;
            }

            this.propertyBufferPtrs = propertyBufferPtrs;
            this.indexBufferPtr     = this.bufferable.GetIndex();

            // RULE: Renderer takes uint.MaxValue, ushort.MaxValue or byte.MaxValue as PrimitiveRestartIndex. So take care this rule when designing a model's index buffer.
            var ptr = this.indexBufferPtr as OneIndexBufferPtr;

            if (ptr != null)
            {
                GLSwitch glSwitch = new PrimitiveRestartSwitch(ptr);
                this.switchList.Add(glSwitch);
            }
        }
Ejemplo n.º 8
0
        protected override void DoInitialize()
        {
            // init shader program
            ShaderProgram program = new ShaderProgram();
            var           shaders = (from item in shaderCodes select item.CreateShader()).ToArray();

            program.Create(shaders);
            this.shaderProgram = program;
            foreach (var item in shaders)
            {
                item.Delete();
            }

            // init property buffer objects
            var propertyBufferPtrs = new PropertyBufferPtr[propertyNameMap.Count()];
            int index = 0;

            foreach (var item in propertyNameMap)
            {
                PropertyBufferPtr bufferPtr = this.bufferable.GetProperty(
                    item.nameInIBufferable, item.VarNameInShader);
                if (bufferPtr == null)
                {
                    throw new Exception();
                }
                propertyBufferPtrs[index++] = bufferPtr;
            }

            this.propertyBufferPtrs = propertyBufferPtrs;
            this.indexBufferPtr     = this.bufferable.GetIndex();

            var ptr = this.indexBufferPtr as OneIndexBufferPtr;

            if (ptr != null)
            {
                var glSwitch = new PrimitiveRestartSwitch(ptr);
                this.switchList.Add(glSwitch);
            }
        }