Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 24 Apr 2012
Offline Last Active Feb 02 2015 10:16 PM

Topics I've Started

Render To Texture

02 February 2015 - 06:16 PM

I'm trying to render the scene to texture and draw nothing on the back buffer 
// Set the render target to render to texture
devContext->OMSetRenderTargets(1, &renderToTextureTargetView, depthStencilView);
// Clear
devContext->ClearRenderTargetView(renderToTextureTargetView, D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f));
devContext->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);


swapChain->Present(1, 0);

// I'm expecting the above code to draw the scene to the texture not to the back buffer

// Done, now set render target to back buffer
devContext->OMSetRenderTargets(1, &backBuffer, depthStencilView);

I'm expecting to have the scene rendered to the texture, but what happens is that I get a blank black texture and the mesh is rendered to the back buffer (I see the mesh on the screen).


Any idea what's wrong?



Sending World, View and Projection Matrices To D3D9 Vertex Shader

31 January 2015 - 07:05 AM

Passing world, view, project matrices to the vertex shader in D3D11 can be done by creating constant buffer, then using deviceContext->VSSetConstantBuffers()


Now I'm trying to do the exact same thing in D3D9, I have in the shader file:

cbuffer MatrixBuffer
     matrix worldMatrix;
     matrix viewMatrix;
     matrix projectionMatrix;

How do I pass world, view and projection matrices to this vertex shader in D3D9?


EDIT: I don't want to use ID3DXEffect.

Questions about D3D9 and D3D11

28 January 2015 - 06:18 PM

I'm now working on interface to support both D3D9 and D3D11, I have several questions:
1. How do I change the values of D3D11_RASTERIZER_DESC during rendering?
Lets say I have to switch between cull modes, usually I create two D3D11_RASTERIZER_DESC (RasterizerCullModeNone and RasterizerCullModeBack)
Now, the problem is that I could set RasterizerCullModeBack while I want to enable wirefire mode at the same time, other times I will want to use RasterizerCullModeBack while I don't want wirefire mode.
So what the is the correct way to handle that so I can freely change the values of D3D11_RASTERIZER_DESC during rendering?
2. How come device->CheckMultisampleQualityLevels() is inside the deivce class? usually I will need to get the values from this function before I create the device
Do I have to create the device twice in order to use device->CheckMultisampleQualityLevels()?
3. I'm using interface to support several versions of D3D, the interface "IRenderer" should handle everything related to creating buffers and drawing, now I'm trying to create the draw function, what parameters should be used for the draw function IRenderer::Draw() so the draw call should execute on either IRenderer9 or IRenderer11 (based on the selected D3D version)?
4. What is the most efficient way to handle things like per pixel light, fog, bump mapping in the engine?
Should I create one single shader file and use it to do all the effects that the engine support?
If Yes, what if the developer who works on the engine wants to add some effects not supported by the engine using the shader? Should I render the mesh twice in order to use both shaders (the custom one created by the developer and the game engine default shader)?
5. Is there is performance different between D3DXMath and XNMath? What are the major difference? What is commonly used in latest FPS games?

FPS Camera Bouncing On the Terrain

28 January 2015 - 06:13 AM

I have implemented FPS Camera by using Capsule Shape in Bullet Physics.


That works, however I see the player sometimes bounce on the terrain which is unrealistic behavior. 


How do I make the player never bounce on the terrain using Bullet Physics?

3D Box Texture Coordinates

26 January 2015 - 08:25 PM

I have 3D box with the following vertices:

CUSTOM_VERTEX vertices[] = 
    {  D3DXVECTOR3(-1.0f, 1.0f, -1.0f), Texcoord[0], D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f) },
    {  D3DXVECTOR3(1.0f, 1.0f, -1.0f), Texcoord[1], D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f) },
    {  D3DXVECTOR3(1.0f, 1.0f, 1.0f), Texcoord[2], D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f) },
    {  D3DXVECTOR3(-1.0f, 1.0f, 1.0f), Texcoord[3], D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f) },
    {  D3DXVECTOR3(-1.0f, -1.0f, -1.0f), Texcoord[4], D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f) },
    {  D3DXVECTOR3(1.0f, -1.0f, -1.0f), Texcoord[5], D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f) },
    {  D3DXVECTOR3(1.0f, -1.0f, 1.0f), Texcoord[6], D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f) },
    {  D3DXVECTOR3(-1.0f, -1.0f, 1.0f), Texcoord[7], D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f) },


and indices as the following:

DWORD indices[] =






Now, what values should I put in the array Texcoord[] so I can have a valid texture coordinate for the box?


I tried to put different texture coordinates but I can't get the box to appear as expected.


According to what I know the texture coordinates for the box should be as the following:

Attached File  TextureCoordSys.jpg   30.36KB   0 downloads


Which means the following should form one side of the box:

D3DXVECTOR2(0.0f, 0.0f) // Vertex: 1
D3DXVECTOR2(1.0f, 0.0f) // Vertex: 2
D3DXVECTOR2(0.0f, 1.0f) // Vertex: 3
D3DXVECTOR2(1.0f, 1.0f) // Vertex: 4
If I'm correct, what texture coordinates values should I put for Vertex 5, 6, 7, 8?