コード例 #1
0
ファイル: Canvas.cs プロジェクト: mbos14/2d-Physics
		//------------------------------------------------------------------------------------------------------------------------
		//														Render()
		//------------------------------------------------------------------------------------------------------------------------
		override protected void RenderSelf(GLContext glContext) {
			if (_invalidate) {
				_texture.UpdateGLTexture ();
				_invalidate = false;
			}

			base.RenderSelf (glContext);
		}
コード例 #2
0
ファイル: Game.cs プロジェクト: mbos14/2d-Physics
		//------------------------------------------------------------------------------------------------------------------------
		//														Game()
		//------------------------------------------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="GXPEngine.Game"/> class.
		/// This class represents a game window, containing an openGL view.
		/// </summary>
		/// <param name='width'>
		/// Width of the window in pixels.
		/// </param>
		/// <param name='height'>
		/// Height of the window in pixels.
		/// </param>
		/// <param name='fullScreen'>
		/// If set to <c>true</c> the application will run in fullscreen mode.
		/// </param>
		public Game (int pWidth, int pHeight, bool pFullScreen, bool pVSync = true) : base()
		{
			if (main != null) {
				throw new Exception ("Only a single instance of Game is allowed");
			} else {

				main = this;
				_updateManager = new UpdateManager ();
				_collisionManager = new CollisionManager ();
				_glContext = new GLContext (this);
				_glContext.CreateWindow (pWidth, pHeight, pFullScreen, pVSync);
				_gameObjectsContained = new List<GameObject>();

				//register ourselves for updates
				Add (this);

			}
		}
コード例 #3
0
ファイル: GameObject.cs プロジェクト: mbos14/2d-Physics
		//------------------------------------------------------------------------------------------------------------------------
		//														RenderSelf
		//------------------------------------------------------------------------------------------------------------------------
		protected virtual void RenderSelf(GLContext glContext) {
			if (visible == false) return;
			glContext.PushMatrix(matrix);
			glContext.PopMatrix();
		}
コード例 #4
0
ファイル: GameObject.cs プロジェクト: mbos14/2d-Physics
		//------------------------------------------------------------------------------------------------------------------------
		//														Render
		//------------------------------------------------------------------------------------------------------------------------
		/// <summary>
		/// This function is called by the renderer. You can override it to change this object's rendering behaviour.
		/// When not inside the GXPEngine package, specify the parameter as GXPEngine.Core.GLContext.
		/// This function was made public to accomoadate split screen rendering. Use SetViewPort for that.
 		/// </summary>
		/// <param name='glContext'>
		/// Gl context, will be supplied by internal caller.
		/// </param>
		public virtual void Render(GLContext glContext) {
			if (visible) {
				glContext.PushMatrix(matrix);
				
				RenderSelf (glContext);
				foreach (GameObject child in GetChildren()) {
					child.Render(glContext);
				}
				
				glContext.PopMatrix();
			}
		}
コード例 #5
0
ファイル: NLineSegment.cs プロジェクト: mbos14/2d-Physics
		//------------------------------------------------------------------------------------------------------------------------
		//														RenderSelf()
		//------------------------------------------------------------------------------------------------------------------------
		override protected void RenderSelf(GLContext glContext) {
			if (game != null && start != null && end != null) {
				recalc ();
				RenderLine (start, end, color, lineWidth);
			}
		}
コード例 #6
0
ファイル: Sprite.cs プロジェクト: mbos14/GTFO
 //------------------------------------------------------------------------------------------------------------------------
 //                                                        RenderSelf()
 //------------------------------------------------------------------------------------------------------------------------
 protected override void RenderSelf(GLContext glContext)
 {
     if (game != null) {
         Vector2[] bounds = GetExtents();
         float maxX = float.MinValue;
         float maxY = float.MinValue;
         float minX = float.MaxValue;
         float minY = float.MaxValue;
         for (int i=0; i<4; i++) {
             if (bounds[i].x > maxX) maxX = bounds[i].x;
             if (bounds[i].x < minX) minX = bounds[i].x;
             if (bounds[i].y > maxY) maxY = bounds[i].y;
             if (bounds[i].y < minY) minY = bounds[i].y;
         }
         bool test = (maxX < 0) || (maxY < 0) || (minX >= game.width) || (minY >= game.height);
         if (test == false) {
             if (blendMode != null) blendMode.enable ();
             _texture.Bind();
             glContext.SetColor((byte)((_color >> 16) & 0xFF),
                                (byte)((_color >> 8) & 0xFF),
                                (byte)(_color & 0xFF),
                                (byte)(_alpha * 0xFF));
             glContext.DrawQuad(GetArea(), _uvs);
             glContext.SetColor(1, 1, 1, 1);
             _texture.Unbind();
             if (blendMode != null) BlendMode.NORMAL.enable();
         }
     }
 }
コード例 #7
0
ファイル: Game.cs プロジェクト: mbos14/2d-Physics
		//------------------------------------------------------------------------------------------------------------------------
		//														RenderSelf()
		//------------------------------------------------------------------------------------------------------------------------
		override protected void RenderSelf(GLContext glContext) {
			//empty
		}