Author |
Topic: DirectX9 tutorials for BB4W (Read 1065 times) |
|
rtr2
Guest
|
 |
Re: DirectX9 tutorials for BB4W
« Reply #10 on: Jul 25th, 2015, 4:14pm » |
|
on Jul 25th, 2015, 10:30am, Torro wrote: See my announcement in the Libraries section.
Richard.
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: DirectX9 tutorials for BB4W
« Reply #11 on: Jul 26th, 2015, 9:54pm » |
|
on Jul 25th, 2015, 10:30am, Torro wrote: 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.
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
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.
|
|
Logged
|
|
|
|
dfeugey
Guest
|
 |
Re: DirectX9 tutorials for BB4W
« Reply #13 on: Jul 28th, 2015, 06:02am » |
|
I will. But when, it's another question
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
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 |
|
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.
|
|
Logged
|
|
|
|
DDRM
Administrator
member is offline


Gender: 
Posts: 321
|
 |
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
|
|
Logged
|
|
|
|
dfeugey
Guest
|
 |
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.
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
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:
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.
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.
|
|
Logged
|
|
|
|
DDRM
Administrator
member is offline


Gender: 
Posts: 321
|
 |
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
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
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! 
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.
|
|
Logged
|
|
|
|
DDRM
Administrator
member is offline


Gender: 
Posts: 321
|
 |
Re: DirectX9 tutorials for BB4W
« Reply #20 on: Jul 28th, 2015, 4:03pm » |
|
Hi Richard,
List: yes, obviously the order is important - but both lists I found on MSDN gave them in alphabetical order, so I assumed that must be the vTable order, since I couldn't find a separate mention of the latter, which probably reflects my lack of familiarity with MSDN... That would explain it if they are different. If they are different, then your header (or at least a pointer to the vTable list) will DEFINITELY be useful!
124/4: OK, sloppily expressed! I meant I expected the gap to be 80 x 4, or maybe 80 x 2, since it was 80 places later in the alphabetical list. Of course, if the list isn't alphabetical, it could easily occur 31 places later... 
[defeatist] Maybe. Realist? 
Exciting 3D applications? Well, at least I enjoy playing with it - and actually, it's not all that hard when I concentrate...
Best wishes,
D
|
|
Logged
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: DirectX9 tutorials for BB4W
« Reply #21 on: Jul 28th, 2015, 7:36pm » |
|
Hullo all,
I haven't read the topic in its entirety but I still get notified to updates to the thread. I will dig out these old files and see if they are of any use. Of note, the helper file contain a mass of structure definitions etc for DirectX9 so code like
Code:
SYS!(!pDevice%+228), pDevice%, 29, 1 : REM Enable specular
can be avoided completely. There is a lot of helpful stuff within the library which makes it a lot simpler to get a program up and running.
Can you give me a bit of time and I will see what I turn up. I will try and test them to see if they work in v6.00. I expect they will *but* will a structure variant now be a different size? I assume so, but I can't even remember if I used any or not. It has been a long time.
Give me a few days and I'll see what I have got left over.
Michael
|
|
Logged
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: DirectX9 tutorials for BB4W
« Reply #22 on: Jul 28th, 2015, 9:10pm » |
|
I've dug around and found this - I'll have to use two separate posts...
Code:
REM *******************************************************************
REM
REM Introduction :
REM
REM *******************************************************************
REM
REM These tutorials are based on http://www.directxtutorial.com/ which
REM is an excellent site to learn about DirectX programming. These are
REM very in depth tutorials and I won't repeat what is said there,
REM rather I will show you the 'minimal' BB4W program which will
REM achieve the same effect as the tutorial. You can then go on to
REM modify them at your hearts desire!
REM
REM We will use DirectX9. Why? Well, DirectX8 is now officially
REM 'unsupported' although DirectX9 and 10 still maintain backward
REM compatibility. There is no BB4W library for DirectX9 and so it will
REM be useful to learn to create the functions we need from the ground
REM up. You will find that a lot of your programs are based around
REM the same shell.
REM
REM DirectX uses COM (Component Object Model), if you are not familiar
REM with COM then a quick read of :
REM
REM http://bb4w.wikispaces.com/Component+Object+Model+programming
REM
REM which will help with the basics. I will not try to explain it here.
REM
REM I have decided to use structures to call the different methods in
REM each interface see :
REM
REM http://bb4w.wikispaces.com/Calling+object+methods+using+structures
REM
REM Although it can seem tedious to type out the structures first time,
REM it does lead to more readable code than the more obfuscating
REM indirection method. This is especially useful when you come back to
REM the code after a long time.
REM
REM For instance reading :
REM
REM SYS IDirect3DDevice9.BeginScene%, IDirect3DDevice9%
REM
REM is a lot easier to reference than
REM
REM SYS !(!D%+164), D%
REM
REM There are some caveats to using structures. The first is that the
REM original memory allocated for the structure is wasted but this is
REM not really a big problem. Second, we have to use a tricky line of
REM code to redirect the structure to point to the interfaces despatch
REM table (we *must* remember to do this!) and third we could argue
REM that they are slightly slower to call than using indirection. All
REM in all, I think it is worthwhile doing for the readability of the
REM code.
REM
REM The only other thing to mention is the FNf() function. DirectX uses
REM 4 byte floating point values rather than BB4W's 5 or 8 byte float
REM (*FLOAT 40 and *FLOAT 64 respectively). Whenever you see a value
REM such as 1.0f or 0.5f mentioned in the tutorials we need to use
REM FNf(1.0) or FNf(0.5) instead, otherwise we will get some very funny
REM results. See :
REM
REM http://bb4w.wikispaces.com/Passing+floating-point+values+to+DLLs
REM
REM For further information.
REM *******************************************************************
REM
REM Programming DirectX9
REM Lesson 1
REM
REM *******************************************************************
REM Remember, this lesson shows you a lot of code which will later
REM be moved into a library. You could skip to lesson three which
REM shows you exactly the same program but with all the reusable
REM code put in a library.
REM Well, we should choose a screen mode.
REM MODE 8 is a good start. 640 x 512 pixels.
REM we'll also turn the cursor off.
REM Notice initialisation of the window is done for you by BB4W!
MODE 8
OFF
REM We should always make sure that we have a cleanup procedure.
REM This enables us to free up all the resources we create with DirectX
REM Remember, any object 'created' by you will stay there until you
REM free it. To prevent all your memory eventually being used up you
REM must free it.
ON ERROR PROC_Error : PROC_Cleanup : END
ON CLOSE PROC_Cleanup : QUIT
REM First we need to load in the D3D9.DLL. This 'Dynamic Linked
REM Library' contains all the goods to use DirectX. If you haven't,
REM install the latest DirectX SDK it would be a good reference
REM Otherwise, make sure you have DirectX9 installed.
SYS "LoadLibrary", "D3D9.DLL" TO D3D9DLL%
REM It is good practice to check the result of any Windows API call we
REM make just in case things rely on them later, but we won't always
REM do this.
IF D3D9DLL% = FALSE THEN
m$ = "Failed to load D3D9.DLL. " +CHR$13
m$+= "Please ensure you have DirectX9 installed."
ERROR 100, m$
ENDIF
REM The first function we need is 'Direct3DCreate9' so we will query
REM our dll loaded into memory and get its address.
SYS"GetProcAddress", D3D9DLL%, "Direct3DCreate9" TO Direct3DCreate9%
REM Again, check to see if we have found the address
IF Direct3DCreate9% = FALSE THEN
ERROR 100, "Could not locate Direct3DCreate9 function."
ENDIF
REM Now we will 'create' the DirectX9 'device'. This is an 'object'
REM which contains 'interfaces' and/or 'methods'. We can call these
REM methods to control DirectX.
REM
REM At first we will define constants etc as we need them, but later
REM we can move all definitions to a separate initialisation routine,
REM and later still, to a separate library.
REM First get the Direct3D9 interface pointer :
D3D_SDK_VERSION = 32 : REM DirectX 9c
SYS Direct3DCreate9%, D3D_SDK_VERSION TO IDirect3D9%
IF IDirect3D9% = FALSE THEN
ERROR 100, "Failed to Create Direct3D9 interface."
ENDIF
REM Now we need to define our first interface. We do this by defining
REM the following structure and then redirecting it to point to the
REM interface's methods.
DIM IDirect3D9{ \
\QueryInterface%, \
\AddRef%, \
\Release%, \
\RegisterSoftwareDevice%, \
\GetAdapterCount%, \
\GetAdapterIdentifier%, \
\GetAdapterModeCount%, \
\EnumAdapterModes%, \
\GetAdapterDisplayMode%, \
\CheckDeviceType%, \
\CheckDeviceFormat%, \
\CheckDeviceMultiSampleType%, \
\CheckDepthStencilMatch%, \
\CheckDeviceFormatConversion%, \
\GetDeviceCaps%, \
\GetAdapterMonitor%, \
\CreateDevice% }
REM We have created the structure, but unfortunately if we were to call
REM any of the methods with it we would fail dramatically. With the
REM next line we redirect our structure to point to the IDirect3D9
REM despatch table.
!(^IDirect3D9{}+4) = !IDirect3D9%
REM Sorry about that, but it is essential we do this if we want to use
REM structure members as methods/functions!
REM Next we define the PRESENT_PARAMETERS{} which we need to 'create
REM the device' and set some of its members.
DIM D3DPRESENT_PARAMETERS{ \
\BackBufferWidth%, \
\BackBufferHeight%, \
\BackBufferFormat%, \
\BackBufferCount%, \
\MultiSampleType%, \
\MultiSampleQuality%, \
\SwapEffect%, \
\hDeviceWindow%, \
\Windowed%, \
\EnableAutoDepthStencil%, \
\AutoDepthStencilFormat%, \
\Flags%, \
\FullScreen_RefreshRateInHz%, \
\PresentationInterval% }
REM Define some constants
REM Take note this is NOT BB4W's TRUE which is -1!
_TRUE = 1
D3DSWAPEFFECT_DISCARD = 1
REM Set some D3DPRESENT_PARAMETERS{} members
D3DPRESENT_PARAMETERS.Windowed% = _TRUE
D3DPRESENT_PARAMETERS.SwapEffect% = D3DSWAPEFFECT_DISCARD
D3DPRESENT_PARAMETERS.hDeviceWindow% = @hwnd%
REM And now we Create the Device
D3DADAPTER_DEFAULT = 0
D3DDEVTYPE_HAL = 1
D3DCREATE_SOFTWARE_VERTEXPROCESSING = &20
SYS IDirect3D9.CreateDevice%, IDirect3D9%, D3DADAPTER_DEFAULT, \
\ D3DDEVTYPE_HAL, @hwnd%, D3DCREATE_SOFTWARE_VERTEXPROCESSING, \
\ D3DPRESENT_PARAMETERS{}, ^IDirect3DDevice9% TO R%
IF R%<>0 OR IDirect3DDevice9% = FALSE THEN
ERROR 100, "Failed to Create IDirect3DDevice9."
ENDIF
REM Notice the ^ (address of) symbol with ^IDirect3DDevice9%. We will
REM come across this a lot when we want to receive a value back from
REM the SYS call which is not returned in the result.
REM A note of the SYS call format:
REM You may have noticed the slightly different SYS call format when
REM calling an method via an object's interface compared to a simple
REM Windows API function. You must put the interface pointer as the
REM second parameter ie after calling the method :
REM
REM SYS IDirect3D9.CreateDevice%
REM
REM We add the interface pointer
REM
REM SYS IDirect3D9.CreateDevice%, IDirect3D9%
REM
|
|
Logged
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: DirectX9 tutorials for BB4W
« Reply #23 on: Jul 28th, 2015, 9:11pm » |
|
Add this to the first bit...
Code:
REM and then the parameters we are passing. See the call we made above.
REM In fact this Device is an Interface, and so if we want we can
REM define another structure and redirect it to this Interface's
REM despatch table.
DIM IDirect3DDevice9{ \
\QueryInterface%, \
\AddRef%, \
\Release%, \
\TestCooperativeLevel%, \
\GetAvailableTextureMem%, \
\EvictManagedResources%, \
\GetDirect3D%, \
\GetDeviceCaps%, \
\GetDisplayMode%, \
\GetCreationParameters%, \
\SetCursorProperties%, \
\SetCursorPosition%, \
\ShowCursor%, \
\CreateAdditionalSwapChain%, \
\GetSwapChain%, \
\GetNumberOfSwapChains%, \
\Reset%, \
\Present%, \
\GetBackBuffer%, \
\GetRasterStatus%, \
\SetDialogBoxMode%, \
\SetGammaRamp%, \
\GetGammaRamp%, \
\CreateTexture%, \
\CreateVolumeTexture%, \
\CreateCubeTexture%, \
\CreateVertexBuffer%, \
\CreateIndexBuffer%, \
\CreateRenderTarget%, \
\CreateDepthStencilSurface%, \
\UpdateSurface%, \
\UpdateTexture%, \
\GetRenderTargetData%, \
\GetFrontBufferData%, \
\StretchRect%, \
\ColorFill%, \
\CreateOffscreenPlainSurface%, \
\SetRenderTarget%, \
\GetRenderTarget%, \
\SetDepthStencilSurface%, \
\GetDepthStencilSurface%, \
\BeginScene%, \
\EndScene%, \
\Clear%, \
\SetTransform%, \
\GetTransform%, \
\MultiplyTransform%, \
\SetViewport%, \
\GetViewport%, \
\SetMaterial%, \
\GetMaterial%, \
\SetLight%, \
\GetLight%, \
\LightEnable%, \
\GetLightEnable%, \
\SetClipPlane%, \
\GetClipPlane%, \
\SetRenderState%, \
\GetRenderState%, \
\CreateStateBlock%, \
\BeginStateBlock%, \
\EndStateBlock%, \
\SetClipStatus%, \
\GetClipStatus%, \
\GetTexture%, \
\SetTexture%, \
\GetTextureStageState%, \
\SetTextureStageState%, \
\GetSamplerState%, \
\SetSamplerState%, \
\ValidateDevice%, \
\SetPaletteEntries%, \
\GetPaletteEntries%, \
\SetCurrentTexturePalette%, \
\GetCurrentTexturePalette%, \
\SetScissorRect%, \
\GetScissorRect%, \
\SetSoftwareVertexProcessing%, \
\GetSoftwareVertexProcessing%, \
\SetNPatchMode%, \
\GetNPatchMode%, \
\DrawPrimitive%, \
\DrawIndexedPrimitive%, \
\DrawPrimitiveUP%, \
\DrawIndexedPrimitiveUP%, \
\ProcessVertices%, \
\CreateVertexDeclaration%, \
\SetVertexDeclaration%, \
\GetVertexDeclaration%, \
\SetFVF%, \
\GetFVF%, \
\CreateVertexShader%, \
\SetVertexShader%, \
\GetVertexShader%, \
\SetVertexShaderConstantF%, \
\GetVertexShaderConstantF%, \
\SetVertexShaderConstantI%, \
\GetVertexShaderConstantI%, \
\SetVertexShaderConstantB%, \
\GetVertexShaderConstantB%, \
\SetStreamSource%, \
\GetStreamSource%, \
\SetStreamSourceFreq%, \
\GetStreamSourceFreq%, \
\SetIndices%, \
\GetIndices%, \
\CreatePixelShader%, \
\SetPixelShader%, \
\GetPixelShader%, \
\SetPixelShaderConstantF%, \
\GetPixelShaderConstantF%, \
\SetPixelShaderConstantI%, \
\GetPixelShaderConstantI%, \
\SetPixelShaderConstantB%, \
\GetPixelShaderConstantB%, \
\DrawRectPatch%, \
\DrawTriPatch%, \
\DeletePatch%, \
\CreateQuery% }
REM Phew! We will put all this stuff in a library so we don't have to
REM type it out every time.
REM Now, remember to redirect our structure we just typed out to the
REM interface's despatch table.
!(^IDirect3DDevice9{}+4) = !IDirect3DDevice9%
REM Now we can do something with this device.
REM For this tutorial we shall just change the background colour by
REM cycling though some different RGB values 1000 times.
D3DCLEAR_TARGET = 1
FOR I%=1 TO 1000
R% = 128 + 127 * SIN(TIME/50)
G% = 128 + 127 * SIN(TIME/70)
B% = 128 + 127 * SIN(TIME/90)
REM Now we OR these values together to create an D3DCOLOR value
C% = &FF000000 OR (R%<<16) OR (G%<<8) OR B%
REM We could check the return values of these calls,
REM but we won't bother here because we are in a tight
REM loop and we want to get on with things. If we had
REM a problem we could check the return values to aid
REM our debugging process.
SYS IDirect3DDevice9.Clear%, IDirect3DDevice9%, 0, 0, \
\ D3DCLEAR_TARGET, C%, FNf(1.0), 0
SYS IDirect3DDevice9.BeginScene%, IDirect3DDevice9%
REM We will do lots of other things here!
SYS IDirect3DDevice9.EndScene%, IDirect3DDevice9%
SYS IDirect3DDevice9.Present%, IDirect3DDevice9%, 0,0,0,0
PRINT TAB(0,0)"Frame : "; I%, " Colour : ";~C%
NEXT
PRINT "Finished."
PROC_Cleanup
END
REM A cleanup routine.
DEF PROC_Cleanup
REM Release IDirect3DDevice9
IDirect3DDevice9% += 0 : IF IDirect3DDevice9% THEN
SYS IDirect3DDevice9.Release%, IDirect3DDevice9%
ENDIF
REM Release IDirect3D9
IDirect3D9% += 0 : IF IDirect3D9% THEN
SYS IDirect3D9.Release%, IDirect3D9%
ENDIF
REM Free the dll
D3D9DLL% += 0 : IF D3D9DLL% THEN SYS "FreeLibrary", D3D9DLL%
ENDPROC
DEF PROC_Error
SYS "MessageBox", @hwnd%, REPORT$, "Error : ", 0
ENDPROC
REM Convert to 32-bit float
DEF FNf(A#)
LOCAL A%,P%
PRIVATE F%
IF F%=0 THEN
DIM P%10
[OPT 2
.F%
mov esi,[ebp+2]:mov edi,[ebp+7]
fld qword [esi]:fstp dword [edi]
ret
]
ENDIF
A# *= 1.0#
CALL F%,A#,A%
=A%
|
|
Logged
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: DirectX9 tutorials for BB4W
« Reply #24 on: Jul 28th, 2015, 9:13pm » |
|
....and it works in v6.00 trial!

Um, Richard, I need an ungrade.exe I am afraid... new computer again..
Michael
|
|
|
|
|