Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 07 May 2010
Offline Last Active Today, 04:09 AM

#5168827 This singleton keeps crashing.

Posted by on 24 July 2014 - 02:42 AM

This *(int*) doesnt work in my opinion, because you subtract the content of the adresses instead of subtract the addresses of the pointers. This little piece of code should just calculates the offset from the Singleton class to the covered class. So in memorylayout the ms_Singleton-member needs its 4 or 8 byte for its pointer-storage. Appended to ms_Singleton the covered-class members are aligned. So to get the right startposition when GetSingleton is used, the pointer is shifted by the calculated offset. Afaik this code was a workaround for older compilers and the newer ones automatically calculate those pointer-shiftings. I would give it a try to just cast the pointer ms_Singleton = (T*)this;

In VS2013 it should probably work, but I haven't tried it on Linux or Mac.

Btw. using int as datatype is critical, because it's size isn't constant through x86 and x64 and different OS. You should use char, short or long.

#5125395 Octrees

Posted by on 21 January 2014 - 10:58 AM

Quadtrees are a 2D subdivision, octrees are 3D or "2 quadtrees on top of each other".

In quadtrees the division is only in 2 axis (x,y). So the z-position of an object doesn't matter.

In octrees the third axis is also used for subdivision, so the z-position is evaluated, if an object is in the upper or lower quadtree of an octree.

#5125100 SwapChain resize questions

Posted by on 20 January 2014 - 12:03 PM

I had the same issue, when I implemented the resizing and also got some ugly synchronization problems up to bluescreens from graphiccard-driver, cause I rendered in another thread to the window-messagequeue and called the resize-function on every WM_MOVE event.

When you trigger your resizefunction? I guess the order Drawing->Present->Resize or Resize->Drawing->Present should reduce flickering. In my solution I ended up in just resize the textures when resize is finished. So the rendered image gets scaled while resizing and corrected just once afterwards.

#5103437 [SharpDX] Not sure why resizing my window causes jagged polygon edges

Posted by on 22 October 2013 - 11:42 AM

Just guessing, but you use _form.Width and .Height for your new SwapChainTarget-sizes. I think these values are the dimension of the full window including titlebar, border etc. You must use the clientarea-size of your form for correct width and height.


btw: In MSDN the ResizeEnd Event is also triggered when dragging on caption bar.


You may check this eventtype, too.

#5074436 DX11 - Multiple Render Targets

Posted by on 01 July 2013 - 07:53 AM

Are you using the second and third Rendertarget after rendering to them as InputTexture for e.g. final combining the image? If so you have to unset the textures from your shaderresources. You can't read and write from and to the same resource at same time. In the first resourceslot you propably using another texture as input.

#5068120 Can any1 tell me why directx is not initalizing

Posted by on 07 June 2013 - 05:39 PM

So swapChain is null and the function GetBuffer goes into nirvana.

Reason is, D3D11CreateDeviceAndSwapChain fails. Modify your line as I posted to get more information about the problem. Are you sure your graphicscard can do 4xMultisampling? First try the default mode


    scd.SampleDesc.Count = 1;                               // how many multisamples
    scd.SampleDesc.Quality = 0;                             // multisample quality level

#5067982 Can any1 tell me why directx is not initalizing

Posted by on 07 June 2013 - 05:55 AM

The error says one of your used variables is not created. So dev, swapChain oder devcon is probably null. The functions D3D11CreateDeviceAndSwapChain and CreateRenderTargetView returning a HRESULT Errorcode, which you can use to locate the problem.


HRESULT result = D3D11CreateDeviceAndSwapChain(...);
if(FAILED(result)) {


Or just start your application in debugmode. In Visual Studio the debugger stops at the problematic sourceline.

#5062344 Soft filtering edge of tilebase Terrain

Posted by on 16 May 2013 - 12:33 PM

How do you calculate the normals for your quads? Just inside the quad or with corresponding neighbours? Your first screen looks like first option.

When you calculate a normal for one heightmap point by all 4 triangles, which use the same point, you should get a smooth shading.


|\ /|
| P |
|/ \|

#5022236 Howto: 2D in DirectX Questions

Posted by on 16 January 2013 - 11:30 AM

For a 2D game with Direct3D you need an orthogonal projection matrix, so z-axis is disabled in projection.

To draw a sprite you can either draw a quad with a texture or create the quad within a geometryshader.

For rotation, scaling,... you can modify your modelmatrices.


An alternative is Direct2D, where you can "draw like in MSPaint". You can also draw rectangles with bitmaps to use it as sprites. The API also provides opacity and mask so you can stencil out e.g. the character-sprites. And you can rotate, zoom etc with easier matrix-manipulations.


Maybe Direct2D is a better start to get into the world of 2D and advance to D3D afterwards.

#5012841 "Shield" shader - How to create "bullet effects" and borders?

Posted by on 20 December 2012 - 11:03 AM

There's a huge presentation (http://www.gdcvault.com/play/1014348/HALO-REACH-Effects) from Halo Reach, where they explain, how they did their shield effects and also a portal effect. It looks quite interesting and may help you.

#5000965 Trouble texture mapping from font images (SlimDX, DX11)

Posted by on 14 November 2012 - 11:37 AM

How do you perform your transformation of those texture coordinates? Your transformed coordinates look like you multiply them with the orthogonal view or something.
You can precalculate the coordinates by dividing with texture size e.g.

int texsize=256;
newTexturePositions[0] = new Vector2(textX*16/texsize,textY*16/texsize); // 0: top left

or you can calculate it in pixelshader by providing texturesize via constantbuffer. Calculation is the same:

psInput.u /= constantBuffer.TexSize;
psInput.v /= constantBuffer.TexSize;

#4896812 [HLSL] mul(WorldViewProj, position)?

Posted by on 23 December 2011 - 07:32 AM

Is your WVP-Matrix column-major? When you are using D3DX-functions you have to transpose your matrices before sending them to shaders.