C++ - Using DirectSound or XAudio2 with EAX - c++

Is there any sample/tutorial/resource of using EAX with DirectSound or XAudio2 in C++? I cant find anything and I really need that for my game engine.

First of all, DirectSound is ancient at this point. It is still supported for older games, and the DirectSound 8 headers are in the Windows SDK, but there's been no samples or documentation updates for it in over a decade.
The Windows audio driver model (WDM), however, does not support hardware audio mixing like that required for Creative EAX. Support for this was removed as of Windows Vista, so EAX cannot be used through either DirectSound or XAudio2.
To sum up the Windows Vista driver model changes w.r.t to DirectSound:
LOC_SOFTWARE buffers can support surround sound multi-channel formats. On Windows XP only mono or stereo were supported for LOC_SOFTWARE.
LOC_HARDWARE buffers are not supported.
Effects (I3DL, EAX, etc.) are not supported through DirectSound.
DirectSound 3D positioning is limited to mono sounds.
XAudio2 supports environmental reverb and 3D audio positioning including multi-channel sources, all done in software.
XAudio 2.8 is in the Windows SDK, although you need to use the legacy DirectX SDK for XAudio 2.7 to target Windows 7 or Windows Vista--see this post for details. Samples can be found on GitHub. The DirectX Tool Kit for Audio is very useful abstraction for using XAudio2 from C++.
UPDATE: XAudio 2.9 is now available on Windows 7 SP1 or later via the XAudio2Redist and avoids any need to use the legacy DirectX SDK or legacy DirectSetup deployment.
To get hardware access for features like EAX, you have to use a 3rd party solution like OpenAL. See the Creative site for more.

Related

DirectX and Xbox compatibility

I'm starting game development with DirectX and I was wondering if I somehow play games that I make on Xbox. I know you can use Xbox controller controls, but only on computer (as I know).
Xbox One supports a "Developer mode" which runs UWP applications written for DirectX 11 or DirectX 12. See Microsoft Docs
See this blog post for some additional notes.
To sum up:
For UWP on Xbox One, only x64 native apps are supported
Direct3D 11 with D3D_FEATURE_LEVEL_10_0 is supported
Direct3D 12 with D3D_FEATURE_LEVEL_12_0 is supported in 'game mode' only
Direct3D 9 or earlier is not supported.
For UWP development you do NOT use the legacy DirectX SDK or the deprecated D3DX library.
Game controllers are accessed via Windows.Gaming.Input, and there is an XINPUT emulation library you can use xinput_uap.lib. DirectInput is not supported.
XAudio2 is supported. DirectSound and XACT are not supported.
If you are looking to learn low-level graphics in C++ see DirectX Tool Kit. This library is supported for UWP apps including UWP on Xbox One as well as Win32 desktop apps on Windows 7 or later. The UWP templates at directx-vs-templates work for UWP on Xbox One.
There are a number of UWP samples on GitHub which will run on UWP for Xbox One.
Unity can also be used to target UWP on Xbox One

Why d3dx is deprecated?

I'm very new to DirectX, and learning it only for a week. A collection of powerful lessons I found and learn from is braynzarsoft d3d12 lessons. It's very difficult, there is a lot of information, but this is what I like.
The lessons seems to be unfinished, and I decided to search through the Internet on how to make a sphere, maybe there is ready vertices matrix, or some algorithm that will describe the sphere's vertices. I found this question, where one person says that what I am doing is actually deprecated and now I should program using the DirectX Tool Kit.
I am really confused - I am doing really well, yet all my code works perfectly, and as far as I want.
Can somebody, who has experience in DirectX programming, explain to me why what I am doing is deprecated, what I should do in general, and where I can get sphere vertices?
Currently, I wrote simple vertex and pixel shaders, initialized a d3d12 device, swap chain, command list, described vertices for a quad, and wrote a class that can add, move, rotate and scale cubes, which I do in an Update() call, before UpdatePipeline().
My try
In DirectxTK there is a function D3DXCreateSphere that has LPD3DXMESH *ppMesh and LPD3DXBUFFER *ppAdjacency interfaces as the output arguments. Perhaps, I can get vertex array I need from them. But anyway, I don’t will it be possible to combine DirectxTK code with my.
The short answer is that as part of the development effort for the Windows 8 SDK (circa 2011), the "DirectX SDK" was migrated into the Windows SDK. The DirectX libraries, headers, and tools were moved into the Windows SDK and the "DirectX SDK" was declared deprecated (i.e. the DirectX SDK June 2010 release was the last one ever made).
Microsoft moved samples online for Windows 8, so the majority of the samples in the DirectX SDK were abandoned in favor of Windows Store/UWP samples. As a personal project, I've put a bunch of the Direct3D 11 samples up on GitHub updated so they only use the Windows SDK.
A number of technologies were left behind in this migration as noted on the Microsoft Docs page.
Direct3D 9 development is considered legacy, and the primary reason for still using it was Windows XP support. The Windows 8 SDK doesn't support Windows XP development--Visual Studio 2012-2017 support Windows XP development by using the Windows 7.1A SDK. If you want to target Direct3D 9, you are basically stuck with using the legacy DirectX SDK--although some engines have enough of their own helper code that they don't really need D3DX9.
Direct3D 10 development is considered legacy. Direct3D 11 is a strict super-set of Direct3D 10, is supported by the same versions of Windows, and the Feature Level mechanism means Direct3D 11 works on more hardware than Direct3D 10 ever did. As such, the helper library D3DX10 is deprecated.
The XACT library was not carried forward. It was created primarily for Xbox 360, so it's been deprecated.
Managed DirectX 1.1 has been deprecated for ages (~2005)
See The Zombie DirectX SDK and Where is the DirectX SDK?
As for what you are supposed to use instead, I have created a number of libraries to replace what was in D3DX9/D3DX10/D3DX11. See Living Without D3DX
For DirectX 12 development, the legacy DirectX SDK never supported it. Samples are on GitHub, and otherwise you are supposed to just use the Windows 10 SDK. I have a version of DirectX Tool Kit for DirectX 12 as well on GitHub. That said, if you are new to DirectX you should really consider starting with DirectX 11.
There is such a thing as D3DX12, but it's not quite the same thing as the older D3DX11 library. D3DX11 had code for loading textures, doing BC compression, etc. and required both a header and a runtime DLL. The only way to ship that DLL with your game was to use the legacy DirectX Setup.
D3DX12 is just a header of some helper functions. There is no DLL and no REDIST. It typically gets copied into a project when you create a DirectX 12 Visual Studio template, and you can download it from GitHub. For more information on D3DX12, see this blog post.
DirectX Tool Kit for DX11 and DX12, DirectXTex, DirectXMesh, DirectXMath, and UVAtlas provide much of what D3DX9, D3DX10, and D3DX11 did but supports both DirectX 11 and DirectX 12. They are all open source, so there's no DLL or REDIST: you just build it yourself from source. They are not "drop-in" replacements, but they provide the same functionality in a more Modern C++ form. They support any C++ program written for classic "Win32" development, Universal Windows Platform (UWP) apps, or Xbox One.
Really this is the primary topic I've been covering in my blog for the past decade. Lots of details there if you want more information on what's been happening.
UPDATE: While using the open source replacements for D3DX9/D3DX10/D3DX11 are still recommended, and easy to adopt for Direct3D 11 or Direct3D 12, there are of course lots of existing tutorials and codebases that use D3DX. To support these scenarios without the messy quirks of trying to use the legacy DirectX SDK with modern Windows SDKs, you can make use of the Microsoft.DXSDK.D3DX NuGet package. Using this package, I was able to republish all of the Direct3D 9 and Direct3D 10 legacy DirectX SDK samples to GitHub.

OpenGL version is few years older than laptop

When I write a java program using LWJGL, and get the OpenGL version using glGetString(GL_VERSION);. Then it displays: 2.1.0 - Build 8.15.10.1892
When I open my windows console (using the famous 'cmd' run), and I use systeminfo, it gives me not just any information about the installation date of windows.
I want to get the installation date of windows because then I know how old my laptop is. After searching the internet, I used WMIC OS GET installdate and I finally got a date: 11 November 2010.
And I assume that's true because I can remember at least the same year. And of course the device may have been some time at the factory or in the store.
When I lookup how old OpenGL 2.1.0 is, I see it's of around 2006 https://www.opengl.org/wiki/History_of_OpenGL#OpenGL_2.1_.282006.29
I'm disappointed of my OpenGL version.
I'm running 64 bit Windows 7. The device is probably at least from the end of 2010, but java displays an OpenGL version of 2006.
There are newer OpenGL versions from widely before November 2010, like version 3.0 (2008), 3.1 (2009) and 3.2 (also 2009)
Could it perhaps be that the JVM only has access to an older version of OpenGL?
Some time ago I played a CD-rom game on this laptop. I think that game would never be playable if it used OpenGL 2.1.0...
Or is this an unfair comparision?
OpenGL by itself is just a specification. The actual thing running on your computer is called an implementation which are usually part of the graphics driver. Also each OpenGL specification has very specific requirements on the implementation. And there are many things in OpenGL-3.x that simply are not supported even by hardware that were "modern" in 2010. For example Intel GPUs from around that time simply don't have everything that's required for OpenGL-3 support. Hence you'll get only OpenGL-2.x support for those and nothing more.
You could look up your laptop specification and see your gfx hardware. This will tell you which version of OpenGL your hardware supports (this information will be available from the gfx chip vendor most likely).
Using an API that supports the version of GL that you hardware does is another issue and may be with the way you have initialized or used the openGL graphics lib.
I would have thought most drivers these days support older versions. They may not support the API natively, but I would have thought provide wrappers for the functionality in the driver. Certainly I can code in OpenGL 1.1 and see the results on the same machine as an OpenGL 4.5 program (On a quadro K2200M).

directx 9 with visual studio 2012 express

I decided to learn directx on my old laptop that has an ATI Radeon X1200 card.
Using the program GPU-Z.0.7.2 I found that my card support directx 9 /SM2.0 and has shadrers of 4 Pixel / 2 Vertex.
Using dxdiag on my windows 7 I found that directx version is directx 11. Then I downloaded visual studio 2012 express but I did not install it yet.
Since my card supports only directx 9 im going to read the book Introduction to 3D Game Programming with DirectX 9.
Now what version of the direct SDK do I have to download ? and after downloading the SDK what should I install first the SDK or visual studio 2012 express ? Is the book ok ? I mean there are other editions of the book but they supprt directx 9c , directx 10 and directx 11.
Thank u so much.
Using dxdiag on my windows 7 I found that directx version is directx
11.
This is the DirectX runtime version, not SDK version. so it does not matter which version of SDK you use to develop your program.
As others said, the installation order does not matter.
The book you mentioned is good for new starters. but I recommend you to start from the shader version, since fixed pipeline functionalities such as transforming and lighting was abandoned start from DirectX 10, they all moved to shaders, there is a shader version of that book.
there are lots of materials and resources to learn DirectX, I paste some pages for your reference.
http://www.directxtutorial.com/LessonList.aspx?listid=9
http://www.braynzarsoft.net/index.php?p=DX11Lessons
http://www.rastertek.com/tutindex.html
DirectX SDK examples are also very good choice.
You should be able to use Direct3D 11 whilst still targeting a Direct3D 9 device via the D3D_FEATURE_LEVEL enum, which you can specify in your D3D11CreateDeviceAndSwapChain.
The Microsoft DirectX SDK (June 2010) contains both DirectX 11 and DirectX 9 headers and documentation. The install order doesn't really matter (I've used the SDK in Code::Blocks before installing Visual Studio and it worked fine) since it's really just a collection of header files and debug dlls, plus a bunch of stuff to get you started.
Personally I don't use books when learning a library - I look at the documentation, which is a firsthand explanation of the material, or search up a tutorial (though you should take anything you read in a tutorial with a grain of salt). There are also several websites and videos that explain the graphics pipeline really well. I can't really comment on the book otherwise.
If you not targeting Windows XP or earlier OS, throw DirectX 9 book, forget it (same with DirectX 10 if you not targeting Vista without Service packs), and take DirectX 11 one
Luna's books are great, but, IMO, online tutorials that zdd mentioned are better. And free. But still, to write something cool, you will need to read much more than one book or one series of tutorials. Take the best parts and mix it!
You can develop with DirectX 11 API (for Windows Vista SP2 and later OSes), but still targeting DirectX 9 hardware (feature level 9.3). Shaders is a must. Love them!
When you installing Visual Studio 2012 or higher, you also get a copy of Windows SDK. Do not install standalone DirectX SDK, because it is obsolete. Since Windows 8, DirectX SDK is a part of Windows SDK. Install standalone DirectX SDK only if you really-really need that old stuff, such as D3D11X or effects framework (for Luna books).
Happy coding!

What is the native way to communicate with a standard USB PTP/MTP camera on Windows?

I'm looking at WinUsb, and I have a feeling it's not what I need. Could you please point me in the right direction?
I just need to detect device and send/receive raw data. I used to use libusb, but some of it's characteristic force me to switch to a native API. The only problem is I don't know it's name.
It sounds like you're looking for WPD (Windows Portable Devices). This API is included in the Windows SDK and supports MTP communication with a variety of devices. The WPD team have a very useful blog, which contains instructions on how to get started with development.
Edit:
If you want raw USB access then WPD has a driver kit available:
Windows Portable Devices Driver Kit
The WPD Driver Kit includes a
Device Driver Interface (DDI) that is supported in Windows 7, Windows
Vista, and Windows XP operating Systems. Developers will use this DDI
to write drivers for devices that are not already supported by the MTP
or Mass Storage class drivers that Microsoft distributes.
I've got some answers here:
https://sourceforge.net/mailarchive/forum.php?thread_name=HKEDKEEGPPEOHLHHEPEDKEOADBAA.michael.plante%40gmail.com&forum_name=libusb-win32-devel
In a few words - WPD for Windows Vista/7 and ReadFile/WriteFile for XP.