Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / D3DLIB - D3DFunc 3.7.1 + Extras for DarkGDK 7.3+ Class Library

Author
Message
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 25th Aug 2009 04:27 Edited at: 27th Aug 2009 17:52
Hello All

Im not sure about everybody, but I have had issues using Cloggy's D3DFunc GDK version with any version of DarkGDK from the November2008 upgrade to present 7.4. I actually resolved the issues myself by porting the parts of Cloggy's source code for DBPro to GDK.

But it has come to my attention that other users were having trouble getting it to work with the latest version of DarkGDK aswell, so I thought I would port the whole thing over into a set of easy to use classes.

All of the Functionality of D3DFunc 3.7.1 is wrapped into the classes, aswell as a bunch of extras that I have only just begun wrapping into it. These include Coloured Positionable Shadowed AA Text, and some Direct Image Access drawing functions that were written originally be Sephnroth.

The entire thing is contained in a derived class called "D3DLIB".
I have prefixed all of the function names, primarily to group them together inside intellisense so its a little more intuitive to find the functions. The Prefixes are as follows :

B3D_ - Batch 3D Drawing Functions
B2D_ - Batch 2D Drawing Functions
F3D_ - Normal 3D Drawing Functions
F2D_ - Normal 2D Drawing Functions
TXT_ - All of the AA Text Functions
IMG_ - All of the Direct Image Access functions
GDK_ - All of the "CORE" functions, camera, object creation and helpers.

There is a demonstration app that I have included in with the source code to demonstrate usage of all the major parts of the lib.

The Lib has some basic documentation with it, in the form of fairly extensive code comments, and I have setup the intellisense "docs" where it will show you the comment for the function you have highlighted.

I would like this to be considered as something similar to a "beta" release of D3DLIB. I would like to get some people to test it for me if possible and let me know any bugs they find so I can track them down and hopefully fix them. I also have a bunch of other classes that I am adding to D3DLIB, to extend it even further. There is a Terrain Generation class, that is built with DX meshes, it supports generating its own Alpha Maps, Environment Maps, has a built in set of A* Pathfinding functions and can handle "objects" placed on it, it stores where they are etc. There is a perlin noise image generation class, which doubles as the heightmap generator for the terrain class, its capable of generating its own normals maps for the noise maps it makes and can load and save its images, Plus various other classes that contain more or less "helper" functions, designed to make repetitive tasks simpler.

Here are some screenies of the demo :







Here is the Demo Program's source code(its in the attachement aswell, its just here so you can see how everything is working)



As you can see, the usage of all of the functions is achieved through the D3DLIB derived class, which inherits from all of the others and maintains all of the global variables etc. It is also quite simple an intuitive. Plus the speed is simply amazing, to do all of the drawing operations in this demo, using GDK commands alone would result in it crawling at a snail's pace.....

Attachment ZIP contains all of the source code for the library, aswell as the source code for the DEMO program and the actual project that I compiled the DEMO from, so you can see how I have it setup, just add the D3DLIB.vcproj to an existing solution.

Note that the EXE in the attachment was compiled with DarkGDK 7.4 and most of the testing I did was also using that version of GDK.

I hope this helps a few people. Ill be posting any updates to the library here in this thread, ill update the attachement in this post so you will always find the latest version here.

Please note, you do not have to use the included classes, the way everything is working together is quite simple, and it would not be very hard to extract the functions from the classes and use them on their own if you wish to.

EDIT : A new attachment as of 28th Auguest, it fixes the following :

* GDK_GetDesktopWidth();
* GDK_GetDesktopHeight();
* GDK_GetDesktopDespth();

Those functions are basically empty in cloggy's library, they return NULL values, hence the 0's. I just made a couple of WinAPI calls to get the desktop res data like this :



g_hDesktop is a HWND handle to the desktop and is global if you want to use it... the DEVMODE structure is local and will go out of scope after the lib is instanced.

If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 26th Aug 2009 08:39
Here is a DEMO of the Terrain classes that I am working on, I mentioned them in the above post.

They are the result of me following around half a dozen various DirectX Games related tutorials from books and websites, trying to put everything together.

So far, there is no lighting in the demo, but there are NO GDK Objects, images or entities of any kind.... its all pure DX, using GDK to render, although it can be interfaced with GDK for normal usage without any problems, I can place GDK objects on it etc..

This is a definite work in progress so dont take the look of the terrain to be too final.

The terrain is made up of "Mesh Patches", which fit together to form the final terrain(there is no LOD yet, but it does cull lol). The size of the terrain can be specified and changed on the fly, generation, as you will see, is very close to instant. It supports rectangular terrains, so it doesnt have to be square.

It has some very basic pathfinding algorithms built into it at the moment, I will be expanding them to be a little more modular. At the moment you can give it 2 points and get a path back between those 2 points, but its tied into the terrain classes height and environment maps.

The Texturing is all done through a Pixel Shader, and again, rendered straight to the mesh through DirectX, with GDK essentially "presenting" the frames I setup. The Terrain generates its own alpha maps based on it's height for the shader to texture splatter it.

The "Object Placement", they are just directX meshes aswell, they are loaded from .X files, is all handled through the terrain class on terrain creation. It generates and environment map to place them randomly(and is based closely off the alpha algorithms), its based on the terrain height at the moment, it places trees on grass and rocks on rock or snow.....

Ok, thats enough prattling... here is a screeny of the terrain with a path layed out on it from the top of a mountain to the bottom. The blue dots represent places the pathfinding alg. checked on its way through.....



The Attachment only contains an EXE(compiled with GDK 7.4) and the shader/media files. No source code in the download this time, but I will put the Main.cpp file in code tags below... Note that you wont be able to compile it, as its using a different verion of my D3DLIB and about half a dozen extra classes for the terrain management...



Ill get this finished as I can and post back... May possible put it in the WIP forums, ill see how I go, If I do, ill post here to say so.

If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 26th Aug 2009 22:15
Hi Mista, both demo's worked nice and smooth for me! The terrain and AI stuff is intriguing.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 27th Aug 2009 10:54
SUPER FANTASTIC!

I am sure I speak on behalf of all, when I say that we all love you! You are providing us all with some great and useful stuff for GDK!

thanks!
Techtress
16
Years of Service
User Offline
Joined: 11th Jul 2008
Location: USA
Posted: 27th Aug 2009 15:31
Congratulations and thanks a lot! most everything works now ( including shaders, yay! ). I think the text shadows added a neat little effect.

This may be one of my strange little problems again but when I run the demo program on both of my computers ( defferent OSs and different video cards ) there is no anti-aliasing on text or 3d objects unless I force it on, but even then there is none on the text. This same problem existed in the old D3DFunc too.

It could be some missing DLLs because at first the demo would not run and said it needed d3dx9_41.dll so I had to manually download that.

One more thing I'd like to point out and I believe a couple of functions are not working ( for me, at least ): GDK_GetDesktopWidth(), GDK_GetDesktopHeight(). They both return 0.

These are all pretty minor problems for me and hardly decrease the quality of these libs. Seriously they have helped a lot!
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 27th Aug 2009 16:52
Thanx for letting me know Techtress, im glad most of its working, ill take a look at those functions and check I didnt make a silly type somewhere or other.. Although those functions are supposed to be returning the desktop resolution I think... so if your desktop was set to 1280x1024... the GDK_GetDesktopWidth() should return 1280, im not sure if being in fullscreen or not would affect that ill have to check that too..

I did compile the demo with the March2009 DirectX SDK and GDK 7.4, so maybe if you didnt have the very latest directX redist or something like that it may have caused the missing dll msg.. Ill have a look through the D3DFunc thread aswell and see if any of these problems are something that is a known issue(those functions are fron D3DFunc by Cloggy) but like I said, im guessing its most likely some typo or other I missed lol, also the Terrain one is using mostly pure DX code, GDK is basically only presenting frames I am setting up in that demo and controlling the cameras, though it does talk to GDK...

If it ain't broke.... DONT FIX IT !!!
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 27th Aug 2009 17:54
I have added the functionality to get the desktop resolution and bit depth to the lib and updated the top post and the DEMO with the new version.

The Demo now display the desktop res in the top middle of the screen, see my first post for details.

Thanx again Techtress for letting me know. I wouldnt have picked that one up without someone telling me, I really appreciate it

If it ain't broke.... DONT FIX IT !!!
Matt G
20
Years of Service
User Offline
Joined: 26th Oct 2004
Location: Australia
Posted: 30th Aug 2009 13:13
I get the error
1>.\D3DLib.rc(10) : fatal error RC1015: cannot open include file 'afxres.h'.
when i try to compile the demo. Google tells me that its a mfc thing, and isnt included in the express version of visual studio, is there a way to remove it as dependency or is it nessecary?
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 30th Aug 2009 13:44
No, I only included my project so you could see the structure of how I had it setup and the settings I used. Im sorry it probably wont compile in VS express as I use the professional version of VS.

However, all you need to do is to start you own new empty GDK project in Visual Studio Express and delete the main.cpp file that is generated, then manually copy all of the .cpp and .h files (except resource.h) from the D3DLIB folder over to you new project's folder.

Then inside Visual Studio, right click on your project name in solution explorer and select "Add Existing...". That will present you with a file dialog window to select the files you want to add(you can select more than once file in the window by holding CTRL or groups with SHFT), just select all of the files you copied and hit ok to add them to your project.

From there, you should be able to compile and run the demo. Note that if you are in debug mode, dont forget to change the library to MT from MTd.

Hope that helps, if I wasnt clear on something, just ask and ill try to explain further.

If it ain't broke.... DONT FIX IT !!!
Matt G
20
Years of Service
User Offline
Joined: 26th Oct 2004
Location: Australia
Posted: 30th Aug 2009 14:42 Edited at: 30th Aug 2009 15:07
nope thats ok, i worked it out in a hack way, by copying my source over the main.cpp source in your project, and compiled which worked after deleting a bunch of things (like the resource.h). So then it led me to doing just what you said . ty tho.

Incedently what im trying to do with d3d func is draw some text to an image so i can use it as a texture, but i cant get it to work with either dark gdk's text or this, how can i do it? I see a lot of dbMakeImageUsage() when people are doing similar things but i cant find the documentation on how to use that anywhere...

I was trying to make a new camera, set it as the active camera, print some text and render that camera to an image, so that i can dynamically create/delete text on a plain.
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 30th Aug 2009 15:20 Edited at: 30th Aug 2009 15:28
just use dbSetCameraToImage() when you are creating you camera.

Its params are :

dbSetCameraToImage(int CamID, int ImgID, int Width, int Height, int GenAlpha);

That command will create the image for you, ImgID.. you can then do what you want with it and render to it by rendering to the camera

hope this helps(its the easiest way I could think of lol)

EDIT : You could also have a look at the IMG_ commands and how it swaps the render targets around, and use something similar to swap your render targets before you use the TXT_ functions. That would be more complex though and I would suggest using the GDK commands where possible as they are easier and tidier..

Also to answer you question about the dbMakeImageUsage question... To be completely honest, I have no idea, other than that I deduced this was the only way that worked through trial and error... I tried all of the other GDK image creation commands and they just wouldnt accept being wrangled in the way I was doing it, this one would.

It's parameters are the same as the normal dbMakeImage() function, passing it an integer ID and the width and height. Where it differs is in it's 4th parameter. It is a DWORD, and again I dont know exactly what other parameters you can pass it or use it for, but pass it the value of "1" allows it to be used as a render target, and other values dont.

Im sorry I cant be more helpful with how that command works, but I honestly just kind of used trial and error and guess work in relation to that, once I had it working how it should I stopped experimenting with it. I also havent had the need to pass it any other values, if it has any, as it does everything ive asked it to so far with the value "1" passed to it lol...

If it ain't broke.... DONT FIX IT !!!
Matt G
20
Years of Service
User Offline
Joined: 26th Oct 2004
Location: Australia
Posted: 30th Aug 2009 16:08
yeah that is what i tried to do, but im not getting any text on my image.

Matt G
20
Years of Service
User Offline
Joined: 26th Oct 2004
Location: Australia
Posted: 30th Aug 2009 16:10 Edited at: 30th Aug 2009 16:26
[EDIT] Whoops, sorry for the double post, my internet died mid posting and i pressed post again when it came back up...

yeah that is what i tried to do, but im not getting any text on my image.



And the d3d func version:




Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 30th Aug 2009 16:34 Edited at: 30th Aug 2009 16:38
Here try this :



This creates camera 1 and sets it to image 1. It then creates a box and textures it with image 1.

It gets the render surface of the image and swaps it before the text is sent to it, then swaps it back afterwards and sends more text to the main camera.

Use the above as an example... I hope it helps you

EDIT : I only jsut noticed in your code, You are assuming camera number 1 is the default camera in GDK, its actually Camera 0 thats the default.

If it ain't broke.... DONT FIX IT !!!
Matt G
20
Years of Service
User Offline
Joined: 26th Oct 2004
Location: Australia
Posted: 30th Aug 2009 16:40
Wow, ty. It works, havent taken the time learn why atm, cause of the time and i have work (btw, similar time, hello fellow aussie, what are you still doing up, and while im btw'ing, nice dreadnaught avvy u traitor). But ty very very much, i will definitely try to learn from that 2moro.

Login to post a reply

Server time is: 2024-11-20 17:24:38
Your offset time is: 2024-11-20 17:24:38