public override void Shown()
		{
			try
			{
				root = new RootDisposable();

				VideoTypes videoType;
				video = Video.Init(VideoTypes.D3D11, out videoType, root, this, DepthStencilFormats.Defualt, true);
				viewPort = ViewPortAPI.New(video, new Point2(), video.BackBufferSize);
				float cameraDis = 10;
				camera = new Camera(viewPort, new Vector3(cameraDis, cameraDis, cameraDis), new Vector3(), new Vector3(cameraDis, cameraDis+1, cameraDis));

				//DiffuseSolidColorMaterial.Init(video, "Data/", video.FileTag, ShaderVersions.Max, null);
				//DiffuseSolidColorMaterial.ApplyInstanceConstantsCallback = applyTransform;
				DiffuseTextureMaterial.Init(video, "Data/", video.FileTag, ShaderVersions.Max, null);
				DiffuseTextureMaterial.ApplyObjectMeshCallback = applyTransform;
				DiffuseTextureMaterial.ApplyInstanceObjectMeshCallback = applyInstanceTransform;

				var materialTypes = new Dictionary<string,Type>();
				materialTypes.Add("Material", typeof(DiffuseTextureMaterial));
				var value3Types = new List<MaterialFieldBinder>();
				var textureTypes = new List<MaterialFieldBinder>();
				textureTypes.Add(new MaterialFieldBinder("Material", "Diffuse", "Diffuse"));
				model = new Model(video, "Data/untitled2.rm", "Data/", materialTypes, null, null, value3Types, null, textureTypes, null, 0, modelLoaded);

				QuickDraw3ColorMaterial.Init(video, "Data/", video.FileTag, ShaderVersions.Max, quickDrawShaderLoaded);
				qdMaterial = new QuickDraw3ColorMaterial();

				rasterizerState = RasterizerStateAPI.New(video, RasterizerStateDescAPI.New(RasterizerStateTypes.Solid_CullCW));
				depthState = DepthStencilStateAPI.New(video, DepthStencilStateDescAPI.New(DepthStencilStateTypes.ReadWrite_Less));
				blendState = BlendStateAPI.New(video, BlendStateDescAPI.New(BlendStateTypes.None));
				samplerState = SamplerStateAPI.New(video, SamplerStateDescAPI.New(SamplerStateTypes.Linear_Wrap));

				inited = true;
			}
			catch (Exception e)
			{
				Message.Show("Error", e.Message);
				dispose();
			}
		}
Exemple #2
0
 public void DrawStart(Camera camera)
 {
     vertexBuffer.Enable(indexBuffer);
     shaderCamera.Set(camera.TransformMatrix);
     texelOffset.Set(texture.TexelOffset);
     shaderTexture.Set(texture);
     layout.Enable();
     instancing = false;
 }