Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 02 Apr 2011
Offline Last Active Today, 02:55 PM

Posts I've Made

In Topic: Problems passing an XMFLOAT4 to a shader

01 July 2014 - 07:16 PM

I think the reason is you are not adding D3D11_CPU_ACCESS_WRITE flag to your constant buffer. Since you are writing data from CPU you need to use that flag.

In Topic: Questions about game developing

26 June 2014 - 07:18 AM

I have Direct X SDK.So, I must link it to visual studio and start learning ,right?

Yes. And if you start with the tutorial in that web page it starts with a tutorial to how to link it properly. Also I forgot to mention but Frank Luna's books are great for Direct X reference, it tells you most of the stuff that you need to know with detail. http://www.d3dcoder.net/ this is his web page and you can buy the book depending on the version of Direct X you want to learn. I am assuming you are going for Direct X 11.

In Topic: Questions about game developing

25 June 2014 - 06:05 PM



1- I haven't tried Code::Blocks so I can't say anything about that but I am using Visual Studio and I am pretty happy with it. Also you might need Windows SDK or Direct X sdk. Windows SDK is newer but you need Windows 7 or 8.

2- If you really want to learn what is going on with Direct X I recommend you to create your own small applications. Since most of the game engines hide the complexities from the user it is hard to learn really what is going on by learning a game engine.


In Topic: DirectX10 - Rasterizer state

29 May 2014 - 07:46 PM

What you can do is create a wrapper class for the D3D10_RASTERIZER_DESC which sets everything to its default value. Then you can change only the values you want. So you don't have to type that all the time. In my case I created a wrapper class with D3D11_RASTERIZER_DESC(I'm using DirectX 11) as its private member. But you can also create a struct or class that inherits from D3D10_RASTERIZER_DESC.

In Topic: Constant buffers and shader variables

05 May 2014 - 03:39 PM

It makes sense that different shaders have different constant buffers. One trick that you can do if you are trying to get some global variables is you can create a header file.

// MyGlobalShaderHeader.hlsli

cbuffer globalEveryFrame : register(b0)
     matrix viewMatrix;
     float4 elapsedTime; // size needs to be multiple of 16 anyways

And lets say you are using this for vertex shader. Then you can set it once in the beginning of rendering

deviceContext->VSSetConstantBuffers(0, 1, &myBuffer);

Now you can use it for all the vertex shaders that include that header. Only thing you need to be careful about is you have to make sure that you don't change register 0 between shaders that need those global variables.


So if you are trying to create a global buffer you can use that trick. But if those variables are shader specific I think it is better idea to have different constant buffers for different shaders. It is much more manageable that way. So every material can know which buffers they are responsible from.


One side not though as I wrote in the comment above constant buffers are automatically become multiple of 16 bytes. So lets say you put 1 float2 and 1 float it occupies float4 space. So when you are setting your bytewidth it needs to be multiple of 16 bytes otherwise you will get an error.