Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


MikeBMcL

Member Since 06 Sep 2012
Offline Last Active Oct 29 2013 08:32 AM

#5029339 Stereoscopic 3D - how to create a swapchain

Posted by MikeBMcL on 06 February 2013 - 03:01 AM

Try changing

 

    if(FAILED(m_dxgiFactory->CreateSwapChainForHwnd(
        m_device,
        p_hWnd,
        &m_swapChainDesc,
        &m_swapChainFullscreenDesc,
        m_dxgiOutput,
        m_swapChain.ptr())))
        throw "Failed to create DXGI swap chain";

 

to

 

    HRESULT hr;
    hr = m_dxgiFactory->CreateSwapChainForHwnd(
        m_device,
        p_hWnd,
        &m_swapChainDesc,
        &m_swapChainFullscreenDesc,
        m_dxgiOutput,
        m_swapChain.ptr());

    if (FAILED(hr))
    {
        std::stringstream str;
        str << "Failed to create DXGI swap chain. HR: 0x" << std::hex << std::uppercase << static_cast<unsigned long>(hr) << std::endl;
        OutputDebugStringA(str.str().c_str());
        throw str.str().c_str();
    }

 



Note that you'll need to #include <string> <sstream> <ios> and <ostream>. Also, I'd generally recommend throwing C++ standard library-based exceptions rather than raw ASCII strings and working in Unicode (e.g. L"Something" rather than "Something") along with the corresponding wide character variants of the STL functionality (e.g. std::wstringstream) and Windows API calls (OutputDebugStringW).

Once you have the HRESULT code from the swap chain failure, you'll potentially have much more information than just that the call failed.

At a guess, what's probably going on based on the code you provided you are passing in for the HWND a parameter named "p_hWnd". If that's really a pointer to an HWND, you should be passing in "*p_hWnd" since the API call is expecting an HWND, not a pointer to one.

Also, from the documentation - http://msdn.microsoft.com/en-us/library/hh768891(v=vs.85).aspx , you are calling m_dxgiFactory->IsWindowedStereoEnabled to check for stereo support but this just tells you whether or not you can render a windowed app in stereo. The proper check for a full screen app is to call IDXGIOutput1::GetDisplayModeList1 and see if any of the returned modes supports stereo. You are doing that anyway but your initial call to IsWindowedStereoEnabled is superfluous and might even improperly exclude stereo if the card didn't support windowed stereo with its current settings but would support full screen stereo.




#4999092 Understanding Buffer, Texture, and Sampler "registers"

Posted by MikeBMcL on 08 November 2012 - 07:20 PM

You can, yes, though it's probably better to just use an include file for common structs and define the shader-specific buffers in each shader's HLSL file. Or are you planning to put all of the shaders into one file?

(Note: By "you can" I mean that I tested compiling a vertex and pixel shader with two cbuffers both assigned to register(b0) where only one of those cbuffers is used and that I received no compile errors using the built-in shader compilation with VS 2012 and the Windows 8 SDK; you might have different results if you compile using an older version of fxc even though it should in theory work fine. It's not super hard to test so if you are using an older fxc, just try it and see what happens.).


#4996751 Pixel shader executing wrong

Posted by MikeBMcL on 02 November 2012 - 09:48 PM

You didn't mention which shader model you are using, but I'm guessing you aren't familiar with branch and flatten attributes: http://msdn.microsof...610(VS.85).aspx . Try moving your tex2d call before the if and then just assign the correct float4 color inside the if-else.


#4996468 XNA's Future

Posted by MikeBMcL on 02 November 2012 - 02:56 AM

Engine and system level development is in C++. 'Most' of the game world programming game logic in scripting languages for their engines or doing other tasks. There are many tasks in game development.

I forgot about point sprites. But they could easily be replicated with quads (even improved upon) so it's hard to argue that anything was lost through their removal. And I saw their removal as one of many steps preparatory to moving the code base to DX10/11 (even though that ultimately hasn't happened). I do agree with PC being the least-loved platform for XNA. Anyway, I quoted that snippet because yeah I know there are other aspects of game development. But if you are planning to work in the programming aspects at all, you need only look through the job postings to see that (for the most part) people without C++ knowledge need not apply (even if you ultimately end up in a sub-discipline where you never end up writing any C++). Indeed, things like Lua interpreters written in C++ are some of the many things in the "libraries, tool chains" groups that made it impossible for most shops to consider going to C#. The expense of writing a Lua interpreter in C# likely wouldn't be too high as a stand-alone task, but add in physics, content ingestion, other ad-hoc interpreters and parsers, and everything else, (not to mention 3rd party middleware that you have little to no control over) and the costs can quickly become prohibitive. It's the same reason that people like my father are paid well to write new COBOL code (and maintain and update existing code); the existing millions upon millions of lines of COBOL code that his company has represent an astronomical sum of time and money when looked at from a replacement cost point of view but a relatively minor sum when looked at from a maintenance and update cost point of view. The same is true with C++ and game development, and that was my point.


#4996371 XNA's Future

Posted by MikeBMcL on 01 November 2012 - 06:04 PM

Several things. First, XNA is in the WP8 SDK. And if you want to write Windows Phone games that target WP7 and WP8 hardware then XNA is the only real option since the DirectX stuff is WP8 hardware only. If you want to develop XNA games for Xbox or PC then you need to download the WP7.1 SDK and the WP7.1.1 update to it. Second, XNA 4 didn't throw Xbox games under the bus. Off hand, the only thing that Xbox lost from 3.1 to 4.0 was 8192x8192 textures. As long as your switched to the HiDef profile you could do everything else (and a lot of it even got faster since they batched up state changes rather than pushing them one-by-one to the GPU). And if you look at the API changes made to XNA 4, they seem clearly designed towards moving XNA's guts from DX9 to DX10/11. But it seems extremely unlikely that that will happen at this point. If I had to guess why, I would say it was a combination of too many studios and developers being unwilling/unable to move from C++ to C# (due to experience, familiarity, libraries, tool chains, etc.) combined with the new Windows Runtime accomplishing all the sandboxing without the requirement to use C# and .NET. At this point it seems that DirectX 11+ and Windows Runtime are the future of the MS game development stack. XNA is in some sort of maintenance mode. It remains a good tool for teaching the basics of game development, but as most of the game development world can't or won't move away from a core of C++, anyone who really wants to get into the industry will need to learn C++ and DirectX/OpenGL eventually anyway. And there will continue to be projects like SharpDX, SlimDX, and MonoGame to keep things alive for developers who do want .NET game development.


#4991697 Good C++11 resources for advanced programmer

Posted by MikeBMcL on 19 October 2012 - 12:41 AM

Over the summer I wrote a free (reg-ware) eBook for SyncFusion targeted at C# developers aiming to learn modern C++. You might find it helpful as it covers const-correctness, the cast operators and their use cases, references, the ins and outs of all the constructors and assignment operators, namespaces (something I think is important in modern C++ but which is easy for people coming back to it to overlook or ignore), RAII and the Standard Library's smart pointers (unique_ptr, shared_ptr, the make_shared function) and (for Windows) ComPtr, strings (much better than they used to be but they could be better still), lambdas, some basic idioms, and some of the other important features of the C++ Standard Library (std::vector and other containers, iterators in general, and some miscellany suggestions for things to look into further).

It's not as strong on the Standard Library as it could be, but the design goal was approximately 100 pages with a focus on practical examples (there are ~20 sample programs with full code). Link here: http://www.syncfusion.com/resources/techportal/ebooks/cplusplus ; intro/overview here: http://channel9.msdn.com/coding4fun/blog/C-for-C-Developers-with-C-Succinctly . Comes in PDF and MOBI and the code samples are available on bitbucket: https://bitbucket.org/syncfusion/cpp_succinctly .

(I've already been paid for it and don't get any bonuses for downloads or anything so I'm recommending it purely on a "you may find it useful" basis, without any ulterior motives. If you download it and it helps you, great! If you skip it, that's fine too.)

Ultimately when the next edition of The C++ Programming Language comes out in March, that'll definitely be the book to get.


PARTNERS