コード例 #1
0
ファイル: Sprite.cs プロジェクト: jpernst/GameStack
		public Sprite (Stream stream, TextureSettings settings, Vector4 rect, bool relativeRect, Vector4 color, bool flipV = true) {
			var tex = new Texture(stream, settings);
			_material = new SpriteMaterial(new SpriteShader(), tex);
			
			if (rect == Vector4.Zero)
				rect = new Vector4(0, 0, tex.Size.Width, tex.Size.Height);
			else if (relativeRect) {
				rect.X *= tex.Size.Width;
				rect.Y *= tex.Size.Height;
				rect.Z *= tex.Size.Width;
				rect.W *= tex.Size.Height;
			}
			
			_size = new Vector2(rect.Z - rect.X, rect.W - rect.Y);

			_vbuffer = new VertexBuffer(VertexFormat.PositionColorUV);
			_vbuffer.Data = new [] {
				rect.X, rect.Y, 0f, color.X, color.Y, color.Z, color.W, 0f, flipV ? 1f : 0f,
				rect.Z, rect.Y, 0f, color.X, color.Y, color.Z, color.W, 1f, flipV ? 1f : 0f,
				rect.Z, rect.W, 0f, color.X, color.Y, color.Z, color.W, 1f, flipV ? 0f : 1f,
				rect.X, rect.W, 0f, color.X, color.Y, color.Z, color.W, 0f, flipV ? 0f : 1f
			};
			_vbuffer.Commit ();
			
			_ibuffer = new IndexBuffer();
			_ibuffer.Data = new [] { 0, 1, 2, 2, 3, 0 };
			_ibuffer.Commit ();
			
			_ioffset = 0;
			_icount = 6;
			
			_ownResources = true;
		}
コード例 #2
0
ファイル: FrameBuffer.cs プロジェクト: jpernst/GameStack
		public FrameBuffer (Texture texture) {
			ThreadContext.Current.EnsureGLContext();

			_size = texture.Size;

			_oldfb = this.CurrentFrameBuffer;
			_oldViewport = new int[4];

			GL.GenFramebuffers(1, out _fb);
			GL.BindFramebuffer(FramebufferTarget.Framebuffer, _fb);
			GL.BindTexture(TextureTarget.Texture2D, texture.Handle);
			#if __DESKTOP__
			GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, texture.Handle, 0);
			#else
			GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferSlot.ColorAttachment0, TextureTarget.Texture2D, texture.Handle, 0);
			#endif

			GL.BindTexture(TextureTarget.Texture2D, 0);
			GL.BindFramebuffer(FramebufferTarget.Framebuffer, _oldfb);

			this.ClearOnBegin = true;
		}
コード例 #3
0
ファイル: MeshMaterial.cs プロジェクト: jpernst/GameStack
		public TextureSlot(Texture texture, int uvIndex, float blendFactor, TextureOperation operation, TextureWrap wrapS, TextureWrap wrapT) {
			this.Texture = texture;
			this.UVIndex = uvIndex;
			this.BlendFactor = blendFactor;
			this.Operation = operation;
			this.WrapS = wrapS;
			this.WrapT = wrapT;
		}
コード例 #4
0
ファイル: SpriteMaterial.cs プロジェクト: jpernst/GameStack
		public SpriteMaterial (Shader shader, Texture texture) : base(shader) {
			_texture = texture;
			this.Color = Vector4.One;
		}