DX9Lib

Started by Dabzy, Dec 20, 2024, 02:14 PM

Previous topic - Next topic

Dabzy

Newest addition to the family, my DX9Lib of old! \o/

Okay, I've added a bit more too it, tidied it up some what, discovered a few little buggeries which weren't there before.

Now, this was going to be added as a 2D renderer to LUI, because obviously, LibSGD was the meat, but, now, this is the meat, hence some of the updates I've given it, like input, the odd bit collision is to go in and probably other stuff.

Anyway, people out there may be screaming "Why DirectX9? Why didn't you just go for the throat and use a newer API"... Honest answer... There really really isn't anything wrong with DirectX 9, okay, it's over 20 years old, but, it works fine, the likes of your DirectX 11 and 12 bring a lot to the 3D party, tons, but, do I need all that? No!!! And if you do need all that, well, you probably wouldn't be here really.

For myself, and probably beginners, DirectX9 is perfectly fine, I had code there, so, I may as well use it! ;)

But then I'll hear "But, Microsoft may drop it or GPU cards/drivers may not support it", but then, who said anything about relying on a graphics card or it's drivers to support the API, thankfully, MS have thought about it, realised that there is a ton of software out there that relies on it, and as such, they've included mappings of Direct9 WITHIN DirectX12, it's called the D3D9On12 mapping layer, it maps D3D9 commands to D3D12 by acting as the D3D9 Device Driver Interface (DDI). Now, I'm not sure how far this mapping spans and how far they have with got with it, but, I have read that in some case's, a newer redistributable is required to be installed to cover some stuff that is missing. Unfortunately, at the moment, I don't have an extra (clean) Win11 PC to test on.

Anyway, nifty stuff, so in theory, DirectX9 has been around for over 20 years, and as such, given the support, there is no excuse not to be around for another 20. Which is why I find this a perfect solution for my needs... DirectX9 is going nowhere it seems! <---- Famous last words.

Right, like I did with Lui, here is a list of what's there currently:

DX9_Cls()
DX9_CopyImage%(image%)
DX9_CreateTargetImage%(imageWidth%,imageHeight%)
DX9_DegreeToRadian#(degrees%)
DX9_DrawAnimImage(image%,x%,y%,cellNumber%)
DX9_DrawAnimImageRect(image%,x%,y%,top%,left%,width%,height%,frame%)
DX9_DrawImage(image%,x%,y%)
DX9_DrawImageRect(image%,x%,y%,top%,left%,width%,height%)
DX9_DrawText(text$,x%,y%,centre,font%)
DX9_End()
DX9_Flip()
DX9_GetFPS%()
DX9_GetFontHeight%(font%)
DX9_GetFontWidth%(font%)
DX9_GetImageCellCount%(image%)
DX9_GetImageHeight%(image%)
DX9_GetImageWidth%(image%)
DX9_GetMouseX%()
DX9_GetMouseY%()
DX9_Graphics%(resWidth%,resHeight%,resFormat%,synced%,windowed%)
DX9_HidePointer()
DX9_IsFontAvailable%(sysFontName$)
DX9_IsKeyDown%(vKeyCode%)
DX9_IsKeyHit%(vKeyCode%)
DX9_IsMouseDown%(vmButtonCode%)
DX9_IsMouseHit%(vmButtonCode%)
DX9_LoadAnimImage%(filePath$, cellWidth%, cellHeight%, cellAmount%)
DX9_LoadAnimImageMasked%(filePath$,cellWidth%, cellHeight%, cellAmount%, red%,green%,blue%)
DX9_LoadFont%(font$,width%,height%,italic)
DX9_LoadFontRGB%(font$,width%,height%,r%,g%,b%,italic%)
DX9_LoadImage%(filePath$)
DX9_LoadImageMasked%(filePath$,red%,green%,blue%)
DX9_SetAlpha(alphaLevel#)
DX9_SetClsColor(r%,g%,b%)
DX9_SetDefaultRenderTarget()
DX9_SetEventMode(mode%)
DX9_SetImageMidOrigin(image%)
DX9_SetImageMidRotOrigin(image%)
DX9_SetImageOrigin(image%,x%,y%)
DX9_SetImageRotOrigin(image%,x%,y%)
DX9_SetRenderTarget(image%)
DX9_SetRotation(radians#)
DX9_SetScale(scaleX#,scaleY#)
DX9_SetWindowTitle%(title$)
DX9_ShowMessage(title$,message$)
DX9_ShowPointer()

DX9Lib.DLL Command Count: 46

Initial FPS comparison between B3D's DX7 (Running from Blitz3D IDE), and DX9Libs DX9 render (Running from Launchpad IDE) speed is thus:

B3D (DX7)
2700ish - Windowed
120 - Full screen  <---- VSync seems to be locked on my system in regards to DX7!?!

DX9
5300ish - windowed
6350ish - Full screen

Baring in mind, there is a residue DX7 DC running behind DX9!

Dabz
Intel Core i5 6400 2.7GHz, NVIDIA GeForce GTX 1070 (8GB), 16Gig DDR4 RAM, 256GB SSD, 1TB HDD, Windows 10 64bit

Dabzy

Managed to test it on a clean Win11 machine, updated the GFX driver, installed this:

https://www.microsoft.com/en-us/download/details.aspx?id=8109&msockid=15eb4e948a36630f1dba5aaa8bd662ae

Which I've plonked in the $LaunchpadDir$/DX9redist folder as a zip because the downloaded version is one of them crappy "Extract to here" things, where, you have to run it, dump the contents somewhere, with no option to create a new folder, (so you have to create a new folder before you extract the actual setup files otherwise you'll probably soil an existing folder) navigate to where ever it was dumped and then run the DX9SETUP.exe file from there... How very MS! :/

Anyhoo, once I had the driver/DX files installed, everything was tickety boo! \o/ yay

Dabzy
Intel Core i5 6400 2.7GHz, NVIDIA GeForce GTX 1070 (8GB), 16Gig DDR4 RAM, 256GB SSD, 1TB HDD, Windows 10 64bit

Dabzy

Oh aye, and I've documented the DX9Lib comments and implemented my own online documentation system don't you know... How very PHP of me:

https://launchpad-ide.com/launchpad/doc/index.php

:)

Dabzy
Intel Core i5 6400 2.7GHz, NVIDIA GeForce GTX 1070 (8GB), 16Gig DDR4 RAM, 256GB SSD, 1TB HDD, Windows 10 64bit