Line 19: | Line 19: | ||
− | * '''Material''', the Material helper is really neat ! It's a template against a [VertexStructure] and compiles a shader from a string, a byte[] or from a file. | + | * '''Material''', the Material helper is really neat ! It's a template against a [[#Vertex_Structures VertexStructure]] and compiles a shader from a string, a byte[] or from a file. |
In the latter case, it automatically watches the file for changes so your shader is recompiled every times the file changes (ideal for debugging !). | In the latter case, it automatically watches the file for changes so your shader is recompiled every times the file changes (ideal for debugging !). | ||
It also supports a default "Error Shader" when your shader fails to compile. | It also supports a default "Error Shader" when your shader fails to compile. | ||
− | The material also supports what I call "Shader Interfaces" (more on that here [ | + | The material also supports what I call "Shader Interfaces" (more on that here [[#Shader_Interfaces Shader Interfaces]]) which are reaaaaally useful ! |
Revision as of 16:02, 16 August 2010
Nuaj [nu-a-j'] is my little .Net renderer for DirectX 10. It's quite small and really easy to use. Source code is available here and it's free.
If you want to use it, you will need the SlimDX .Net wrapper that tightly wraps DirectX for use into .Net managed code. Also, it was created with Visual Studio 2010 and .Net Framework 4.0 so make sure you have that !
The main idea behind Nuaj is to "make my life easier", not to create the ultimate renderer that washes dishes and serves coffee. Those are never finished and you always come up with a bad surprise once it's time to use it (providing that you reach that point).
So I decided to create first a set of basic helpers to manage my stuff. Basically, all I need is to create geometry easily using vertices and/or indices, I need to create materials from shaders that compile either from memory or from file, I need to create textures and render targets to feed my shaders and rendering pipeline, tie all this together and roll the dice...
Helpers
All helpers in Nuaj derive from a base Component class that takes a Device and a Name as basic parameters for construction.
- Device, the Device helper is a singleton and wraps the DX10 Device. It contains a swap chain and a back buffer (the default render target). The standard DirectX Device methods are rewired through that new Device class.
Basically, nothing fancy here, you just create your Device with specific parameters and call "ClearRenderTarget()" and "Present()" to run the show. The Device is the first parameter needed for every other component type in Nuaj so make sure it's created first.
- Material, the Material helper is really neat ! It's a template against a #Vertex_Structures VertexStructure and compiles a shader from a string, a byte[] or from a file.
In the latter case, it automatically watches the file for changes so your shader is recompiled every times the file changes (ideal for debugging !). It also supports a default "Error Shader" when your shader fails to compile. The material also supports what I call "Shader Interfaces" (more on that here #Shader_Interfaces Shader Interfaces) which are reaaaaally useful !
Vertex Structures
Pixel Formats
Shader Interfaces
.Net Subtlety
If you create a new application from scratch and wish to use SlimDX, make sure to edit you app.config file and change these lines :
<?xml version="1.0"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> </configuration>
by these so you can use backward compatible assemblies :
<?xml version="1.0"?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> </configuration>