BCB Components rotating around DirectX

Welcome to BCB-Tools.com Latest News

Development Tools Demo Applications Step-By-Step Tutorials Component Reference

Register Here Available Downloads

Frequently Asked Questions Links to other sites Information about the BCB-Tools.com website


    TUTORIAL - THE MAGIC OF DIRECTX
    Go to the Welcome Page
        ABOUT DIRECTX

    Read some step-by-step TDx_Library Tutorials...

    Author: Darren John Dwyer






    INTRODUCING DIRECTX
    Top     Next

    -= View information about the TDx_Library =-

    DirectX is a set of low-level device drivers for Windows 95,98,ME,CE,NT,2000,XP,Vista,7,8,10.
    More importantly, DirectX is also a low-level Software Development Kit (SDK) for Windows Operating Systems,
    used for developing applications that work on all these various Windows Operating Systems.

    ...

    DirectX is usually used in games programming, but can be used to 'spruce up' or to add 'zing' to other,
    more traditional applications. Read "Boring applications"...

    ...

    Normally, when you install Windows, or when you install a program that requires DirectX,
    you automatically install the relevant DirectX device drivers for the program to use.

    ...

    DirectX is what powers the underlying engine of Windows, and the SDK allows computer programmers
    to write applications that use all the advanced features available in modern hardware used by the
    Windows operating system, such as sound effects, music, accelerated-2D graphics, bit-blitting features,
    advanced input devices such as force-feedback joysticks and steering wheels, advanced multiplayer networking,
    accelerated 3D graphics, and so on...

    ...

    At a hardware device driver level, DirectX talks to the hardware devices in your computer system, and reports
    that functionality back to the DirectX part of the Windows operating system, then smart DirectX compatible
    computer programs use the features available in the hardware to add all sorts of advanced features to their software.

    In DirectX terminology, this is called the HAL (Hardware Abstraction Layer), and it makes all devices appear
    to the DirectX computer programmer to be all relatively similar, just with different levels of hardware features.

    From a programming level, if a device does not contain support for a particular function, DirectX will attempt
    to emulate the hardware functions using software device drivers, a little slower, but still handy for programmers
    who do not want to program for all hardware devices.

    In DirectX terminology, this is called the HEL (Hardware Emulation Layer), and if a hardware feature is not
    available, DirectX will attempt to supply it to DirectX programs anyway.

    ...

    DirectX comes in many different flavours, as Microsoft have progressively updated it over the years
    and the two most popular variants are DirectX 7 (the best version) and DirectX 9.0c, the latest version.

    DirectX 7 is relatively easy to learn, and is suitable for anyone who wants to add DirectX support
    to their Windows applications, while DirectX 9.0c is suitable mostly for advanced 3D programmers.

    ...

    For the purposes of explaining the DirectX SDK, let's focus on the DirectX 7 SDK (the easiest to learn)...

    The DirectX SDK comes in one large package, but is broken up into 5 major sections that make it easier to learn :-
    • DirectDraw - for programming advanced 2D graphics and animation
    • DirectSound - for programming advanced sound effects and music
    • DirectInput - for programming advanced input devices
    • DirectPlay - for programming advanced multiplayer networking features
    • Direct3D - for programming advanced 3D graphics and animation

    ...

    Programming something as advanced as DirectX is not easy, but thats why the TDx_Library exists,
    to make it easy as using Borland C++ Builder.





    DIRECTDRAW - 2D GRAPHICS / ANIMATION
    Top     Next     Prev

    -= View information about the TDx_Draw_Library =-

    DirectDraw is pretty straightforward.

    Basically, if you want to animate anything on the screen, and it does not require 3d graphics,
    you use DirectDraw.

    If you want thousands of images animating all over all available screens, all at once, with various
    color effects, various bit-blitting effects, gamma ramps, etc. then you use DirectDraw.

    ...

    DirectDraw is mostly made up of DirectDrawDevices, and DirectDrawSurfaces.

    Using DirectDraw, you create an interface for each available graphics device you want to program for,
    then you create surfaces used to display images on each device.

    You need to display and image, you tell DirectDraw to Bit-Blit or Page-Flip, and you are programming graphics.
    Easy as.

    ...

    During bit-blitting of an image, you can apply different effects to the image, allowing for many
    complex displays using very little programming source code.

    For example, if you want to display an image upside-down, you just tell DirectX to render it upside-down
    during the same time it would normally take for DirectX to display the image.

    If hardware support is available for drawing an image upside-down, DirectX will automatically use the
    hardware bit-blitting capabilities, otherwise DirectX will just use software to draw the image upside-down.

    Similarly, if you want to display an image, but only display pixels that are not black, you can do this too.
    Just as easy.

    ...

    The magic of DirectDraw is being able to display thousands of images in realtime, on all monitors, all at once.
    When you get used to programming DirectDraw, the effect is incredible...

    ...

    There is more to DirectDraw than immediately comes to mind...

    For example, DirectDraw allows you to scan the display device to find out which display modes it is capable
    of using, then you can setup whichever display mode you prefer, being it 640x480x8 to 1024x768x32 to whatever...

    Also, DirectDraw is capable of streaming data from Video Ports, such as USB cameras, although Microsoft
    forgot to tell anyone how to use any of this functionality... the DirectX 7 SDK comes complete with SDK support
    for DirectDrawVideoPorts but does not come with any example source code to tell you how to use it all...

    Over time, given more hardware, i'll attempt to figure out video port programming, so then we all have something
    to work with...

    ...







    DIRECTSOUND - SOUND EFFECTS / MUSIC
    Top     Next     Prev

    -= View information about the TDx_Sound_Library =-

    DirectSound is the easiest of all DirectX to use.

    It covers playing all kinds of sound effects, music, sound recording, 3d sounds, and so on.

    ...

    Basically, you've got sound devices, and sound buffers.

    You create an interface to a particular sound device, and create a sound buffer to store the music or sound fx data,
    then when you want to hear the sound come out of your chosen device, you just tell DirectSound to play the sound effect.

    All realtime mixing is done for you by DirectSound.
    You can say "Play this sound", "Play that sound", "Play another sound", and DirectSound will handle it all for you,
    and your sound fx will all play simultaneously.

    All you have to do is create your interface to your chosen device, set it up for playback, then play your sound effect.
    Easy As.

    ...

    Playing music is harder, because you have to deal with DirectSoundBuffer notifications, and buffering of your
    stream of music from an input device, such as a file, or from a microphone.

    But it can be done, as shown in the examples for the TDx_Sound_Library.

    ...

    The magic of DirectSound is being able to play hundreds of sound effects in realtime, on all sound devices, all at once.
    When you get used to programming DirectSound, the effect is incredible, especially for sprucing up "boring" programs with sounds.

    ...

    DirectSound is also used for recording sounds from sound input devices, such as microphones, headsets,
    and so on... You can record at pretty well any frequency (same as for playback) and, because of the inbuilt
    streaming functions of the TDx_Sound_Library, you can easily record sounds of a length limited only by your
    storage hardware... for example, you can record an entire album as a .wav if you have a big enough hard-drive...

    ...

    Last but not least, DirectSound also has 3D sound functionality, but as yet, i have not tried this out
    and cannot comment, other than the fact that you can make sounds appear as if they have come from above your
    head, to the left, to the right, behind your head, and so on, and you can make them move from the back of
    your head to the front of your head to simulate a car going past or similar...







    DIRECTINPUT - ADVANCED INPUT DEVICES
    Top     Next     Prev

    -= View information about the TDx_Input_Library =-

    DirectInput is interesting.

    ...

    Using DirectInput, you can talk to all kinds of advanced input devices, such as a 5-button mouse,
    or a steering wheel, or an aircraft control yoke, or a force-feedback joystick, or whatever advanced
    input devices you can imagine.

    You can figure out which buttons are pressed / released; for force-feedback devices, you can assign
    various types of force-feedback effects to a particular button or joystick axis.

    You get direct access to the mouse and keyboard, with either of two access modes, a polling mode
    where you periodically check the status of the mouse position and buttons usually based on a set timer
    interval, and an event-driven mode, whereby the application is called when the status of the mouse or
    keyboard or other input device changes.

    ...

    Using DirectInput, you bypass the normal Windows operating system and access the input devices
    directly, allowing you to do things like check which of all keys are pressed on the keyboard, instead
    of just getting one keypress at a time.

    Or figuring out which mouse buttons are currently depressed.
    Or handling a joystick, at all.

    ...

    The magic of DirectInput is that you can write code for all sorts of input devices, so you can
    use all the buttons available on a particular device, or you can setup force-feedback effects, such
    as a "shake, rattle and roll" or a 'twitch' of the joystick in a particular direction, and you
    can do it all at once.






    DIRECTPLAY - MULTIPLAYER NETWORKING
    Top     Next     Prev

    -= View information about the TDx_Play_Library =-

    I like DirectPlay, even though it's a bit confusing at first, it's too easy, compared to traditional networking.

    ...

    DirectPlay allows you to add multiplayer networking to your applications, all while
    making the actual networking protocols transparent to the end-user.

    For example, you can setup a "Connection" on a LAN or over the Internet, or a Direct-Cable-Connection,
    then send messages between different "Players", individually, or all at once if they are arranged in "Groups".

    This is as easy as saying SendMessage(Player1,"This is a message") or SendMessage(Group1,"To all players")...

    No having to worry about your packets arriving at their destination, no re-assembling packets,
    no having to worry about setting up ports...

    DirectPlay makes networking easy.
    Unfortunately, like most of DirectX, it's relatively complicated... see below...

    ...

    The TDx_Play_Library makes it all just so much easier...

    ...

    The magic of DirectPlay is not having to worry about any of the networking protocols / handshaking / anything like that.
    With DirectPlay, you just setup your network connections, setup your players and groups, then send and recieve messages...

    ...

    DirectPlay also comes with this magical beast called the DirectPlayLobby.

    This thing, the DirectPlayLobby, is what you use to create servers for multiplayer hosting solutions, it seems.
    It can do things like determine what DirectPlay compatible applications are installed on the pc, automatically
    launch said applications, and so on...

    Unfortunately, the DirectX 7 SDK does not come with many examples of how to use DirectPlayLobby's...
    As we understand more, we'll let you know...







    DIRECT3D - 3D GRAPHICS / ANIMATION
    Top     Next     Prev

    -= View information about the TDx_3DI_Library =-

    Direct3D is an incredible beast.

    You setup a 3d world, then setup a camera, then setup your world data, then you tell Direct3D to render it,
    and it happens in realtime, mixing with the speed of DirectDraw to draw 3d graphics on any monitor.

    ...

    We are currently working on more of DirectX 7's Direct3D...
    We are also working on DirectX 9's Direct3D...

    Meantime, the TDx_3DI_Library covers Direct3D Immediate Mode, which is huge to say the least,
    and you almost need a degree in 3D graphics programming to use it, but it covers pretty well anything
    in the realm of 3D graphics programming, and it can be used to completely write a 3D computer game, or similar.

    As I learn more, I'll add more to this section.






    ABOUT PROGRAMMING WITH DIRECTX
    Top     Next     Prev

    Normally, programming DirectX applications is hard work.

    It's complex, it requires you to have advanced knowledge of Win32 programming, and it's best suited
    for Visual C++.

    It's not at all suited to a Rapid Application Development environment such as Borland C++ Builder.

    ...

    Borland C++ Builder has no real support for DirectX either.

    While with BCB is "technically" possible to develop DirectX applications, it is both
    a pain and almost impossible todo, since the DirectX SDK itself does not normally compile with BCB.

    Thats why we developed the TDx_Library, to supply Borland C++ Builder users with a decent RAD interface
    to all of DirectX, without sacrificing any of the advanced functionality of DirectX or Borland C++ Builder,
    taking all the pain out of programming DirectX applications using Borland C++ Builder.

    ...

    To fully comprehend the difficulty of programming DirectX applications, you first need to understand
    many of the complex things required for DirectX programming, such as COM interfaces, Win32 Event Queues,
    Callbacks, and so on.

    To get DirectX 7 to work in Borland C++ Builder, you also need to know all about multi-threading,
    how to integrate it all into the Borland C++ Builder Visual Component Library, how to patch the DirectX 7.0a SDK
    so it actually works in Borland C++ Builder, etc.

    ...

    The TDx_Library is designed to allow you to easily program DirectX applications using all the Rapid Application
    Development benefits of Borland C++ Builder, while all the hard-work of getting DirectX to actually work in
    Borland C++ Builder has been made transparent to the end-user of the TDx_Library.

    For example, the TDx_Library is multi-threaded, automatically monitoring the Win32 event queue for you,
    translating DirectX notification events to easy-to-use Borland C++ Builder OnNotification() Events, much
    simpler than having to write a multi-threaded application yourself, with all the inherent locking and debugging
    problems.

    Another example, the TDx_Library automatically handles DirectX callback functions, something rather painful
    todo in Borland C++ Builder, but once again, we've translated them to be easy-to-use BCB OnCallback() Events.

    ...

    Finally, Microsoft uses a programming standard in all their SDK's called "hungarian notation", which makes
    unfriendly variable types and names like LPDIRECTSOUNDBUFFER lpdsBuf4; when in Borland C++ Builder, it's
    a much friendlier TDx_SoundBuffer* SoundBuffer4;








    ABOUT PROGRAMMING WITH THE TDX_LIBRARY
    Top     Next     Prev

    In comparison to programming DirectX normally, programming DirectX applications using
    the TDx_Library is very easy indeed...

    Remember, RAD DirectX... _Rapid_ Application Development... Easy-As...

    ...

    For one thing, you have everything at your fingertips. Press F1 anywhere, a simple once-only keypress,
    and up pops relevant, detailed, translated into english, help, all customized for Borland C++ Builder
    and it's Visual Component Library SDK standard.

    ...

    Besides that, all the hard stuff, like playing around creating and destroying interfaces and error checking
    is done for you, and it's all transparent to you... you never have to worry about anything, you just use
    the TDx_Library as if it's just another fully integrated part of Borland C++ Builder...

    No Callbacks, no Win32 event queue management, no multithreading synchronization between DirectX and the
    Borland C++ Builder VCL... the whole lot is done for you automagically.

    ...

    All you have to do is one line of code to create an interface to any particular DirectX COM standard,
    and 'viola', DirectX is ready to go.

    ...

    Then, you add in all the benefits of the Borland C++ Builder Rapid Application Development environment,
    such as the Object Inspector and Events and so on...

    Then, because you can mix-and-match the TDx_Library with the standard controls of the Borland C++ Builder
    VCL component library, it's almost becomes too easy...

    ...

    Usually, using the TDx_Library, within an hour you have a working prototype.
    Within a couple of days you have most of the application framework done.
    Then it's just polishing everything and application release.

    There's nothing like Rapid Application Development in general,
    and there's nothing quite like the TDx_Library - Rapid Application Development DirectX.

    ...

    This is a big plug, but RAD DirectX rules.

    Compared to programming DirectX normally, the TDx_Library will save you 80% of the time, and 90% of the effort
    of programming your DirectX compatible applications.







    MORE INFORMATION
    Top     Prev

    For more information, choose from the following links :-




























Top

Welcome |  Latest News |  Tools |  Demos |  Tutorials |  Reference |  Register |  Downloads
FAQ |  Links |  Site Information

This page is Copyright © 2000-2008 Darren John Dwyer, Australia. All Rights Reserved.
Borland C++ Builder, CBuilder, etc are Trademarks of Borland Corporation.
DirectX, DirectDraw, Windows, etc are Trademarks of Microsoft Corporation.