Esempio n. 1
0
        /// <summary>
        /// Center (Horizontally or Vertically) GUI Content within a Layout Area
        /// </summary>
        /// <param name="ct">Enum specifying the direction to center the content in</param>
        /// <param name="rd">Delegate function for creating centered content</param>
        public static void Center(CenterType ct, RenderDelegate rd)
        {
            if (ct != CenterType.Horizontal)
            {
                GUILayout.BeginVertical();
            }

            GUILayout.FlexibleSpace();
            if (ct != CenterType.Vertical)
            {
                GUILayout.BeginHorizontal();
            }

            GUILayout.FlexibleSpace();
            rd.Invoke();
            GUILayout.FlexibleSpace();
            if (ct != CenterType.Vertical)
            {
                GUILayout.EndHorizontal();
            }

            GUILayout.FlexibleSpace();
            if (ct != CenterType.Horizontal)
            {
                GUILayout.EndVertical();
            }
        }
Esempio n. 2
0
        } // Render(passName, renderDelegate)

        /// <summary>
        /// Render
        /// </summary>
        /// <param name="setMat">Set matrix</param>
        /// <param name="techniqueName">Technique name</param>
        /// <param name="renderDelegate">Render delegate</param>
        public void Render(Material setMat,
                           string techniqueName,
                           RenderDelegate renderDelegate)
        {
            SetParameters(setMat);

            /*will become important later in the book.
             * // Can we do the requested technique?
             * // For graphic cards not supporting ps2.0, fall back to ps1.1
             * if (BaseGame.CanUsePS20 == false &&
             *  techniqueName.EndsWith("20"))
             *  // Use same technique without the 20 ending!
             *  techniqueName = techniqueName.Substring(0, techniqueName.Length - 2);
             */

            // Start shader
            effect.CurrentTechnique = effect.Techniques[techniqueName];
            effect.Begin(SaveStateMode.None);

            // Render all passes (usually just one)
            //foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            for (int num = 0; num < effect.CurrentTechnique.Passes.Count; num++)
            {
                EffectPass pass = effect.CurrentTechnique.Passes[num];

                pass.Begin();
                renderDelegate();
                pass.End();
            } // foreach (pass)

            // End shader
            effect.End();
        } // Render(passName, renderDelegate)
Esempio n. 3
0
 public LargeColumn(IColumn <TModel, TPostModel> left, IColumn <TModel, TPostModel> middle, IColumn <TModel, TPostModel> right)
 {
     this.left   = left;
     this.middle = middle;
     this.right  = right;
     this.render = this.Small;
 }
 /// <summary>
 /// Start
 /// </summary>
 /// <param name="testName">Test name</param>
 /// <param name="initCode">Init code</param>
 /// <param name="renderCode">Render code</param>
 public static void Start(string testName,
                          RenderDelegate initCode, RenderDelegate renderCode)
 {
     using (Instance = new TestXNAGame(testName, initCode, renderCode))
     {
         Instance.Run();
     }
 }
Esempio n. 5
0
 static void OverrideRender(GLib.GType gtype)
 {
     if (RenderCallback == null)
     {
         RenderCallback = new RenderDelegate(Render_cb);
     }
     gnomesharp_canvas_item_override_render(gtype.Val, RenderCallback);
 }
        /// <summary>
        /// Start
        /// </summary>
        /// <param name="testName">Test name</param>
        /// <param name="renderCode">Render code</param>
        public static void Start(string testName,
			RenderDelegate renderCode)
        {
            using (game = new TestGame(testName, renderCode))
            {
                game.Run();
            } // using (game)
        }
Esempio n. 7
0
 /// <summary>
 /// Start
 /// </summary>
 /// <param name="testName">Test name</param>
 /// <param name="initCode">Init code</param>
 /// <param name="renderCode">Render code</param>
 public static void Start(string testName,
                          RenderDelegate initCode, RenderDelegate renderCode)
 {
     using (game = new TestGame(testName, initCode, renderCode))
     {
         game.Run();
     }     // using (game)
 }         // Start(testName, initCode, renderCode)
Esempio n. 8
0
 public ProxyHandler(RenderDelegate @delegate)
     : base(typeof (CefProxyHandler))
 {
     _delegate = @delegate;
     _getProxyForUrlCallback = GetProxyForUrl;
     MarshalToNative(new CefProxyHandler {
         Base = DedicatedBase,
         GetProxyForUrl =
             Marshal.GetFunctionPointerForDelegate(_getProxyForUrlCallback)
     });
 }
Esempio n. 9
0
        public AudioUnitStatus SetRenderCallback(RenderDelegate renderDelegate, AudioUnitScopeType scope, uint audioUnitElement = 0)
        {
            var cb = new AURenderCallbackStruct();

            cb.Proc       = CreateRenderCallback;
            cb.ProcRefCon = GCHandle.ToIntPtr(gcHandle);

            this.render = renderDelegate;

            return(AudioUnitSetProperty(handle, AudioUnitPropertyIDType.SetRenderCallback, scope, audioUnitElement, ref cb, Marshal.SizeOf(cb)));
        }
Esempio n. 10
0
        public static void Init(RenderDelegate renderCallback)
        {
            if (renderCallback == null)
            {
                throw new ArgumentNullException("renderCallback");
            }

            _callbackHandle = GCHandle.Alloc(renderCallback);

            rad_Init(Marshal.GetFunctionPointerForDelegate(renderCallback));
        }
Esempio n. 11
0
        /// <summary>
        /// Create test game
        /// </summary>
        /// <param name="setWindowsTitle">Set windows title</param>
        /// <param name="windowWidth">Window width</param>
        /// <param name="windowHeight">Window height</param>
        /// <param name="setInitCode">Set init code</param>
        /// <param name="setRenderCode">Set render code</param>
        public TestXNAGame(string setWindowsTitle, RenderDelegate setInitCode, RenderDelegate setRenderCode)
        {
            Instance = this;

            Instance.Window.Title = setWindowsTitle;

            //#if DEBUG
            //            // Force window on top
            //            WindowsHelper.ForceForegroundWindow( this.Window.Handle.ToInt32() );
            //#endif
            initCode   = setInitCode;
            renderCode = setRenderCode;
        }
        /// <summary>
        /// Create test game
        /// </summary>
        /// <param name="setWindowsTitle">Set windows title</param>
        /// <param name="windowWidth">Window width</param>
        /// <param name="windowHeight">Window height</param>
        /// <param name="setInitCode">Set init code</param>
        /// <param name="setUpdateCode">Set update code</param>
        /// <param name="setRenderCode">Set render code</param>
        protected TestGame(string setWindowsTitle,
			RenderDelegate setRenderCode)
        {
            this.Window.Title = setWindowsTitle;

            #if !XBOX360
            #if DEBUG
            // Force window on top
            WindowsHelper.ForceForegroundWindow(this.Window.Handle.ToInt32());
            #endif
            #endif
            renderCode = setRenderCode;
        }
Esempio n. 13
0
 /// <summary>
 /// Sets the view to be rendered and updates the behavior of controls accordingly.
 /// </summary>
 /// <param name="renderer">A <see cref="AccountManagementControl.RenderDelegate"/> for rendering the control.</param>
 protected override void SetView(RenderDelegate renderer)
 {
     this._renderByView = renderer;
     if (renderer == this.RenderTaskView)
     {
     }
     else if (renderer == this.RenderCreatorView)
     {
     }
     else if (renderer == this.RenderViewerView)
     {
         SetMode(ManagerMode.View);
     }
 }
Esempio n. 14
0
        public DMDDevice()
        {
            string libraryName = "dmddevice.dll";

            if (Environment.Is64BitProcess)
            {
                libraryName = "dmddevice64.dll";
            }
            var fullPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), libraryName);

            _dllhandle = NativeLibrary.LoadLibrary(fullPath);
            if (_dllhandle != IntPtr.Zero)
            {
                LogManager.GetCurrentClassLogger().Info("Loaded {0} from {1} to create a virtual DMD", libraryName, fullPath);
                var openHandle = NativeLibrary.GetProcAddress(_dllhandle, "Open");
                if (openHandle != IntPtr.Zero)
                {
                    _open = (OpenCloseDelegate)Marshal.GetDelegateForFunctionPointer(openHandle, typeof(OpenCloseDelegate));
                }
                var closeHandle = NativeLibrary.GetProcAddress(_dllhandle, "Close");
                if (closeHandle != IntPtr.Zero)
                {
                    _close = (OpenCloseDelegate)Marshal.GetDelegateForFunctionPointer(closeHandle, typeof(OpenCloseDelegate));
                }
                var renderGray2Handle = NativeLibrary.GetProcAddress(_dllhandle, "Render_4_Shades");
                if (renderGray2Handle != IntPtr.Zero)
                {
                    _renderGray2 = (RenderDelegate)Marshal.GetDelegateForFunctionPointer(renderGray2Handle, typeof(RenderDelegate));
                }
                var renderGray4Handle = NativeLibrary.GetProcAddress(_dllhandle, "Render_16_Shades");
                if (renderGray4Handle != IntPtr.Zero)
                {
                    _renderGray4 = (RenderDelegate)Marshal.GetDelegateForFunctionPointer(renderGray4Handle, typeof(RenderDelegate));
                }
                var renderRgb24Handle = NativeLibrary.GetProcAddress(_dllhandle, "Render_RGB24");
                if (renderRgb24Handle != IntPtr.Zero)
                {
                    _renderRgb24 = (RenderDelegate)Marshal.GetDelegateForFunctionPointer(renderRgb24Handle, typeof(RenderDelegate));
                }
                var gameSettingsHandle = NativeLibrary.GetProcAddress(_dllhandle, "PM_GameSettings");
                if (gameSettingsHandle != IntPtr.Zero)
                {
                    _gameSettings = (GameSettingsDelegate)Marshal.GetDelegateForFunctionPointer(gameSettingsHandle, typeof(GameSettingsDelegate));
                }
            }
            else
            {
                LogManager.GetCurrentClassLogger().Error("Failed to load {0} in {1}", libraryName, fullPath);
            }
        }
Esempio n. 15
0
        } // Render(techniqueName, renderDelegate)

        #endregion

        #region Render single pass shader
        /// <summary>
        /// Render single pass shader, little faster and simpler than
        /// Render and it just uses the current technique and renderes only
        /// the first pass (most shaders have only 1 pass anyway).
        /// Used for MeshRenderManager!
        /// </summary>
        /// <param name="renderDelegate">Render delegate</param>
        public void RenderSinglePassShader(
            RenderDelegate renderDelegate)
        {
            // Start effect (current technique should be set)
            effect.Begin(SaveStateMode.None);
            // Start first pass
            effect.CurrentTechnique.Passes[0].Begin();

            // Render
            renderDelegate();

            // End pass and shader
            effect.CurrentTechnique.Passes[0].End();
            effect.End();
        } // RenderSinglePassShader(renderDelegate)
Esempio n. 16
0
        public AUGraphError SetNodeInputCallback(int destNode, uint destInputNumber, RenderDelegate renderDelegate)
        {
            if (nodesCallbacks == null)
            {
                nodesCallbacks = new Dictionary <uint, RenderDelegate> ();
            }

            nodesCallbacks [destInputNumber] = renderDelegate;

            var cb = new AURenderCallbackStruct();

            cb.Proc       = CreateRenderCallback;
            cb.ProcRefCon = GCHandle.ToIntPtr(gcHandle);
            return(AUGraphSetNodeInputCallback(handle, destNode, destInputNumber, ref cb));
        }
Esempio n. 17
0
        /// <summary>
        /// Create test game
        /// </summary>
        /// <param name="setWindowsTitle">Set windows title</param>
        /// <param name="windowWidth">Window width</param>
        /// <param name="windowHeight">Window height</param>
        /// <param name="setInitCode">Set init code</param>
        /// <param name="setRenderCode">Set render code</param>
        protected TestGame(string setWindowsTitle,
                           RenderDelegate setInitCode,
                           RenderDelegate setRenderCode)
        {
            this.Window.Title = setWindowsTitle;

#if !XBOX360
#if DEBUG
            // Force window on top
            WindowsHelper.ForceForegroundWindow(this.Window.Handle.ToInt32());
#endif
#endif
            initCode   = setInitCode;
            renderCode = setRenderCode;
        }         // TestGame(setWindowsTitle, setRenderCode)
Esempio n. 18
0
 private void ChooseRenderDelegate()
 {
     if (SourceSize.Width > DestinationSize.Width)
     {
         // zoom out
         this.renderDelegate = new RenderDelegate(RenderZoomOutRotatedGridMultisampling);
     }
     else if (SourceSize == DestinationSize)
     {
         // zoom 100%
         this.renderDelegate = new RenderDelegate(RenderOneToOne);
     }
     else if (SourceSize.Width < DestinationSize.Width)
     {
         // zoom in
         this.renderDelegate = new RenderDelegate(RenderZoomInNearestNeighbor);
     }
 }
 private void ChooseRenderDelegate()
 {
     if (SourceSize.Width > DestinationSize.Width)
     {
         // zoom out
         this.renderDelegate = new RenderDelegate(RenderZoomOutRotatedGridMultisampling);
     }
     else if (SourceSize == DestinationSize)
     {
         // zoom 100%
         this.renderDelegate = new RenderDelegate(RenderOneToOne);
     }
     else if (SourceSize.Width < DestinationSize.Width)
     {
         // zoom in
         this.renderDelegate = new RenderDelegate(RenderZoomInNearestNeighbor);
     }
 }
Esempio n. 20
0
#pragma warning restore 612
#endif

        public AudioUnitStatus AddRenderNotify(RenderDelegate callback)
        {
            if (callback == null)
            {
                throw new ArgumentException("Callback can not be null");
            }

            AudioUnitStatus error = AudioUnitStatus.OK;

            if (graphUserCallbacks.Count == 0)
            {
                error = (AudioUnitStatus)AUGraphAddRenderNotify(handle, renderCallback, GCHandle.ToIntPtr(gcHandle));
            }

            if (error == AudioUnitStatus.OK)
            {
                graphUserCallbacks.Add(callback);
            }
            return(error);
        }
Esempio n. 21
0
        public AudioUnitStatus AddRenderNotify(RenderDelegate callback)
        {
            if (callback is null)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(callback));
            }

            AudioUnitStatus error = AudioUnitStatus.OK;

            if (graphUserCallbacks.Count == 0)
            {
                error = (AudioUnitStatus)AUGraphAddRenderNotify(Handle, renderCallback, GCHandle.ToIntPtr(gcHandle));
            }

            if (error == AudioUnitStatus.OK)
            {
                graphUserCallbacks.Add(callback);
            }
            return(error);
        }
        public WMPVisualizationWindow(ConfigProfile configProfile)
        {
            this._ConfigProfile = configProfile;

              _RenderDelegate = new RenderDelegate(Render);

              _WMPEffect = WMPEffect.SelectEffect(_ConfigProfile.WMPVizClsId, Handle);

              if (_WMPEffect != null && _ConfigProfile.WMPVizPreset < _WMPEffect.Presets.Length)
            _WMPEffect.SetCurrentPreset(_WMPEffect.Presets[0]);

              _WakeupRenderThread = new AutoResetEvent(false);
              _RenderThread = new Thread(new ThreadStart(RenderThread));
              _RenderThread.IsBackground = true;
              _RenderThread.Start();

              _Timer = new System.Timers.Timer(1000 / _ConfigProfile.WMPVizFps);
              _Timer.Elapsed += new ElapsedEventHandler(_Timer_Elapsed);
              _Timer.Start();
        }
Esempio n. 23
0
        /// <summary>
        /// Render using this shader.
        /// </summary>
        /// <param name="setMat">Set matrix</param>
        /// <param name="techniqueName">Technique name</param>
        /// <param name="renderDelegate">Render delegate</param>
        public void RenderMultipass(RenderDelegate renderDelegate)
        {
            //SetCameraParameters( game.Camera );
            // Start shader
            //effect.CurrentTechnique = effect.Techniques[ techniqueName ];
            effect.Begin(SaveStateMode.None);

            // Render all passes (usually just one)
            //foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            for (int num = 0; num < effect.CurrentTechnique.Passes.Count; num++)
            {
                EffectPass pass = effect.CurrentTechnique.Passes[num];

                pass.Begin();
                renderDelegate();
                pass.End();
            } // foreach (pass)

            // End shader
            effect.End();
        } // Render(passName, renderDelegate)
Esempio n. 24
0
        public AudioUnitStatus RemoveRenderNotify(RenderDelegate callback)
        {
            if (callback == null)
            {
                throw new ArgumentException("Callback can not be null");
            }
            if (!graphUserCallbacks.Contains(callback))
            {
                throw new ArgumentException("Cannot unregister a callback that has not been registered");
            }

            AudioUnitStatus error = AudioUnitStatus.OK;

            if (graphUserCallbacks.Count == 0)
            {
                error = (AudioUnitStatus)AUGraphRemoveRenderNotify(handle, renderCallback, GCHandle.ToIntPtr(gcHandle));
            }

            graphUserCallbacks.Remove(callback);              // Remove from list even if there is an error
            return(error);
        }
Esempio n. 25
0
 /// <summary>
 /// Sets the view to be rendered and updates the behavior of controls accordingly.
 /// </summary>
 /// <param name="renderer">A <see cref="AccountManagementControl.RenderDelegate"/> for rendering the control.</param>
 protected override void SetView(RenderDelegate renderer)
 {
     _renderByView = renderer;
     if (renderer == this.RenderIntroView)
     {
         _actionButton.Text = _actionButton.CommandName = _showCreatorCommandName;
     }
     //else if (renderer == this.RenderElectionSelection)
     //{
     //}
     //else if (renderer == this.RenderContactSelection)
     //{
     //}
     else if (renderer == this.RenderCreateForm)
     {
         _actionButton.Text = _actionButton.CommandName = _createAccountCommandName;
     }
     else if (renderer == this.RenderCreateErrorView)
     {
         _actionButton.Text = _actionButton.CommandName = _retryCreateCommandName;
     }
 }
Esempio n. 26
0
 protected void SetBlock(Dictionary <String, RenderDelegate> Blocks, String BlockName, RenderDelegate Callback)
 {
     Blocks[BlockName] = Callback;
 }
Esempio n. 27
0
 public McgNode( RenderDelegate act, McgLayer l, int start_x, int start_y, int? end_x, int? end_y, int? delay)
 {
     OnDraw = act;
     _Node( l, start_x, start_y, end_x, end_y, delay );
 }
Esempio n. 28
0
		} // Start(testName, initCode, renderCode)

		/// <summary>
		/// Start
		/// </summary>
		/// <param name="testName">Test name</param>
		/// <param name="renderCode">Render code</param>
		public static void Start(string testName,
			RenderDelegate renderCode)
		{
			Start(testName, null, renderCode);
		} // Start(testName, renderCode)
Esempio n. 29
0
 public DynamicSprite(string filename, RenderTarget2D renderTarget, RenderDelegate render, bool keepLoaded) : base(filename)
 {
     Render       = render;
     RenderTarget = renderTarget;
     KeepLoaded   = keepLoaded;
 }
Esempio n. 30
0
        public override void Render()
        {
            int vertStartOffset = WindowManager.Instance.VertexList.Count;

            Point texOffset = Point.Empty;
            if(stateOffets.ContainsKey(state))
                texOffset = stateOffets[state];
            if (ToggleButton)
            {
                if (Toggled)
                    texOffset = stateOffets[ButtonState.DOWN];
            }

            // Top
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X, Position.Y), new Size(atlas["topleft"].Width, atlas["topleft"].Height)), MoveRectangle(atlas["topleft"], texOffset), atlas.Texture.Size));
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X + atlas["topleft"].Width, Position.Y), new Size(Size.Width - atlas["topleft"].Width - atlas["topright"].Width, atlas["top"].Height)), MoveRectangle(atlas["top"], texOffset), atlas.Texture.Size));
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X + Size.Width - atlas["topright"].Width, Position.Y), new Size(atlas["topright"].Width, atlas["topright"].Height)), MoveRectangle(atlas["topright"], texOffset), atlas.Texture.Size));

            // Bottom
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X, Position.Y + Size.Height - atlas["bottomleft"].Height), atlas["bottomleft"].Size), MoveRectangle(atlas["bottomleft"], texOffset), atlas.Texture.Size));
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X + atlas["bottomleft"].Width, Position.Y + Size.Height - atlas["bottom"].Height), new Size(Size.Width - atlas["bottomleft"].Width - atlas["bottomright"].Width, atlas["bottom"].Height)), MoveRectangle(atlas["bottom"], texOffset), atlas.Texture.Size));
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X + Size.Width - atlas["bottomright"].Width, Position.Y + Size.Height - atlas["bottomright"].Height), atlas["bottomright"].Size), MoveRectangle(atlas["bottomright"], texOffset), atlas.Texture.Size));

            // Middle
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X, Position.Y + atlas["topleft"].Height), new Size(atlas["left"].Width, Size.Height - atlas["topleft"].Height - atlas["bottomleft"].Height)), MoveRectangle(atlas["left"], texOffset), atlas.Texture.Size));
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X + atlas["left"].Width, Position.Y + atlas["top"].Height), new Size(Size.Width - atlas["left"].Width - atlas["right"].Width, Size.Height - atlas["top"].Height - atlas["bottom"].Height)), MoveRectangle(atlas["middle"], texOffset), atlas.Texture.Size));
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X + Size.Width - atlas["right"].Width, Position.Y + atlas["topright"].Height), new Size(atlas["right"].Width, Size.Height - atlas["top"].Height - atlas["bottomright"].Height)), MoveRectangle(atlas["right"], texOffset), atlas.Texture.Size));

            ulong key = SortItem.GenerateBits(SortItem.FSLayer.HUD, SortItem.Viewport.DYNAMIC, SortItem.VPLayer.HUD, SortItem.Translucency.NORMAL, atlas.Texture.MaterialID, 0, 0, WindowManager.Instance.vb.VertexBufferID);
            int nPrimitives = (WindowManager.Instance.VertexList.Count - vertStartOffset) / 3;
            RenderDelegate del = new RenderDelegate((effect, device, setMaterial) =>
            {
                if (setMaterial)
                    device.SetTexture(0, atlas.Texture.Texture);

                // Draw UI elements
                device.DrawPrimitives(PrimitiveType.TriangleList, vertStartOffset, nPrimitives);
            });

            WindowManager.Instance.renderCalls.Add(new KeyValuePair<ulong, RenderDelegate>(key, del));

            base.Render();
        }
Esempio n. 31
0
 public FaceCount(int _size, HalfEdge _eStart, RenderDelegate _render)
 {
     size   = _size;
     eStart = _eStart;
     render = _render;
 }
 private void Flush()
 {
     this.renderDelegate = null;
 }
Esempio n. 33
0
        public void Render()
        {
            if (!Visible || letters == null)
                return;

            // LocalServer gives "root" prefix
            if (CVars.Instance.FindVar("sv_running").Integer == 1)
                LinePrefix = "# ";

            List<VertexPositionColorTex> verts = new List<VertexPositionColorTex>();
            VertexPositionColorTex[] bgverts = MiscRender.GetQuadPoints(new System.Drawing.RectangleF(0, 0, Renderer.Instance.RenderSize.Width, Renderer.Instance.RenderSize.Height), new Color4(0.75f, 0.0f, 0.0f, 0.0f));

            verts.AddRange(bgverts);
            // Add background
            int maxLines = Renderer.Instance.RenderSize.Height / 15;
            int maxWidth = Renderer.Instance.RenderSize.Width / 9;

            // Build vert list
            Size screenSize = Renderer.Instance.RenderSize;

            int currH = 0;
            string text = "";
            int textLines = 0;
            Color4 currentColor = Color.White;
            // Start from newest line, to oldest, or to we get to text that cant be seen
            for (int line = lines.Count; line >= 0 && currH <= maxLines; line--)
            {
                int internalH = 0, currW = 0;
                if (line == lines.Count)
                {
                    text = LinePrefix + (currentHistory == -1 ? currentText : commandHistory[currentHistory]);
                    textLines = 1;
                }
                else
                {
                    currentColor = Color.White;
                    text = lines[line];
                    textLines = NumLinesForString(text) + 1;
                }
                currH += textLines;

                // Iterate over chars
                for (int i = 0; i < text.Length; i++)
                {
                    int letter = (int)text[i]-32; // Dont have the first 32 ascii chars
                    if (text[i] == '\n')
                    {
                        currW = 0;
                        internalH++;
                        continue;
                    }
                    else if (text[i] == '\r')
                        continue;
                    else if (text.Length > i+1 && text[i] == '^' && text[i + 1] >= '0' && text[i + 1] <= '9') // ^<0-9>
                    {
                        // Change color
                        int colorNumber = int.Parse(text[i + 1].ToString());
                        if (colorNumber < ConsoleColors.Length)
                            currentColor = ConsoleColors[colorNumber];
                        else
                            currentColor = ConsoleColors[7]; // white

                        // Don't draw "^1" in console output
                        if (line != lines.Count)
                        {
                            i++;
                            continue;
                        }
                    }

                    if (letter > letters.Length || letter < 0)
                    {
                        //Common.Instance.WriteLine("Letter out of bounds: " + text[i]);
                        letter = (int)'~' -31;
                    }

                    VertexPositionColorTex[] qv = MiscRender.GetQuadPoints(new System.Drawing.RectangleF(currW * 9, Renderer.Instance.RenderSize.Height - (currH * 15) + (internalH*15), 9, 15), new RectangleF(new PointF(letters[letter].TexCoord.X, letters[letter].TexCoord.Y), new SizeF(9, 15)), font.Size, currentColor);
                    verts.AddRange(qv);

                    // count up the current chars shown
                    currW++;
                    if (currW >= maxWidth)
                    {
                        currW = 0;
                        internalH++;

                        if (internalH >= maxLines)
                            break;
                    }
                }
            }

            // Add caret
            int caretletter = (int)'_'-32;
            verts.AddRange(MiscRender.GetQuadPoints(new System.Drawing.RectangleF((currentPos+2) * 9, Renderer.Instance.RenderSize.Height - 15, 9, 15), new RectangleF(new PointF(letters[caretletter].TexCoord.X, letters[caretletter].TexCoord.Y), new SizeF(9, 15)), font.Size));

            // Pack it up and send it off to the renderer
            VertexPositionColorTex[] arr = verts.ToArray();
            ulong key = SortItem.GenerateBits(SortItem.FSLayer.HUD, SortItem.Viewport.DYNAMIC, SortItem.VPLayer.HUD, SortItem.Translucency.NORMAL, font.MaterialID, 0, 0, 0);
            int nPrimitives = (verts.Count) / 3;
            RenderDelegate del = new RenderDelegate((effect, device, setMaterial) =>
            {
                //if (setMaterial)
                    device.SetTexture(0, bg.Texture);

                // Draw UI elements
                    device.DrawUserPrimitives<VertexPositionColorTex>(PrimitiveType.TriangleList, 2, arr);
                    device.SetTexture(0, font.Texture);
                device.DrawUserPrimitives<VertexPositionColorTex>(PrimitiveType.TriangleList, 6, nPrimitives-2, arr);
                //device.DrawPrimitives(PrimitiveType.TriangleList, 0, nPrimitives);
            });
            Renderer.Instance.drawCalls.Add(new KeyValuePair<ulong, RenderDelegate>(key, del));
        }
Esempio n. 34
0
 public RenderThread(RenderDelegate callback)
 {
     this.renderCallback = callback;
     shouldRender = true;
 }
Esempio n. 35
0
        public RenderDelegate GetDrawDelegate()
        {
            if (_myDrawDelegate != null) return _myDrawDelegate;

            _myDrawDelegate = (int x, int y) => {

                Vector2 screen = Coords.Physics2Screen(new Vector2 { X = Position.X, Y = Position.Y });

                // maybe update the screen here?

                sprite.Sprite.x = (int)screen.X - 19;
                sprite.Sprite.y = (int)screen.Y - 12;
                sprite.Sprite.Draw();

                Rectangle dest = new Rectangle((int)screen.X + 4, (int)screen.Y, 41, 41);
                Rectangle src = new Rectangle(0, 0, 41, 41);
                Vector2 origin = new Vector2(21, 21);

                float theta = (float)(Math.PI / 2) - (float)Math.Asin(Impulse.Y / Impulse.Length());
                //Console.Out.WriteLine(theta);

                if (float.IsNaN(theta)) theta = (float)Math.PI / 4;

                Game1.game.spritebatch.Draw(Game1.game.im_arrow, dest, src, Color.White, theta, origin, Microsoft.Xna.Framework.Graphics.SpriteEffects.None, 0);
            };

            return _myDrawDelegate;
        }
Esempio n. 36
0
		public Version1Renderer(RenderDelegate renderDelegate) {
			this.RenderDelegate = renderDelegate;
		}
Esempio n. 37
0
        public void DrawLagometer()
        {
            int vertStartOffset = WindowManager.Instance.VertexList.Count;

            int x = middle.Location.X;
            int y = middle.Location.Y;
            int w = middle.Size.Width;
            int h = middle.Size.Height;

            float range = h / 3;
            float mid = y + range;
            float vscale = range / 150;
            float wscale = (float)w / Lagometer.LAGBUFFER;
            for (int a = 0; a < Lagometer.LAGBUFFER; a++)
            {
                int i = (Client.Instance.lagometer.frameCount - 1 - a) & Lagometer.LAGBUFFER-1;
                int v = Client.Instance.lagometer.frameSamples[i];
                v = (int)(v*vscale);
                if (v > 0)
                {
                    // Yellow
                    if (v > range)
                        v = (int)range;
                    // Draw rect
                    WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(x + w - ((a) * wscale), mid - v), new SizeF(1 * wscale, v)), new SlimDX.Color4(Color.Yellow)));
                }
                else if (v < 0)
                {
                    // Blue
                    v = -v;
                    if (v > range)
                        v = (int)range;
                    // Draw rect
                    WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(x + w - ((a) * wscale), mid), new SizeF(1 * wscale, v)), new SlimDX.Color4(Color.Blue)));
                }
            }

            // Draw snapshot latency & drop graph
            for (int a = 0; a < Lagometer.LAGBUFFER; a++)
            {
                int i = (Client.Instance.lagometer.snapshotCount - 1 - a) & Lagometer.LAGBUFFER-1;
                int v = Client.Instance.lagometer.snapshotSamples[i];
                if (v > 0)
                {
                    Color4 color;
                    if ((Client.Instance.lagometer.snapshotFlags[i] & 1) == 1)
                    {
                        // Yellow for rate delay
                        color = new Color4(Color.Yellow);
                    }
                    else
                    {
                        // Green
                        color = new Color4(Color.Green);
                    }
                    v = (int)(v * vscale);
                    if (v > range)
                        v = (int)range;
                    // Draw rect
                    WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(x + w - (a*wscale), y+h-v), new SizeF(1*wscale, v)), color));
                }
                else if (v < 0)
                {
                    // Red for dropped snapshots
                    WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(x + w - (a * wscale), y + h - range), new SizeF(1 * wscale, range)), new SlimDX.Color4(Color.Red)));
                }
            }

            ulong key = SortItem.GenerateBits(SortItem.FSLayer.HUD, SortItem.Viewport.DYNAMIC, SortItem.VPLayer.HUD, SortItem.Translucency.NORMAL, tex.MaterialID, 0, 0, WindowManager.Instance.vb.VertexBufferID);
            int nPrimitives = (WindowManager.Instance.VertexList.Count - vertStartOffset) / 3;
            RenderDelegate del = new RenderDelegate((effect, device, setMaterial) =>
            {
                if (setMaterial)
                    device.SetTexture(0, tex.Texture);

                // Draw UI elements
                device.DrawPrimitives(PrimitiveType.TriangleList, vertStartOffset, nPrimitives);
            });
            if(nPrimitives > 0)
                WindowManager.Instance.renderCalls.Add(new KeyValuePair<ulong, RenderDelegate>(key, del));
        }
Esempio n. 38
0
		protected void SetBlock(Dictionary<String, RenderDelegate> Blocks, String BlockName, RenderDelegate Callback)
		{
			Blocks[BlockName] = Callback;
		}
 /// <summary>
 /// Start
 /// </summary>
 /// <param name="renderCode">Render code</param>
 public static void Start(RenderDelegate renderCode)
 {
     using (game = new TestGame("Unit Test", renderCode))
     {
         game.Run();
     } // using (game)
 }
 private void BtnStart_Click(object sender, RoutedEventArgs e)
 {
     if (!Rendering)
     {
         Rendering        = true;
         BtnStart.Content = "STOP";
         RenderDelegate renderDelegate = new RenderDelegate(Render);
         Recording = CbRecording.IsChecked.Value;
         UseColors = CbUseColor.IsChecked.Value;
         Vector[] PrevPath;
         //STEP 1: Zero order starts as a point in the center and morphs out to order 1.
         My_Order = 1;
         Len      = canvas1.ActualWidth / Math.Pow(2, My_Order);
         Total    = (int)Math.Pow(2, 2 * My_Order);
         Line L;
         Array.Resize(ref Linear, Total);
         Array.Resize(ref Path, Total);
         Array.Resize(ref Interpolated, Total);
         Array.Resize(ref Lines, Total);
         if (Recording)
         {
             WaitTime = 500;
         }
         else
         {
             WaitTime = 100;
         }
         int maxOrder = int.Parse(TxtMaxOrder.Text);
         //Calculate the points
         for (int I = 0; I < Total; I++)
         {
             Linear[I]       = new Vector(canvas1.ActualWidth / 2, canvas1.ActualHeight / 2);
             Path[I]         = Hilbert(I);
             Interpolated[I] = Linear[I];
         }
         //Draw the lines
         canvas1.Children.Clear();
         for (int I = 0; I < Interpolated.Length - 1; I++)
         {
             L = new Line
             {
                 StrokeThickness = 2.0,
                 X1 = Interpolated[I].X,
                 Y1 = Interpolated[I].Y,
                 X2 = Interpolated[I + 1].X,
                 Y2 = Interpolated[I + 1].Y
             };
             if (UseColors)
             {
                 L.Stroke = My_Brushes[I & 3];
             }
             else
             {
                 L.Stroke = Brushes.DeepSkyBlue;
             }
             Lines[I] = L;
             canvas1.Children.Add(L);
         }
         //Morph the lines from Linear to Path
         for (double p = 0; p <= 1; p += 0.04)
         {
             if (!Rendering)
             {
                 return;
             }
             for (int I = 0; I < Total; I++)
             {
                 Interpolated[I] = Lerp(Linear[I], Path[I], p);
             }
             Dispatcher.Invoke(renderDelegate, DispatcherPriority.ApplicationIdle);
             Thread.Sleep(WaitTime);
             if (Recording)
             {
                 SaveImage(canvas1);
             }
         }
         //STEP 2: Higher orders are formed by linear interpolating 4 points in each line
         //        (except in the connection lines)
         for (My_Order = 2; My_Order <= maxOrder; My_Order++)
         {
             Len      = canvas1.ActualWidth / Math.Pow(2, My_Order);
             Total    = (int)Math.Pow(2, 2 * My_Order);
             PrevPath = Path;
             Array.Resize(ref Linear, Total);
             Array.Resize(ref Path, Total);
             Array.Resize(ref Interpolated, Total);
             Array.Resize(ref Lines, Total);
             //Calculate 4 points between the points of the Previous Path
             //But not between the 3rd and 4th point (= connecting line)
             int index;
             int counter = 0;
             for (int I = 0; I < PrevPath.Length - 1; I++)
             {
                 index = I & 3;
                 if (index < 3)
                 {
                     for (double p = 0; p <= 0.8; p += 0.2)
                     {
                         Linear[counter] = Lerp(PrevPath[I], PrevPath[I + 1], p);
                         counter++;
                     }
                 }
                 else if (index == 3)
                 {
                     Linear[counter] = PrevPath[I];
                     counter++;
                 }
             }
             Linear[counter] = PrevPath.Last();
             for (int I = 0; I < Total; I++)
             {
                 Path[I]         = Hilbert(I);
                 Interpolated[I] = Linear[I];
             }
             canvas1.Children.Clear();
             //Draw the initial lines
             for (int I = 0; I < Interpolated.Length - 1; I++)
             {
                 L = new Line
                 {
                     StrokeThickness = 2.0,
                     X1 = Interpolated[I].X,
                     Y1 = Interpolated[I].Y,
                     X2 = Interpolated[I + 1].X,
                     Y2 = Interpolated[I + 1].Y
                 };
                 if (UseColors)
                 {
                     L.Stroke = My_Brushes[I & 3];
                 }
                 else
                 {
                     L.Stroke = Brushes.DeepSkyBlue;
                 }
                 Lines[I] = L;
                 canvas1.Children.Add(L);
             }
             //Morph the lines from Linear to Path
             for (double p = 0; p <= 1; p += 0.04)
             {
                 if (!Rendering)
                 {
                     return;
                 }
                 for (int I = 0; I < Total; I++)
                 {
                     Interpolated[I] = Lerp(Linear[I], Path[I], p);
                 }
                 Dispatcher.Invoke(renderDelegate, DispatcherPriority.ApplicationIdle);
                 Thread.Sleep(WaitTime);
                 if (Recording)
                 {
                     SaveImage(canvas1);
                 }
             }
         }
         //Wait to show the last curve (needed for looping animated Gif images)
         if (Recording)
         {
             for (int I = 0; I < 40; I++)
             {
                 Dispatcher.Invoke(renderDelegate, DispatcherPriority.ApplicationIdle);
                 Thread.Sleep(WaitTime);
                 SaveImage(canvas1);
             }
             //Convert the PNG images into an animated GIF.
             MakeGif(15);
             Recording = false;
         }
         Rendering        = false;
         BtnStart.Content = "START";
     }
     else
     {
         Rendering        = false;
         BtnStart.Content = "START";
     }
 }
Esempio n. 41
0
 public TransparentObjectsBufferRecord(Vector2 Position, object Data, RenderDelegate Render)
 {
     this.Position = Position;
     this.Data     = Data;
     this.Render   = Render;
 }
Esempio n. 42
0
        public override void Render()
        {
            // Update text size
            if (Changed)
            {
                TextSize = new Rectangle();
                Renderer.Instance.Fonts["textbox"].MeasureString(Renderer.Instance.sprite, Text, DrawTextFormat.Left, ref TextSize);

                Changed = false;
            }
            DrawRect = new Rectangle(Position.X + atlas["left"].Width, Position.Y + atlas["top"].Height, Size.Width - atlas["left"].Width - atlas["left"].Width, Size.Height - atlas["top"].Height - atlas["bottom"].Height);

            // Early out
            if (DrawRect.Width <= 0)
                return;

            int vertStartOffset = WindowManager.Instance.VertexList.Count;
            // Draw borders
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(Position.X, Position.Y), atlas["topleft"].Size), atlas["topleft"], atlas["topleft"].Size));
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(Position.X + atlas["topleft"].Width, Position.Y), new SizeF(Size.Width - atlas["topleft"].Width - atlas["topright"].Width, atlas["top"].Height)), atlas["top"], atlas["top"].Size));
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(Position.X + Size.Width - atlas["topright"].Width, Position.Y), atlas["topright"].Size), atlas["topright"], atlas["topright"].Size));

            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(Position.X, Position.Y + atlas["topleft"].Height), new SizeF(atlas["left"].Width, Size.Height - atlas["top"].Height - atlas["bottom"].Height)), atlas["left"], atlas["left"].Size));

            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(Position.X + Size.Width - atlas["right"].Width, Position.Y + atlas["topright"].Height), new SizeF(atlas["right"].Width, Size.Height - atlas["top"].Height - atlas["bottom"].Height)), atlas["right"], atlas["right"].Size));

            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(Position.X, Position.Y + Size.Height - atlas["bottomleft"].Height), new SizeF()), atlas["bottomleft"], atlas["bottomleft"].Size));
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(Position.X + atlas["bottomleft"].Width, Position.Y + Size.Height - atlas["bottom"].Height), new SizeF(Size.Width - atlas["bottomleft"].Width - atlas["bottomright"].Width, atlas["bottom"].Height)), atlas["bottom"], atlas["bottom"].Size));
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(Position.X + Size.Width - atlas["bottomright"].Width, Position.Y + Size.Height - atlas["bottomright"].Height), new SizeF()), atlas["bottomright"], atlas["bottomright"].Size));
            int nPrimitives = (WindowManager.Instance.VertexList.Count - vertStartOffset) / 3;

            int vertStartOffset2 = WindowManager.Instance.VertexList.Count;
            WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(Position.X + atlas["left"].Width, Position.Y + atlas["top"].Height), new SizeF(Size.Width - atlas["left"].Width - atlas["right"].Width, Size.Height - atlas["top"].Height - atlas["bottom"].Height)), atlas["middle"], atlas["middle"].Size, new SlimDX.Color4((Enabled ? 0.2f : 0.4f), 1f, 1f, 1f)));
            if (Selection)
            {
                WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(Position.X + (Math.Min(SelectStart, SelectEnd) * ASize.Width + atlas["left"].Width) + OverflowOffset, Position.Y + atlas["top"].Height), new SizeF(ASize.Width * (Math.Abs(SelectStart - SelectEnd)), ASize.Height)), new SlimDX.Color4(0.5f, (173f / 255f), (216f / 255f), (230f / 255f))));
            }
            if (DrawCaret && HasFocus)
            {
                WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new RectangleF(new PointF(Position.X + CaretPositionF.X + atlas["left"].Width, Position.Y + CaretPositionF.Y + atlas["top"].Height), new SizeF(1, Size.Height - 6)), new SlimDX.Color4(Enabled ? 0.8f : 0.4f, 1f, 1f, 1f)));
            }

            int nPrimitives2 = (WindowManager.Instance.VertexList.Count - vertStartOffset2) / 3;

            ulong key = SortItem.GenerateBits(SortItem.FSLayer.HUD, SortItem.Viewport.DYNAMIC, SortItem.VPLayer.HUD, SortItem.Translucency.NORMAL, atlas.Texture.MaterialID, 0, 0, WindowManager.Instance.vb.VertexBufferID);
            RenderDelegate del = new RenderDelegate((effect, device, setMaterial) =>
            {
                //if (Renderer.Instance.CanScissor)
                {
                    oldrect = device.ScissorRect;
                    device.ScissorRect = DrawRect;
                }

                device.SetTexture(0, atlas.Texture.Texture);
                device.DrawPrimitives(PrimitiveType.TriangleList, vertStartOffset, nPrimitives);

                Renderer.Instance.sprite.Begin(SpriteFlags.AlphaBlend);
                Renderer.Instance.Fonts["textbox"].DrawString(Renderer.Instance.sprite, _Text, new Rectangle(new Point(Position.X + atlas["left"].Width + OverflowOffset, Position.Y + atlas["top"].Height + 2), new Size(TextSize.Width, Size.Height - atlas["top"].Height - atlas["bottomleft"].Height)), DrawTextFormat.Left, (Enabled ? Color : Color.FromArgb(128, Color)));
                Renderer.Instance.sprite.End();

                device.SetTexture(0, WhiteTexture);
                device.DrawPrimitives(PrimitiveType.TriangleList, vertStartOffset2, nPrimitives2);

                //if (Renderer.Instance.CanScissor)
                {
                    device.ScissorRect = oldrect;
                }
            });

            WindowManager.Instance.renderCalls.Add(new KeyValuePair<ulong, RenderDelegate>(key, del));
        }
Esempio n. 43
0
        public override void Render()
        {
            if (!Borderless)
            {
                int vertStartOffset = WindowManager.Instance.VertexList.Count;

                // Top
                WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X, Position.Y), new Size(atlas["topleft"].Width, atlas["topleft"].Height)), atlas["topleft"], atlas.Texture.Size));
                WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X + atlas["topleft"].Width, Position.Y), new Size(Size.Width - atlas["topleft"].Width - atlas["topright"].Width, atlas["top"].Height)), atlas["top"], atlas.Texture.Size));
                WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X + Size.Width - atlas["topright"].Width, Position.Y), new Size(atlas["topright"].Width, atlas["topright"].Height)), atlas["topright"], atlas.Texture.Size));

                // Bottom
                WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X, Position.Y + Size.Height - atlas["bottomleft"].Height), atlas["bottomleft"].Size), atlas["bottomleft"], atlas.Texture.Size));
                WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X + atlas["bottomleft"].Width, Position.Y + Size.Height - atlas["bottom"].Height), new Size(Size.Width - atlas["bottomleft"].Width - atlas["bottomright"].Width, atlas["bottom"].Height)), atlas["bottom"], atlas.Texture.Size));
                WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X + Size.Width - atlas["bottomright"].Width, Position.Y + Size.Height - atlas["bottomright"].Height), atlas["bottomright"].Size), atlas["bottomright"], atlas.Texture.Size));

                // Middle
                WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X, Position.Y + atlas["topleft"].Height), new Size(atlas["left"].Width, Size.Height - atlas["topleft"].Height - atlas["bottomleft"].Height)), atlas["left"], atlas.Texture.Size));
                WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X + atlas["left"].Width, Position.Y + atlas["top"].Height), new Size(Size.Width - atlas["left"].Width - atlas["right"].Width, Size.Height - atlas["top"].Height - atlas["bottom"].Height)), atlas["middle"], atlas.Texture.Size));
                WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X + Size.Width - atlas["right"].Width, Position.Y + atlas["topright"].Height), new Size(atlas["right"].Width, Size.Height - atlas["top"].Height - atlas["bottomright"].Height)), atlas["right"], atlas.Texture.Size));

                // Resizeable
                if (Resizeable)
                    WindowManager.Instance.VertexList.AddRange(MiscRender.GetQuadPoints(new Rectangle(new Point(Position.X + Size.Width - atlas["scale"].Width - 2, Position.Y + Size.Height - atlas["scale"].Height - 2), atlas["scale"].Size), atlas["scale"], atlas.Texture.Size));

                ulong key = SortItem.GenerateBits(SortItem.FSLayer.HUD, SortItem.Viewport.DYNAMIC, SortItem.VPLayer.HUD, SortItem.Translucency.NORMAL, atlas.Texture.MaterialID, 0, 0, WindowManager.Instance.vb.VertexBufferID);
                int nPrimitives = (WindowManager.Instance.VertexList.Count - vertStartOffset) / 3;
                RenderDelegate del = new RenderDelegate((effect, device, setMaterial) =>
                {
                    //Rectangle oldrect = device.ScissorRect;
                    //device.ScissorRect = Bound;
                    if (setMaterial)
                        device.SetTexture(0, atlas.Texture.Texture);

                    // Draw UI elements
                    device.DrawPrimitives(PrimitiveType.TriangleList, vertStartOffset, nPrimitives);
                    // Draw Title
                    Sprite sprite = Renderer.Instance.sprite;
                    sprite.Begin(SpriteFlags.AlphaBlend | SpriteFlags.DoNotAddRefTexture);
                    int yOffset = -(TitleSize.Height - atlas["top"].Height) / 2;
                    Renderer.Instance.Fonts["title"].DrawString(sprite, Title, new Rectangle(Position.X + atlas["topleft"].Width - 9, Position.Y + yOffset + 1, Size.Width - (2 * 32), TitleSize.Height), DrawTextFormat.SingleLine | DrawTextFormat.NoClip | DrawTextFormat.Center, Color.FromArgb((int)(Opacity * 255), Color.FromArgb(50, 50, 50)));
                    Renderer.Instance.Fonts["title"].DrawString(sprite, Title, new Rectangle(Position.X + atlas["topleft"].Width - 10, Position.Y + yOffset, Size.Width - (2 * 32), TitleSize.Height), DrawTextFormat.SingleLine | DrawTextFormat.NoClip | DrawTextFormat.Center, Color);
                    sprite.End();
                    //device.ScissorRect = oldrect;
                });

                WindowManager.Instance.renderCalls.Add(new KeyValuePair<ulong, RenderDelegate>(key, del));
            }

            // Render window content
            panel.Render();
        }
Esempio n. 44
0
        public RenderDelegate GetDrawDelegate()
        {
            if( _myDrawDelegate != null ) return _myDrawDelegate;

            _myDrawDelegate = ( int x, int y ) => {

                this.screen = Coords.Physics2Screen( new Vector2 { X = Position.X, Y = Position.Y } );

                // maybe update the screen here?

                myCorpse.Sprite.x = (int)screen.X - 8;
                myCorpse.Sprite.y = (int)screen.Y - 8;
                myCorpse.Sprite.Draw();
            };

            return _myDrawDelegate;
        }
 private void Flush()
 {
     this.renderDelegate = null;
 }
Esempio n. 46
0
 public CustomResult(string contentType, RenderDelegate renderAction)
 {
     // TODO: Null-check
       _render = renderAction;
       MediaType = contentType;
 }
 /// <summary>
 /// Throws a NotSupportedException (can only render IPlanetEnvironmentRenderer objects)
 /// </summary>
 public override void Apply( IRenderContext context, RenderDelegate render )
 {
     SetupTerrainEffect( m_Effect, m_Planet );
     render( context );
 }
Esempio n. 48
0
 public DelegatePresenter(RenderDelegate render, PartialHitTestDelegate partialHitTest)
 {
     this.render         = render;
     this.partialHitTest = partialHitTest;
 }
Esempio n. 49
0
		} // Start(testName, renderCode)

		/// <summary>
		/// Start
		/// </summary>
		/// <param name="renderCode">Render code</param>
		public static void Start(RenderDelegate renderCode)
		{
			Start("Unit Test", null, renderCode);
		} // Start(renderCode)
Esempio n. 50
0
        // Prepare and send rendercalls and buffers to Renderer
        public void Render()
        {
            //if (!ShowManager)
            //    return;
            int ms = (int)Common.Instance.Milliseconds();

            for (int i = 0; i < 8; i++)
            {
                if (ChatMessages[currentChatMessage + i & 7].Key > 0 && ms - ChatMessages[currentChatMessage + i & 7].Key > 5000)
                {
                    ChatMessages[currentChatMessage + i & 7] = new KeyValuePair<int, string>(-1, null);
                }
            }

            // Clear buffers for next frame
            renderCalls.Clear();
            VertexList.Clear();

            // sort back to front
            Windows.Sort(new WindowComparerReversed());
            foreach (Window window in Windows)
            {
                // Render if visible
                if ((window.Visible && ShowManager) || window.AlwaysVisible)
                {
                    window.Update();
                    window.Render();
                }
            }

            // Render Mouse Cursor
            if (ShowManager)
            {
                // Get verts
                int vertexStart = VertexList.Count;
                VertexPositionColorTex[] verts = MiscRender.GetQuadPoints(new System.Drawing.Rectangle(new System.Drawing.Point(Input.Instance.MouseX - cursor_offsets[(int)Cursor].Width, Input.Instance.MouseY - cursor_offsets[(int)Cursor].Height), cursorSize), new Rectangle(Point.Empty, cursorTextures[(int)Cursor].Size), cursorTextures[(int)Cursor].Size);
                VertexList.AddRange(verts);

                // Create rendercall
                ulong key = SortItem.GenerateBits(SortItem.FSLayer.HUD, SortItem.Viewport.DYNAMIC, SortItem.VPLayer.HUD, SortItem.Translucency.NORMAL, cursorTextures[(int)Cursor].MaterialID, 0, 0, vb.VertexBufferID);
                RenderDelegate del = new RenderDelegate((effect, device, setMaterial) => {
                    if (setMaterial)
                        device.SetTexture(0, cursorTextures[(int)Cursor].Texture);

                    device.DrawPrimitives(PrimitiveType.TriangleList, vertexStart, 2);
                });
                renderCalls.Add(new KeyValuePair<ulong, RenderDelegate>(key, del));
            }

            RenderChatMessages();

            // Send rendercalls to renderer
            if (VertexList.Count > 0)
            {
                vb.SetVB<VertexPositionColorTex>(VertexList.ToArray(), VertexList.Count * VertexPositionColorTex.SizeInBytes, VertexPositionColorTex.Format, Usage.WriteOnly);
                Renderer.Instance.drawCalls.AddRange(renderCalls);
            }
        }
Esempio n. 51
0
 public DelegatePresenter(RenderDelegate render) : this(render, null)
 {
 }
Esempio n. 52
0
 public McgNode(RenderDelegate act, McgLayer l, int start_x, int start_y)
     : this(act, l, start_x, start_y, null, null, null)
 {
 }
Esempio n. 53
0
 public override void Render()
 {
     ulong key = SortItem.GenerateBits(SortItem.FSLayer.HUD, SortItem.Viewport.DYNAMIC, SortItem.VPLayer.HUD, SortItem.Translucency.NORMAL, 0, 0, 0, WindowManager.Instance.vb.VertexBufferID);
         RenderDelegate del = new RenderDelegate((effect, device, setMaterial) =>
         {
             Sprite sprite = Renderer.Instance.sprite;
             sprite.Begin(SpriteFlags.AlphaBlend | SpriteFlags.DoNotAddRefTexture);
             Renderer.Instance.Fonts[LabelFont].DrawString(sprite, Text, Bound, DrawTextFormat.Left, System.Drawing.Color.FromArgb((int)(Window.Opacity * 255), Color));
             sprite.End();
         });
         WindowManager.Instance.renderCalls.Add(new KeyValuePair<ulong, RenderDelegate>(key, del));
 }
Esempio n. 54
0
 public MenuBox( ControlDelegate onControlUpdate, RenderDelegate onDraw )
 {
     OnControlUpdate = onControlUpdate;
     OnDraw = onDraw;
 }
Esempio n. 55
0
 public RenderThread(RenderDelegate callback)
 {
     this.renderCallback = callback;
     shouldRender        = true;
 }
Esempio n. 56
0
 static extern void gnomesharp_canvas_item_override_render(IntPtr gtype, RenderDelegate cb);
        /// <summary>
        /// Applies this technique. Applies a pass, then invokes the render delegate to render stuff, for each pass
        /// </summary>
        /// <param name="context">Rendering context</param>
        /// <param name="render">Rendering delegate</param>
        public override void Apply( IRenderContext context, RenderDelegate render )
        {
            Begin( );

            if ( m_Passes.Count > 0 )
            {
                foreach ( IPass pass in m_Passes )
                {
                    pass.Begin( );

                    render( context );

                    pass.End( );
                }
            }
            else
            {
                render( context );
            }

            End( );
        }
Esempio n. 58
0
        public MenuBox( Texture2D _img, int final_x, int final_y, int start_x, int start_y, ControlDelegate onControlUpdate, RenderDelegate onDraw )
        {
            image = _img;
            OnControlUpdate = onControlUpdate;
            OnDraw = onDraw;
            x = final_x;
            y = final_y;
            bounds = new Rectangle( x, y, image.Width, image.Height );
            color_bounds = new Rectangle( x, y, image.Width, image.Height );
            color_bounds.Inflate( -2, -2 );

            McgLayer l = _.sg.renderstack.GetLayer( "menu" );
            rendernode = l.AddNode(
                new McgNode( onDraw, l, start_x, start_y, final_x, final_y, MainMenu.delay )
            );
        }
Esempio n. 59
0
        public RenderDelegate GetDrawDelegate()
        {
            if( _myDrawDelegate != null ) {
                return _myDrawDelegate;
            }

            _myDrawDelegate = ( int x, int y ) => {

                Vector2 screen = Coords.Physics2Screen(
                    new Vector2 { X = Position.X, Y = Position.Y }
                );

                sprite.Sprite.x = (int)screen.X - 10;
                sprite.Sprite.y = (int)screen.Y - 9;
                sprite.Sprite.Draw();

                if (Utility.DrawHitboxes)
                {
                    Vertices v = (_fsFixture.Shape as PolygonShape).Vertices;

                    _.setDrawTarget(Game1.game.spritebatch);

                    int x0 = int.MaxValue, x1 = int.MinValue, y0 = int.MaxValue, y1 = int.MinValue;

                    for (int i = 0; i < 4; i++)
                    {
                        Vector2 r = Coords.Physics2Screen(v[i] + Position);

                        if (r.X < x0) x0 = (int)r.X;
                        if (r.X > x1) x1 = (int)r.X;
                        if (r.Y < y0) y0 = (int)r.Y;
                        if (r.Y > y1) y1 = (int)r.Y;
                    }

                    _.DrawRect(x0, y0, x1, y1, Color.Green);
                }
            };

            return _myDrawDelegate;
        }
Esempio n. 60
0
		public AudioUnitStatus SetRenderCallback (RenderDelegate renderDelegate, AudioUnitScopeType scope, uint audioUnitElement = 0)
		{
			var cb = new AURenderCallbackStruct ();
			cb.Proc = CreateRenderCallback;
			cb.ProcRefCon = GCHandle.ToIntPtr (gcHandle);

			this.render = renderDelegate;

			return AudioUnitSetProperty (handle, AudioUnitPropertyIDType.SetRenderCallback, scope, audioUnitElement, ref cb, Marshal.SizeOf (cb));
		}