Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > .NET Frameworks (точка нет фреймворки) > C# (си шарп)
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 20.02.2014, 09:22   #1
25-й кадр
Человек
Форумчанин
 
Регистрация: 04.04.2011
Сообщений: 178
Вопрос Игрушка на PS Vita

Ребята, подскажите в чём беда? Вот код главной программы, куда всё подключаю.

Код:
using System;
using System.Collections.Generic;

using Sce.PlayStation.Core;
using Sce.PlayStation.Core.Environment;
using Sce.PlayStation.Core.Graphics;
using Sce.PlayStation.Core.Input;

namespace DemoGame1
{
	public class AppMain
	{
		private static GraphicsContext graphics;
		private static Sprite Demo;
	
		public static void Main (string[] args)
		{
			Initialize ();

			while (true) {
				SystemEvents.CheckEvents ();
				Update ();
				Render ();
			}
		}

		public static void Initialize ()
		{
			// Set up the graphics system
			graphics = new GraphicsContext ();
			Texture2D t = new Texture2D("/Application/Assets/Demo.png", false);
			Demo = new Sprite (graphics, t);
			Demo.Position.X = 100;
			Demo.Position.Y = 100;
		}
		public static void Update ()
		{
			// Query gamepad for current state
			var gamePadData = GamePad.GetData (0);
		}

		public static void Render ()
		{
			// Clear the screen
			graphics.SetClearColor (0.0f, 1.0f, 1.0f, 0.0f);
			graphics.Clear ();
			
			
			Demo.Render ();

			// Present the screen
			graphics.SwapBuffers ();
		}
	}
}
Вот код спрайта.

Код:
using System;
using System.Collections.Generic;

using Sce.PlayStation.Core;
using Sce.PlayStation.Core.Graphics;
using Sce.PlayStation.Core.Imaging;

namespace DemoGame1
{
	public class Sprite
	{
		static ShaderProgram shaderProgram;
		protected GraphicsContext graphics;
		float[] vertices = new float[12];
		
		const int indexSize = 4;
		ushort[] indices;
		
		VertexBuffer vertexBuffer;
		protected Texture2D texture;
	
		public Vector3 Position;
		public Vector2 Center;
		public Vector2 Scale = Vector2.One;
		
		float width, height;
		
		public float Width
		{
			get{return width * Scale.X;}
		}
		
		public float Height
		{
			get{return height * Scale.Y;}
		}
		
		public Sprite (GraphicsContext graphics, Texture2D texture)
		{
			

			if (shaderProgram == null)
			{
				shaderProgram = new ShaderProgram("/Application/shaders/Simple.cgx");
				shaderProgram.SetUniformBinding(0, "u_WorldMatrix");
			}
			
			if (texture == null)
			{
				throw new Exception("ERROR: texture is null.");	
			}
			
			this.graphics = graphics;
			this.texture = texture;
			this.width = texture.Width;
			this.height = texture.Height;
			
			indices = new ushort[indexSize];
			indices[0] = 0;
			indices[1] = 1;
			indices[2] = 2;
			indices[3] = 3;	
			
			vertexBuffer = new VertexBuffer(4, indexSize, VertexFormat.Float3, VertexFormat.Float2, VertexFormat.Float4);
		}
		
		public void Render()
		{
			vertices[0]=Position.X - Width * Center.X;
			vertices[1]=Position.Y - Height * Center.Y;
			vertices[2]=Position.Z;
			
			vertices[3]=Position.X - Width * Center.X;
			vertices[4]=Position.Y - Height * (1.0f-Center.Y);
			vertices[5]=Position.Z;
			
			vertices[6]=Position.X - width * (1.0f-Center.X);
			vertices[7]=Position.Y - height * Center.Y;
			vertices[8]=Position.Z;
			
			vertices[9]=Position.X - width * (1.0f-Center.X);
			vertices[10]=Position.Y - height * (1.0f-Center.Y);
			vertices[11]=Position.Z;
			
			Matrix4 screenMatrix = new Matrix4(
                 2.0f/graphics.Screen.Rectangle.Width, 0.0f,   0.0f, 0.0f,
                 0.0f, -2.0f/graphics.Screen.Rectangle.Height, 0.0f, 0.0f,
                 0.0f,  0.0f, 1.0f, 0.0f,
                -1.0f, 1.0f, 0.0f, 1.0f
        );
			
			graphics.SetTexture(0, texture);

			

			shaderProgram.SetUniformValue(0, ref screenMatrix);
			
			
		}
	}
}
Это код шейдера.

Код:

void main( float4 in a_Position  : POSITION,
		   float4 out v_Position : POSITION,
		   uniform float4x4 u_WorldMatrix
		   )
{
	v_Position = mul( a_Position, u_WorldMatrix );
	
}
Добился, чтобы без ошибок было, но картинку не выводит.
Это вам не это

Последний раз редактировалось 25-й кадр; 20.02.2014 в 09:26.
25-й кадр вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Игрушка madkot Помощь студентам 2 08.06.2011 19:05
Игрушка на С/С++ jewel Помощь студентам 2 28.11.2010 23:10
Игрушка Nester Gamedev - cоздание игр: Unity, OpenGL, DirectX 4 15.01.2009 19:02
Игрушка Rusl92 Мультимедиа в Delphi 8 25.09.2008 12:11
Игрушка Rozalinda Gamedev - cоздание игр: Unity, OpenGL, DirectX 9 14.01.2007 22:00