Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        public override void RenderGUIBeforeChildren(GUIRenderEventArgs arg)
        {
            base.RenderGUIBeforeChildren(arg);

            ModernRenderUnit unit   = this.RenderUnit;
            RenderMethod     method = unit.Methods[0];

            method.Render(IndexAccessMode.Random);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        public override void RenderGUIBeforeChildren(GUIRenderEventArgs arg)
        {
            base.RenderGUIBeforeChildren(arg);

            ModernRenderUnit  unit        = this.RenderUnit;
            RenderMethod      method      = unit.Methods[0];
            VertexArrayObject vao         = method.VertexArrayObject;
            IndexBuffer       indexBuffer = vao.IndexBuffer;

            method.Render();
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        public CtrlButtonRenderer()
        {
            var model = new CtrlImageModel();
            var vs    = new VertexShader(vert, inPosition, inUV);
            var fs    = new FragmentShader(frag);
            var codes = new ShaderArray(vs, fs);
            var map   = new AttributeMap();

            map.Add(inPosition, CtrlImageModel.position);
            var methodBuilder = new RenderMethodBuilder(codes, map);

            this.RenderUnit = new ModernRenderUnit(model, methodBuilder);
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        public override void RenderGUIBeforeChildren(GUIRenderEventArgs arg)
        {
            base.RenderGUIBeforeChildren(arg);

            ModernRenderUnit unit    = this.RenderUnit;
            RenderMethod     method  = unit.Methods[0];
            Texture          texture = this.textureSource.BindingTexture;

            if (texture != null)
            {
                method.Program.SetUniform("tex", texture);
            }
            method.Render();
        }
Esempio n. 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bitmap">bitmap to be displayed.</param>
        /// <param name="autoDispose">auto dispose <paramref name="bitmap"/> after this object's initialization.</param>
        public CtrlImageRenderer(Bitmap bitmap, bool autoDispose = false)
        {
            var model = new CtrlImageModel();
            var vs    = new VertexShader(vert, inPosition, inUV);
            var fs    = new FragmentShader(frag);
            var codes = new ShaderArray(vs, fs);
            var map   = new AttributeMap();

            map.Add(inPosition, CtrlImageModel.position);
            map.Add(inUV, CtrlImageModel.uv);
            var methodBuilder = new RenderMethodBuilder(codes, map, new BlendState(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha));

            this.RenderUnit = new ModernRenderUnit(model, methodBuilder);

            this.bitmap      = bitmap;
            this.autoDispose = autoDispose;
        }
Esempio n. 6
0
        public void RenderBeforeChildren(RenderEventArgs arg)
        {
            // gets mvpMat.
            ICamera camera        = arg.Camera;
            mat4    projectionMat = camera.GetProjectionMatrix();
            mat4    viewMat       = camera.GetViewMatrix();
            mat4    modelMat      = this.GetModelMatrix();
            mat4    mvpMat        = projectionMat * viewMat * modelMat;
            // a render uint wraps everything(model data, shaders, glswitches, etc.) for rendering.
            ModernRenderUnit unit = this.RenderUnit;
            // gets render method.
            // There could be more than 1 method(vertex shader + fragment shader) to render the same model data. Thus we need an method array.
            RenderMethod method = unit.Methods[0];
            // shader program wraps vertex shader and fragment shader.
            ShaderProgram program = method.Program;

            //set value for 'uniform mat4 mvpMat'; in shader.
            program.SetUniform("mvpMat", mvpMat);
            // render the cube model via OpenGL.
            method.Render();
        }