Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 31 Oct 2012
Offline Last Active Jul 04 2016 06:27 PM

#5217909 Can't release BackBuffer before calling SwapChain->ResizeBuffers

Posted by on 20 March 2015 - 12:39 PM

Thanks Erik Rufelt...


I have solved it...

I took your advice and created a minimal app copy of the original, cutting the program down to the production of a resizable window. 'Unfortunately' it worked fine! The entire thing was inlined in a translation unit. I was going to post it here but didn't see the point as it did not reproduce the error. So I tried to keep the structure of the original and started to slowly shave parts of the project off until it worked - thereby revealing the culprit code. But that proved too difficult as I couldn't just unplug certain classes - it would mean a redesign of everything. So then I tried firing up the Graphics Debugger to see if it would display the inner workings of what might be going wrong. It mysteriously failed on the creation of the SwapChain with E_NOINTERFACE. This was a blessing in disguise as it lead me to the very area of the problem. Whilst trying to make that work I found that in my attempt to upgrade from DX11.0 to DX11.1 I was going around upgrading the version suffixes of the DX components namely the SwapChain/Device/Context/Adapter/Factory etc.. Here where I created the Adapter and Factory, in my cross-eyed-ness, I had left out the correct suffixes for the uuidof(...) part. It should have been:

Microsoft::WRL::ComPtr<IDXGIAdapter2> spDxgiAdapter;
HR(spDXGIDevice->GetParent(__uuidof(IDXGIAdapter2), (void**)&spDxgiAdapter));
Microsoft::WRL::ComPtr<IDXGIFactory2> spDxgiFactory;
HR(spDxgiAdapter->GetParent(__uuidof(IDXGIFactory2), (void**)&spDxgiFactory));

Oh man, that created all sorts of havoc. I should have given more info in the beginning then you guys may have picked it up.


Thanks profusely.

#5191372 Bizarre Quad's Triangles but a Cube is ok

Posted by on 05 November 2014 - 12:37 PM

*Solved* (See below)

@Buckeye... Thanks for your detailed response here is the info as you requested...



You've shown an inclination to just hack at the values (not good), so, once again, bear with us.


lol, True I confess it's not conducive to a systematic analysis & deduction for the problem. I appreciate your thoughts.



You have #include "TextureMapping.h" in the shader_vs/ps files, but you haven't posted that file.


Oops... I shouldn't have changed that. I don't know what I was thinking. The files are actually called 'TextureMapping_VS.hlsl' & 'TextureMapping_PS.hlsl' and not 'shader.hlsl'. They both reference a 'TextureMapping.h' which contains all the data structures in one place. Here is TextureMapping.h:

#define FLIP_TEXTURE_Y 0

// Constant Buffer Variables
Texture2D txDiffuse    : register(t0);

SamplerState samLinear : register(s0);

cbuffer cbNeverChanges : register(b0)
    matrix xmView;

cbuffer cbOnResize     : register(b1)
    matrix xmProjection;

cbuffer cbEveryFrame   : register(b2)
    matrix xmWorld;
    float4 f4MeshColor;

// Data Structures
struct VS_INPUT
    float4 Pos : POSITION;
    float2 Tex : TEXCOORD0;

struct PS_INPUT
    float4 Pos : SV_POSITION;
    float2 Tex : TEXCOORD0;

// Utility Functions
// ###### This is not called yet !!! I haven't got to experimenting with it yet. ######
float2 Get_Corrected_Texture_Coordinate(float2 f2TexCoord)
        return float2(f2TexCoord.x, 1.0 - f2TexCoord.y);
        return f2TexCoord;

you need to verify that and ensure you're compiling your code correctly.


There are no compilation errors. No directx debug info/errors. No Memory leaks.



3. Post the code for setting the vertex shader, pixel shader, vertex buffer, index buffer, and input layout.

	m_uiStride = sizeof(stVERTEX_POS_TEX); // <===========  This struct was wrong - ok now
	m_uiOffset = 0;
	m_spD3DObj->m_spD3DImmediateContext->IASetVertexBuffers(0,          // 0 - 15 Input slots
															1,          // Number of vertex buffers
															m_spVertexBuffer.GetAddressOf(), // pFirst element in array of VBs
															&m_uiStride,  // pFirst element in array of strides
															&m_uiOffset); // pFirst element in array of offsets. Use to skip Vertices.

	m_spD3DObj->m_spD3DImmediateContext->IASetIndexBuffer(m_spIndexBuffer.Get(),      // Index buffer
														  DXGI_FORMAT_R32_UINT, // Must be same as D3D11_BUFFER_DESC.ByteWidth
														  0);                   // Offset to skip indicies

*Forehead slapping moment*

When looking through the code I saw immediately that the 'stride' when setting the vertex buffers was wrong. I was instead using this structure:

    DirectX::XMFLOAT3 Pos;
    DirectX::XMFLOAT4 Color;

Instead of:

    DirectX::XMFLOAT3 f3Pos;
    DirectX::XMFLOAT2 f2Tex;

So when I put the texture coords in the buffer expected 2 more float values for the vertex and filled it with the x and y for the next vertex. So then the next vertex would have its X value start with the Z value!


Here is the screenshot of the successful quad. (Happy times are here again (for now))



Thanks profusely !!!

#5187486 Help using DirectX SDK

Posted by on 16 October 2014 - 03:21 PM


But for some reason he used 'i's instead of '1's, and there is also no 'EffectsIId.lib' or 'Effects11d.lib' in my DirectX lib files.  



You will need to download Effects11 source files and build it yourself with the correct configuration (win32/x64/debug/release) (also watch out for the ProjectProperties->General->toolset used) from Here: https://fx11.codeplex.com/  Note that the debug configuration of Effects11.lib doesnt have the 'd' in it! Point all your #includes to the directory or better yet copy and paste the .lib file into your project area. Its handy being able to step through the Effects11 source code while you are debugging your code, which is why it is provided.


Supplemental: If you can - you could convert Luna's book to use DX11's DirectXMath and away from the deprecated D3DX libraries http://blogs.msdn.com/b/chuckw/archive/2013/08/21/living-without-d3dx.aspx The guy's name is Chuck Walbourn check out everything from him.

#5175708 Setting a path for objects

Posted by on 23 August 2014 - 05:59 PM

Oops maybe the SetPath call needs to be just above the IF statement so that it sets all object's properties.

#5175706 Setting a path for objects

Posted by on 23 August 2014 - 05:54 PM

Sorry for the confusion. Ok so instead of:

float Scalar = (float)timeGetTime();
Scalar = (Scalar -StartTime) * 0.0003f;
if(CurrentPath == 1)
stVector diff;
diff.x = Path[1].x - Path[0].x;
diff.y = Path[1].y - Path[0].y;
diff.z = Path[1].z - Path[0].z;
float len = (float)sqrt((diff.x * diff.x +
                   diff.y * diff.y +
diff.z * diff.z));
Scalar = Scalar / len;
objPos.x = (Path[1].x - Path[0].x) * Scalar + Path[0].x;
objPos.y = (Path[1].y - Path[0].y) * Scalar + Path[0].y;
objPos.z = (Path[1].z - Path[0].z) * Scalar + Path[0].z;
stVector diff;
diff.x = Path[3].x - Path[2].x;
diff.x = Path[3].y - Path[2].y;
diff.x = Path[3].z - Path[2].z;
float len = (float)sqrt((diff.x * diff.x +
                    diff.y * diff.y +
diff.z * diff.z));
Scalar = Scalar / len;
objPos.x = (Path[3].x - Path[2].x) * Scalar + Path[2].x;
objPos.y = (Path[3].y - Path[2].y) * Scalar + Path[2].y;
objPos.z = (Path[3].z - Path[2].z) * Scalar + Path[2].z;
if(Scalar >= 1.0f)
StartTime = (float)timeGetTime();
if(CurrentPath > 2) CurrentPath = 1;

May be try:

float Scalar = (float)timeGetTime();
Scalar = (Scalar -StartTime) * 0.0003f;

if(Scalar >= 1.0f)
    SetPath(CurrentPath, CurrentPath + 1, Scalar);
    StartTime = (float)timeGetTime(); 
    if((CurrentPath + 1) > MaxPathCount) 
        CurrentPath = 0; 

What is happening is you can call SetPath(...) Every second then if within bounds increment CurrentPath else set to zero.

#5175700 Setting a path for objects

Posted by on 23 August 2014 - 05:04 PM

also maybe replace:

if(CurrentPath > 2) CurrentPath = 1;


if(CurrentPath > MaxPathCount) CurrentPath = 0;

And oh dear sorry about the for loop I gave you... You need to be able to call that SetPath(...) every frame.  Make CurrentPath global. So that it will remember the last frame's number. Then in your render loop:

SetPath(CurrentPath, CurrentPath + 1);

Also as I said I would be best if you set up your Path[n].x to equal minus then plus alternatingly. Then you could add as many as you like but remember to change you MaxPathCount also. I hope this works for you.





#5175684 Setting a path for objects

Posted by on 23 August 2014 - 02:12 PM

I'm not sure but i think it goes from Path[0] to Path[1] then Path[2] to Path[3]. It would be easier if it went from Path[0] to Path[1] to Path[2] to Path[3]. Then it would be a simple case of iterating over them. Try maybe this instead of your if-else:

// Needs to know about diff, Scalar and obPos. I assume they are global
void SetPath(UINT uiStart, UINT uiEnd)
	diff.x = Path[uiEnd].x - Path[uiStart].x;
	diff.y = Path[uiEnd].y - Path[uiStart].y;
	diff.z = Path[uiEnd].z - Path[uiStart].z;
	float len = (float)sqrt((diff.x * diff.x +
					   diff.y * diff.y +
	diff.z * diff.z));
	Scalar = Scalar / len;
	objPos.x = (Path[uiEnd].x - Path[uiStart].x) * Scalar + Path[uiStart].x;
	objPos.y = (Path[uiEnd].y - Path[uiStart].y) * Scalar + Path[uiStart].y;
	objPos.z = (Path[uiEnd].z - Path[uiStart].z) * Scalar + Path[uiStart].z;

Then call via:

for (UINT i = 0; i < MaxPathCount; i++)
    SetPath(i, i+1);

Make sure you #define MaxPathCount to be the maximum number of paths. Don't go out of subscript btw.

The following might not work unless you put them in order properly as I said above.

#define MaxPath 6

Path[0].x = -2.5f; Path[0].y = 1.0f; Path[0].z = 0.0f;
Path[1].x =  2.5f; Path[1].y = 1.0f; Path[1].z = 0.0f;
Path[2].x =  2.5f; Path[2].y = 1.0f; Path[2].z = 0.0f;
Path[3].x = -2.5f; Path[3].y = 1.0f; Path[3].z = 0.0f;
Path[4].x = -2.5f; Path[4].y = -1.0f; Path[4].z = 0.0f;
Path[5].x = -2.5f; Path[5].y = 1.0f; Path[5].z = 0.0f;

#5172538 Pls suggest debugging t'kniques for why I can't display a cube

Posted by on 09 August 2014 - 08:14 PM

Ok I've got it!


Simple mistake: the tutorial had a call to OnResize and I misinterpreted the program flow. It was a virtual function call that the derived overrided and in turn called the parent before setting up the projection with XMMatrixPerspectiveFovLH. I simply had to trigger an OnResize from within an init-function somwhere.


Happy days are here again...!

#5140909 Can't delete static singleton pointer (a deinitialization fiasco)

Posted by on 21 March 2014 - 04:06 AM

Good morning...

Ok I've solved it fully and finally...!!!


I was sleeping and in my dream I dreamed that the shared pointer depended on the fstream(s). The static ofstream and ifstream were created after the shared pointers! I simply moved them to the top,  et voila, no more access violation.


Thank you Jesus!