Code Bucket …

Render System

You can visit http://www.the-barn.org/codebucket.php?id=70 to view this snippet directly.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once

namespace Display
{
	using Effect::Parameter;

	/// a mesh instance with a custom shader and shader parameters
	struct BasicMesh : InstanceBase
	{
	private:
		Shader shader;
		Linker linker;
		DirectX::PMesh mesh;

	public:
		Parameter<float4x4> g_ViewProjMatrix;
		Parameter<float4x4> g_WorldMatrix;
		Parameter<float4> g_Color;

		BasicMesh()
		{
			linker.AddFile("Shaders/Colored.fx");
			shader.AddFragments("Colored_VS_Fragment", "Colored_PS_Fragment");
		}
		void OnCreateDevice()
		{
			linker.Link(shader);
			BindUniforms(shader);
			mesh = GetDevice().CreateTeapot().value;
		}
		void Render() const
		{
			shader.Activate();
			WriteUniforms();
			mesh->DrawSubset(0);
		}
		static void Register(EffectRenderer &R)
		{
			ClassBuilder<BasicMesh>("Mesh", R)
				.Uniforms
					("g_ViewProjMatrix", &BasicMesh::g_ViewProjMatrix)
					("g_WorldMatrix", &BasicMesh::g_WorldMatrix)
					("g_Color", &BasicMesh::g_Color)
				.Resources
					(&BasicMesh::linker)
					(&BasicMesh::shader)
					(&BasicMesh::mesh)
				;
		}
	};
}

//EOF
  • Posted on 05.06.2009 at 12:14 PM by spam
  • Language: C++

Snippets

 
36 Results
Page 1 of 3
TitleLanguagePosted ByPostedExpiresActions
Python first-class classes for KodenPythonstoffle04.07.2010 8:19 AM (68 days 1h 20m ago)-view
mLAN Activation ScriptPlain Textstoffle23.06.2010 6:42 AM (79 days 2h 56m ago)-view
areaC#stoffle27.02.2010 3:51 AM (195 days 6h 48m ago)-view
list extensionsC#stoffle09.02.2010 11:12 PM (212 days 11h 26m ago)-view
possible IComponent intererface version 95C#stoffle09.02.2010 11:04 PM (212 days 11h 35m ago)-view
Render SystemC++spam05.06.2009 12:14 PM (461 days 21h 25m ago)-view
Effect SampleC++spam03.06.2009 2:40 PM (463 days 18h 58m ago)-view
Rho LambdasC++spam03.06.2009 2:38 PM (463 days 19h 1m ago)-view
Example VSM implC++spam02.06.2009 1:21 PM (464 days 20h 18m ago)-view
Vector3 Interface (public)C++kalin11.02.2008 9:53 PM (941 days 12h 46m ago)-view
TimesTablesC++kalin09.02.2008 6:04 PM (943 days 16h 35m ago)-view
Skruje Account Search PagePHPstoffle03.02.2008 5:12 PM (949 days 17h 27m ago)-view
C++ is still bork...C++spam26.01.2008 5:58 PM (957 days 16h 41m ago)-view
C++ is bork #3C++spam26.01.2008 5:47 PM (957 days 16h 52m ago)-view
C++ is bork #2C++spam26.01.2008 5:46 PM (957 days 16h 53m ago)-view
36 Results
Page 1 of 3