Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Call for (more) FAQ submissions

This topic is 5147 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I think it''s time I updated the Forum FAQ again with some new stuff. In particular, I want things for the non-Direct3D sections; at the moment, DSound, DMusic, DPlay, and DShow all just say "There are no questions in this section yet," and DDraw/DInput aren''t much better. So, any suggestions - either for questions, or for questions+answers? At the very least I''m going to try and add a ''What is Direct[thing]?'' question to each section. But a little more than that would be nice; they don''t even have to be questions you see being asked here very much, they just have to be fairly common problems or pitfalls that you think people might find useful to know about. Anyone who''s particularly helpful, well... no promises, but I''ll see if I can talk to Dave about a custom "DirectX Guru" title
Richard "Superpig" Fine
Smoother than a greased baby [TBRF|GP&T|Enginuity1|Enginuity2|Enginuity3|Enginuity4|Enginuity5|TB]

Share this post


Link to post
Share on other sites
Advertisement
Here''s the definitions for the components that I plan to put up, if you''d like to check that they''re correct or make amendments before I do so...

quote:
What is Direct3D?
Direct3D is a library of objects for working with the graphics hardware. As the name suggests, it''s primarily geared towards 3D graphics, though 2D graphics are perfectly possible as well.


quote:
What is Direct3DX?
Direct3DX (or D3DX for short) is a library of helper functions and objects designed to make 3D programming easier. There''s a fair amount of math stuff there, along with objects for meshes, texturing, animation, and certain complex techniques like Precomputed Radiance Transfer.


quote:
What is DirectDraw?
DirectDraw is a library of objects for working with 2D graphics and video ''surfaces.'' It lets you access frame buffers directly, working pixel-by-pixel if you want. It doesn''t include any 3D functionality, and was merged into Direct3D in DirectX 8.0.


quote:
What is DirectInput?
DirectInput is a library of objects for collecting input from the user - via the mouse, keyboard, joysticks, gamepads... pretty much any ''game controller'' you can think of. It also provides a system for ''action mapping,'' which allows you to connect up buttons and axis on the controllers to actions within your game very easily.


quote:
What is DirectSound?
DirectSound is a library of objects for recording and playing sounds with very low latency, and for allowing your game a high level of control over the sound pipeline. It also includes a system for 3D sounds (playing the sound in such a way that it seems to come from a specific direction) and a system for applying effects to sounds (like ''echo'' and ''gargle'').


quote:
What is DirectMusic?
DirectMusic is a high-level set of objects, built on top of DirectSound, that allow you to play sound and music without needing to get quite as low-level as DirectSound. There''s also strong support for ''dynamic soundtracks'' - having music which changes in response to events in the game.


quote:
What is DirectPlay?
DirectPlay is a library of objects for networked games. It provides systems for transferring data between games, as well as objects for locating games on a network, and ''lobbying'' (having players meet up in a chat-room style environment and then automatically launch your game from within it).

Share this post


Link to post
Share on other sites
Looks like you are missing DirectSetup API section. FAQ should at least cover case:

Q: "How can I detect DirectX version number?"
A: "Use DirectSetup API's function DirectXSetupGetVersion() to get get DirectX's version number. There is an example in SDK and sample program with custom function, that determines current version. Full sources are included on SDK_DIR/Samples/C++/Misc/GetDXVer"


[edited by - Cell- on April 16, 2004 4:30:40 PM]

Share this post


Link to post
Share on other sites
hmmm.

some questions/answers for DirectInput:

What headers/libraries do i need for directinput?
#include <dinput.h> and link with dinput8.lib AND dxguid.lib (this library has the GUID''s for the keyboard/mouse).

how do i setup directinput?
just every other directx component, call DirectInput8Create() on an IDirectInput8 interface. once you have a pointer to the directinput interface, call the CreateDevice method to get a pointer to the device (IDirectInputDevice8). Then call the IDirectInputDevice8->SetDataFormat() to set the data format of the device you created. Then call IDirectInputDevice8->SetCooperativeLevel() to set the cooperative level. then call IDirectInputDevice8->Acquire() to acquire the device and get it ready for updating.

how do i setup a keyboard?
pass in GUID_SysKeyboard to CreateDevice() and c_dfDIKeyboard to SetDataFormat().

how do i setup a mouse?
pass in GUID_SysMouse to CreateDevice() and c_dfDIMouse to SetDataFormat() (there are other mouse data formats you can use - check the SDK for more info.)

how do i read from a keyboard or mouse?
before you can check button presses or mouse movement, you must update the device by calling IDirectInputDevice8->GetDeviceState(). this updates that status of the device. the first parameter is the size of the buffer, the second is the actual buffer to recieve the data. NOTE: the device must be Acquire()''d before calling GetDeviceState, otherwise GetDeviceState will fail.

how do i check key presses on a keyboard?
for a keyboard, the Device State buffer is just a simple array of chars (char keyState[256]) that holds the status for each key. for example, to see if the left arrow key is pressed:
if (keyState[DIK_LEFT] & 0x80)
return true;

how do i check mouse movement or button presses?
for a mouse, the Device State buffer is a DIMOUSESTATE structure. this structure holds an array of chars to represent each of the mouse buttons (check this is just like checking for a keypress) and a few floats (lx, ly, lz) to represent the mouse movment in RELATIVE coordinates. lx and ly represent the mouse axis. lz represents the wheel. this structure will be different depending on what data format you use for the mouse (there are 2 that i know of)

Share this post


Link to post
Share on other sites
- DPlay isn''t just for games. You can use it for whatever network application you like.

- Perhaps you should add some section about debugging DX apps?
It should cover enabling debug output, checking HRESULTs for failure, stringifying them and getting their description (via DXGetErrorString and GetErrorDescription), and perhaps using the Error Lookup tool too?

- Maybe add a section/link to InFramez'' Auto-expanding D3D types in VStudio''s variable/watch windows

- Maybe another section/link to InFramez'' Accessing All Device States Through D3DX .fx Files (DirectX9 .0)

Muhammad Haggag,
Optimize
Bitwise account: MHaggag -

Share this post


Link to post
Share on other sites
OK, thanks so far guys - I've added the 'What is Direct[thing]' questions already, and I'll work on integrating the other things you've put forward.

Once this thing looks settled (i.e. nobody has any further suggestions) I'll try and get in touch with the DirectX development team at Microsoft, and ask if anyone has the time to give it a quick read-through, just to make sure it's all correct. I don't want to have to ask them twice, though, so it needs to be all there

Edit: OK, DSetup stuff added. If there's anything wrong with it, please let me know...

[edited by - Superpig on April 16, 2004 7:43:11 PM]

Share this post


Link to post
Share on other sites
I think that FAQ should mention that one can get DirectX's major version *easily* with LOWORD macro, after all FAQ is mostly directed to beginners.

DirectXSetupGetVersion(&dwVersion,&dwRevision);
dwMajorVersion = LOWORD(dwVersion);
// Now dwMajorVersion equals to 8 for DX 8.x, 9 for DX 9.x ect.

Q: "I want to make sure, that my DirectX installation routines work, but I don't want to test it on my own machine"

A: You can also perform fake/test installating with DirectSetup API by passing DSETUP_TESTINSTALL flag to DirectXSetup function. Function then performs a test installation and doesn't install new components."

I think that will eliminate rest of the DSetup questions...

[edited by - Cell- on April 17, 2004 6:46:20 AM]

Share this post


Link to post
Share on other sites
OK, the DSetup stuff's updated, as is the 'debugging DirectX' section at the beginning.

quote:
Original post by akdjr
how do i read from a keyboard or mouse?
before you can check button presses or mouse movement, you must update the device by calling IDirectInputDevice8->GetDeviceState(). this updates that status of the device. the first parameter is the size of the buffer, the second is the actual buffer to recieve the data. NOTE: the device must be Acquire()'d before calling GetDeviceState, otherwise GetDeviceState will fail.

how do i check key presses on a keyboard?
for a keyboard, the Device State buffer is just a simple array of chars (char keyState[256]) that holds the status for each key. for example, to see if the left arrow key is pressed:
if (keyState[DIK_LEFT] & 0x80)
return true;

how do i check mouse movement or button presses?
for a mouse, the Device State buffer is a DIMOUSESTATE structure. this structure holds an array of chars to represent each of the mouse buttons (check this is just like checking for a keypress) and a few floats (lx, ly, lz) to represent the mouse movment in RELATIVE coordinates. lx and ly represent the mouse axis. lz represents the wheel. this structure will be different depending on what data format you use for the mouse (there are 2 that i know of)


The only issue I have with those is that they're for immediate data only - there's no reference to using buffered data. Maybe I'll rewrite them to include that, though I think these questions are possibly answered well enough in the SDK already.

[edited by - Superpig on April 17, 2004 8:18:47 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!