BBC BASIC for Windows
« DirectX9 tutorials for BB4W »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:29pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1 2 3  Notify Send Topic Print
 veryhotthread  Author  Topic: DirectX9 tutorials for BB4W  (Read 1062 times)
Torro
New Member
Image


member is offline

Avatar




PM


Posts: 25
xx Re: DirectX9 tutorials for BB4W
« Reply #5 on: Jul 24th, 2015, 1:17pm »

What is the situation with using directx9 via the BBClibs?

With directx12 on horizon is that going to be quite different?
User IP Logged

rtr2
Guest
xx Re: DirectX9 tutorials for BB4W
« Reply #6 on: Jul 24th, 2015, 2:59pm »

on Jul 24th, 2015, 1:17pm, Torro wrote:
What is the situation with using directx9 via the BBClibs?

The existing D3DLIB library uses DirectX8 rather than DirectX9. There's a particularly important reason for that, which involves the Direct 3D Extensions 'D3DX'. Microsoft permits the distribution of the relevant DirectX8 DLL with applications (supplied as standard with BB4W as D3DX8BBC.DLL) but they do not allow the distribution of the D3DX9 DLL on its own. This makes it almost impossible to support DirectX9 legally from BB4W without shipping a massive MS installer at the same time.

To date, each new version of DirectX has been backwards-compatible with earlier versions, so DirectX8 code (and therefore programs using D3DLIB) still run fine on the latest versions of Windows. If this situation changes, and DirectX8 support is withdrawn by Microsoft, then something would need to be done to maintain D3DLIB functionality.

Of course you can use DirectX9 from BB4W, so long as you avoid the D3DX extensions library entirely, or rely on it already being installed on the target PC (tricky, because there are many versions), or distribute it 'illegally'. Before Michael Hutton 'jumped ship' to PureBasic he wrote a number of DirectX9 applications, proving that it's possible within those restrictions (see earlier posts in this thread).

So, I don't currently have any plans to update D3DLIB but I would be interested to know if there is a demand for this. I haven't investigated whether DirectX versions later than 9 resolve the DLL issue, or make it even more problematic.

Edit: Checking what files are on my PC - d3dx9_32.dll, d3dx10_42.dll and d3dx11_43.dll - those pesky version numbers strongly suggest that the problem is not eased in DirectX 10 or 11. sad

Richard.
« Last Edit: Jul 24th, 2015, 4:17pm by rtr2 » User IP Logged

Torro
New Member
Image


member is offline

Avatar




PM


Posts: 25
xx Re: DirectX9 tutorials for BB4W
« Reply #7 on: Jul 25th, 2015, 05:50am »

Thanks for that.

After reading this it might not be a big deal

http://www.anandtech.com/show/1549/2

User IP Logged

rtr2
Guest
xx Re: DirectX9 tutorials for BB4W
« Reply #8 on: Jul 25th, 2015, 07:12am »

on Jul 25th, 2015, 05:50am, Torro wrote:
After reading this it might not be a big dea

Arguably, the biggest disadvantage of working with DirectX8 rather than DirectX9 is the lack of documentation (other than that supplied with BB4W). Much of what used to be available online seems to have disappeared (I've not tried searching the web archive).

Unfortunately it appears that Michael Hutton has deleted his BB4W DirectX9 tutorial, and its support files, (referred to earlier in this thread) from the Yahoo group. sad

Richard.
User IP Logged

Torro
New Member
Image


member is offline

Avatar




PM


Posts: 25
xx Re: DirectX9 tutorials for BB4W
« Reply #9 on: Jul 25th, 2015, 10:30am »

They were based on http://www.directxtutorial.com/default.aspx

but crucially it requires your DLL wrappers to support it . Are those Dlls opensource?
User IP Logged

rtr2
Guest
xx Re: DirectX9 tutorials for BB4W
« Reply #10 on: Jul 25th, 2015, 4:14pm »

on Jul 25th, 2015, 10:30am, Torro wrote:
They were based on http://www.directxtutorial.com/default.aspx
but crucially it requires your DLL wrappers to support it

See my announcement in the Libraries section.

Richard.
User IP Logged

rtr2
Guest
xx Re: DirectX9 tutorials for BB4W
« Reply #11 on: Jul 26th, 2015, 9:54pm »

on Jul 25th, 2015, 10:30am, Torro wrote:
They were based on http://www.directxtutorial.com/default.aspx

Those tutorials look quite interesting (particularly the DirectX 9 one) although much of the earlier material - what they describe as Direct3D Basics - is covered in the BB4W documentation or the various example programs.

It's the more advanced stuff - like meshes, sprites and HLSL programming - that could be of particular relevance to us, but unfortunately that's only accessible by paying $50 for 'premium membership'!

Richard.



User IP Logged

rtr2
Guest
xx Re: DirectX9 tutorials for BB4W
« Reply #12 on: Jul 27th, 2015, 5:49pm »

on Jul 25th, 2015, 4:14pm, g4bau wrote:
See my announcement in the Libraries section.

Unlike DirectX 8, for which documentation was hard to find, there are many web sites with tutorials and other information on DirectX 9, and most importantly MSDN itself still covers Direct3D 9 in detail.

Specifically, when using the new BB4W libraries, the value returned from FN_init3d() is a pointer to an IDirect3DDevice9 interface. Would it be helpful for me to produce an appropriate BB4W structure declaration for this interface?

Is anybody going to take the bait and write some 3D code?

Richard.
User IP Logged

dfeugey
Guest
xx Re: DirectX9 tutorials for BB4W
« Reply #13 on: Jul 28th, 2015, 06:02am »

I will. But when, it's another question grin
User IP Logged

rtr2
Guest
xx Re: DirectX9 tutorials for BB4W
« Reply #14 on: Jul 28th, 2015, 08:53am »

on Jul 28th, 2015, 06:02am, dfeugey wrote:
I will. But when, it's another question grin

You didn't answer the question about whether a Direct3DDevice9 structure declaration would be useful. It's not a trivial thing to generate (there are an awful lot of methods to include) so I'd like to know that the effort wouldn't be wasted.

Richard.
User IP Logged

DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: DirectX9 tutorials for BB4W
« Reply #15 on: Jul 28th, 2015, 09:22am »

Hi Richard,

Hmm, maybe. I can't work out exactly what I'm trying to do.

I've had a play in the past with directly writing a vertex buffer, and generating "worlds" and mazes in real time, to move around. As part of that, you provided me with some codes, which includes the magic lines:
Code:
      SYS!(!D%+92),D%,N%*L%,0,V%,0,^B% TO R%:REM CreateVertexBuffer
      IF R% THEN=0
      SYS!(!B%+44),B%,0,N%*L%,^P%,0:REM pVB::Lock
 

This now fails with D3D9LIB, presumably because the offsets have changed, as for the specular reflection example you gave earlier? Changing the 92 to 104, as in the library, means it doesn't crash (but still doesn't render, so there's still something else wrong...). I note that the "magic numbers" for the lock and unlock are the same. I'll have a play with a simpler object sometime.

Do these SYS calls address the methods of the device? Will your proposal to provide a structure declaration allow us to use these methods without knowing the "magic numbers"? If not, where can we find them?

On what I believe to be a similar point (which may make you laugh...), is the issue with things like the teapot demo that you can't use "GetProcAddress" unless you know the precise name of the D3D9 DLL, which may vary between machines? I suspect I'm confusing the functions of the DLL called directly by D3D(9)LIB, and the one referred to as D3DX8BBC.DLL - or are they actually the same?

D
User IP Logged

dfeugey
Guest
xx Re: DirectX9 tutorials for BB4W
« Reply #16 on: Jul 28th, 2015, 09:55am »

on Jul 28th, 2015, 08:53am, g4bau wrote:
You didn't answer the question about whether a Direct3DDevice9 structure declaration would be useful. It's not a trivial thing to generate (there are an awful lot of methods to include) so I'd like to know that the effort wouldn't be wasted.
Richard.


Difficult question. It would be, if I use it. But since it's not yet the case, I would say that's it's not a necessity... for me.
User IP Logged

rtr2
Guest
xx Re: DirectX9 tutorials for BB4W
« Reply #17 on: Jul 28th, 2015, 10:07am »

on Jul 28th, 2015, 09:22am, DDRM wrote:
This now fails with D3D9LIB, presumably because the offsets have changed

As you will appreciate there are two different aspects to adapting code from DirectX 8 to DirectX 9:
  1. Although many of the methods in D3D9 work identically to, and have the same parameters as, their equivalents in D3D8, in almost every case their ordinal values (positions in the vTable) change. So it is necessary to discover the new value and change the offset.

  2. In a few cases the methods do not have an identical interface, for example the number of parameters may have changed (you should not be surprised by this, because after all D3D9 is functionally different from D3D8). In those cases you must check the documentation of the function to find out what the new parameters are.
Quote:
Changing the 92 to 104, as in the library, means it doesn't crash (but still doesn't render, so there's still something else wrong...)

That method (IDirect3DDevice9::CreateVertexBuffer) is one whose parameters have changed, as you might have noticed by comparing the equivalent calls in D3DLIB and D3D9LIB. To be specific, it has acquired an extra, sixth, parameter (which you must set to zero):

https://msdn.microsoft.com/en-us/library/windows/desktop/bb174364.aspx

This is presumably why your code didn't work, since you do not appear to have added that parameter.

Quote:
Will your proposal to provide a structure declaration allow us to use these methods without knowing the "magic numbers"?

That is the whole point. This wiki article (8 years old) gives the details - I rather took it for granted that anybody attempting to call COM methods from BB4W would be familiar with it:

http://bb4w.wikispaces.com/Calling+object+methods+using+structures

Quote:
you can't use "GetProcAddress" unless you know the precise name of the D3D9 DLL, which may vary between machines?
(I'm assuming you mean D3DX9 rather than D3D9 there).

It's not just the name, but whether any D3DX9... DLL is present at all! Windows comes with DirectX pre-installed, so (these days) you can be certain that D3D8.DLL and D3D9.DLL will be available. But the extensions library is not part of the standard installation, and will be present only if you happen to have installed another application which needs it.

A correspondent recently sent me this useful link, which gives both the background and some solutions to the D3DX issue:

http://blogs.msdn.com/b/chuckw/archive/2013/08/21/living-without-d3dx.aspx

Richard.
User IP Logged

DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: DirectX9 tutorials for BB4W
« Reply #18 on: Jul 28th, 2015, 12:44pm »

Ah, some pennies beginning to drop...

You are right, I had missed the extra parameter, and it works now...

I understand the difference between D3D9 and D3DX9...

I realise that the renderer is a COM device with methods, and the relevance of the wiki page. I see that there are lots of methods, and understand why you can't implement only the most useful ones.

I still don't understand why the index for CreateVertex is 104, since it is the 15th method listed (plus 3 inherited), but I can live with that... I guess there's a header or something. More worryingly I see SetRenderState is 80 further down the list, but only 124 bytes later: I'd have expected it to be a multiple of 4, or at least 2... Suggests I have no idea what's going on after all...

I've had some fun playing with the teapot program, making it draw "cylinders" that look like cones (only in d3d8, though)

Summary: your proposed structure would be useful to me, but there probably won't be any useful output for anyone else, since my understanding is obviously limited, and I'd quite understand if you felt one happy punter didn't justify the effort it will take you.

What output were you hoping for when you "laid the bait"?

D
User IP Logged

rtr2
Guest
xx Re: DirectX9 tutorials for BB4W
« Reply #19 on: Jul 28th, 2015, 3:44pm »

on Jul 28th, 2015, 12:44pm, DDRM wrote:
I still don't understand why the index for CreateVertex is 104, since it is the 15th method listed (plus 3 inherited)

You have to be careful which 'list' you use. Sometimes you will find the methods listed in alphabetical order, rather than in 'vTable' order, which is obviously of no use in determining the offset. As that method has an offset of 104 it is definitely ordinal 26 (104/4) not ordinal 18 (or perhaps you meant 17, depending in whether you were counting from 0 or 1) that you state.

Quote:
I guess there's a header or something.

Nope, the ordinals start at zero (QueryInterface).

Quote:
More worryingly I see SetRenderState is 80 further down the list, but only 124 bytes later: I'd have expected it to be a multiple of 4, or at least 2

Well, in fact, 124 is a multiple of 4 (it's 4*31)! Back to school for you....

Quote:
Summary: your proposed structure would be useful to me, but there probably won't be any useful output for anyone else, since my understanding is obviously limited

Defeatist! tongue

Quote:
What output were you hoping for when you "laid the bait"?

Over the years the absence of support for DirectX 9 (or, more accurately, the lack of support for a version of DirectX with readily-available documentation) has been cited as a reason for so little uptake beyond what can be achieved using D3DLIB alone. I suppose I am hoping that with D3D9LIB - and some solutions to the D3DX issue - we may see some more exciting 3D applications.

Richard.
User IP Logged

Pages: 1 2 3  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls