Only get black window

Home Forums Real-Time 3D Rendering with DirectX and HLSL Only get black window

This topic contains 10 replies, has 2 voices, and was last updated by  Paul Varcholik 2 years, 9 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #306

    bladematthewslp
    Participant

    This is my first time firing up any project. I am running Chapter 14’s solution on Windows 7 with Visual Studio 2013. I set the CubeDemo as the startup projected. When I run the program, I only get a black window with no cube or words.

    The DirectX Diagnostic Tool says I have DirectX 11. I do not get any errors in the Output window, but I get this warning:

    FXC : warning X4717: Effects deprecated for D3DCompiler_47

    Here is a screenshot of my result:
    http://screencast.com/t/u7fNy0Ge8

    #307

    Paul Varcholik
    Keymaster

    I suspect you might have a shader compilation error. Do you see any warnings/errors, displayed in the output window, at runtime?

    More specifically, I’m wondering if your graphics card/driver supports shader model 5. The BasicEffect.fx file employed in the Chapter 14 demos (indeed, all of the shaders in this section of the book), uses shader model 5. Try editing the BasicEffect.fx file, in the Library project, and the invocation of D3DCompileFromFile, in the CubeDemo project, to use shader model 4.

    Paul

    #311

    bladematthewslp
    Participant

    Hello, I changed the code in the BasicEffect.fx file to have “vs_4_0”.
    I also changed the shader model in the D3DCompileFromFile function to “”fx_4_0”.

    When I run the project now, I get the following error:
    http://screencast.com/t/o130JVoi

    When I rebuild the project, I do get some warnings, which are:

    FXC : warning X4717: Effects deprecated for D3DCompiler_47
    c:\program files (x86)\windows kits\8.1\include\um\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800

    #312

    Paul Varcholik
    Keymaster

    You can only use vs_4_0 for the vertex shader. You must use ps_4_0 for the pixel shader. Also, set the “fx_4_0” string, for the call to D3DCompileFromFile, back to “fx_5_0”. That’s actually about the platform target and I instructed you incorrectly.

    As to the compile-time warnings, both are fine. The FXC warning is generated because the .FX file format has indeed been deprecated. The DirectInput warning can be eliminated by including the following somewhere in your source code (typically where you #include ).

    #ifndef DIRECTINPUT_VERSION
    #define DIRECTINPUT_VERSION 0x0800
    #endif

    Paul

    #313

    bladematthewslp
    Participant

    I set the string back to “fx_5_0”. I also played around with the vs and ps version numbers in BasicEffect.fx, swapping back and forth between vs_4_0/vs_5_0 and ps_4_0/ps_5_0. None of which worked.

    I checked my DirectX setting and according to other documentation, my DirectX11-compatible graphics card should be able to support Shader Model 5.

    I witnessed another classmate fire-up chapter 14’s solution on his Windows 7 machine with Visual Studio 2013, set the Cube Demo as the startup project, and ran the project without any problems. Full text and pictures. For some reason, mine isn’t working.

    #314

    Paul Varcholik
    Keymaster

    Have you tried running any of the other demos? In Chapter 14’s solution, there is also a TriangleDemo. What results do you get when running that application?

    Have you worked through any of the shaders through FX Composer? i.e. the earlier chapters in the book? If so, what results do you see there?

    Paul

    #315

    bladematthewslp
    Participant

    Yes, I tried to run the TriangleDemo of chapter 14. I also tried the ModelDemo of chapter 15. I also tried the very first project in chapter 4. All of them show a black window.

    I’m using the source code and book for a DirectX class and mostly everyone else was able to load chapter 14 with no problem. So I haven’t actually done any exercises, if there are any, from the book or done anything with shaders yet. I was simply testing out the code to see if it runs on my machine.

    One thing I recall from my work with OpenGL is I had to change the GLSL version to 3.3 (I believe) from the modern 4.x something because admittedly I do have a 2 or 3 year old Hp Pavilion dv6 Intel Core i7 laptop with a dedicated 2 GBs of video memory. But I was able to get it to run after lowering the shader version. I’m not sure if HLSL has shader versions like that (perhaps that’s what Shader Model versions are), but there may be something I need to adjust in the code to compensate for that. I just don’t know what it could be.

    I’m including a screenshot of the project properties. I didn’t change anything, but perhaps upon further evaluation you may notice something I need to modify here:

    Chapter 15 ModelDemo Project properties:
    http://screencast.com/t/yTpIbqbKUi8K

    #316

    bladematthewslp
    Participant

    I opened Chapter 11 this time in Visual Studio 2012, rebuilt the projects and ran the Game project. Same thing. Black screen.

    Chapters 12, 13, and 14 will not build at all after updating the Platform Toolset to Visual Studio 2012. I get several linker errors, including:

    DirectXTK.lib(SpriteBatch.obj) : error LNK2038: mismatch detected for ‘_MSC_VER’: value ‘1800’ doesn’t match value ‘1700’ in Program.obj

    DirectXTK.lib(SpriteFont.obj) : error LNK2038: mismatch detected for ‘_MSC_VER’: value ‘1800’ doesn’t match value ‘1700’ in Program.obj

    DirectXTK.lib(pch.obj) : error LNK2038: mismatch detected for ‘_MSC_VER’: value ‘1800’ doesn’t match value ‘1700’ in Program.obj

    DirectXTK.lib(CommonStates.obj) : error LNK2038: mismatch detected for ‘_MSC_VER’: value ‘1800’ doesn’t match value ‘1700’ in Program.obj

    DirectXTK.lib(VertexTypes.obj) : error LNK2038: mismatch detected for ‘_MSC_VER’: value ‘1800’ doesn’t match value ‘1700’ in Program.obj

    DirectXTK.lib(BinaryReader.obj) : error LNK2038: mismatch detected for ‘_MSC_VER’: value ‘1800’ doesn’t match value ‘1700’ in Program.obj

    RenderingGame.obj : error LNK2019: unresolved external symbol “public: void __fastcall DirectX::SpriteBatch::Begin(enum DirectX::SpriteSortMode,struct ID3D11BlendState *,struct ID3D11SamplerState *,struct ID3D11DepthStencilState *,struct ID3D11RasterizerState *,class std::function<void __cdecl(void)>,struct DirectX::XMMATRIX const &)” (?Begin@SpriteBatch@DirectX@@QAIXW4SpriteSortMode@2@PAUID3D11BlendState@@PAUID3D11SamplerState@@PAUID3D11DepthStencilState@@PAUID3D11RasterizerState@@V?$function@$$A6AXXZ@std@@ABUXMMATRIX@2@@Z) referenced in function “public: virtual void __thiscall Rendering::RenderingGame::Draw(class Library::GameTime const &)” (?Draw@RenderingGame@Rendering@@UAEXABVGameTime@Library@@@Z)

    Libraryd.lib(FpsComponent.obj) : error LNK2001: unresolved external symbol “public: void __fastcall DirectX::SpriteBatch::Begin(enum DirectX::SpriteSortMode,struct ID3D11BlendState *,struct ID3D11SamplerState *,struct ID3D11DepthStencilState *,struct ID3D11RasterizerState *,class std::function<void __cdecl(void)>,struct DirectX::XMMATRIX const &)” (?Begin@SpriteBatch@DirectX@@QAIXW4SpriteSortMode@2@PAUID3D11BlendState@@PAUID3D11SamplerState@@PAUID3D11DepthStencilState@@PAUID3D11RasterizerState@@V?$function@$$A6AXXZ@std@@ABUXMMATRIX@2@@Z)

    RenderingGame.obj : error LNK2019: unresolved external symbol “public: void __fastcall DirectX::SpriteFont::DrawString(class DirectX::SpriteBatch *,wchar_t const *,struct DirectX::XMFLOAT2 const &,union __m128,float,struct DirectX::XMFLOAT2 const &,float,enum DirectX::SpriteEffects,float)” (?DrawString@SpriteFont@DirectX@@QAIXPAVSpriteBatch@2@PB_WABUXMFLOAT2@2@T__m128@@M2MW4SpriteEffects@2@M@Z) referenced in function “public: virtual void __thiscall Rendering::RenderingGame::Draw(class Library::GameTime const &)” (?Draw@RenderingGame@Rendering@@UAEXABVGameTime@Library@@@Z)

    Libraryd.lib(FpsComponent.obj) : error LNK2001: unresolved external symbol “public: void __fastcall DirectX::SpriteFont::DrawString(class DirectX::SpriteBatch *,wchar_t const *,struct DirectX::XMFLOAT2 const &,union __m128,float,struct DirectX::XMFLOAT2 const &,float,enum DirectX::SpriteEffects,float)” (?DrawString@SpriteFont@DirectX@@QAIXPAVSpriteBatch@2@PB_WABUXMFLOAT2@2@T__m128@@M2MW4SpriteEffects@2@M@Z)

    I don’t understand why this is happening at all…

    #319

    Paul Varcholik
    Keymaster

    Your original problem was unrelated to a compiler or linker problem, nor a problem with your Visual Studio project configuration. Prior to your installation of the platform update you were compiling and linking successfully. Had you had a project configuration issue, that would not have been the case.

    The external libraries, referenced by the various projects in the book’s demo code, were compiled using Visual Studio 2013. You won’t be able to use those libraries in Visual Studio 2012 without rebuilding the libraries. My recommendation is that you use Visual Studio 2013.

    To your original problem, it still points to a driver or video card issue — more supported since you stated that you had OpenGL 4.x issues. I recommend that you open the Chapter 4 projects in FX Composer — not Visual Studio 2013 — in order to diagnose the problem further. FX Composer doesn’t render with DirectX 11, it uses either DirectX 9 or DirectX 10 (you choose this). If you can render the Chapter 4 shaders (likewise for the shaders presented in Chapters 5 – 9) that will tell you that your card is having trouble with DirectX 11. Read Chapters 3 and 4 for a walk through of using FX Composer and a discussion of those first shaders.

    I also wonder if you’ve updated your video card driver to the latest revision?

    Paul

    #320

    bladematthewslp
    Participant

    Hello,

    I was able to update my AMD Radeon Graphics driver and I am now getting something besides a black window. In the chapter 14 and 15 projects, I am now getting a blue background with the frame rate and elapsed time counter. See videocast here: http://screencast.com/t/gZvpqdVMtoHA

    From my understanding, there is supposed to be a shape rendered here in the CubeDemo and TriangleDemo projects. Any idea what could be causing the shapes not to render? I tried setting the shader model to 4 in the BasicEffects.fx file as recommended earlier but the shape still did not render.

    #322

    Paul Varcholik
    Keymaster

    Sounds like you’ve made some progress and are headed in the right direction. Yes, the CubeDemo renders a cube and the TriangleDemo renders a single, spinning triangle.

    Have you installed FX Composer and tried rendering the book’s earlier shaders using DirectX 9 or 10? That’s the next step here — determining if there’s an issue with DirectX 11 specifically.

    Paul

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.