How would I go about writing a text engine for my DirectDraw game? I don't really even know where to start other than GDI, which I've heard is slow...
Cheers
DW
How would I go about writing a text engine for my DirectDraw game? I don't really even know where to start other than GDI, which I've heard is slow...
Cheers
DW
Hummdee humm, quick google search gave me this:
http://www.andypike.com/tutorials/directx8/011.asp
http://www.google.ca/search?num=50&h...ering+tutorial
Thanks for the links man, but those were primarly D3D based. I was looking for somthing for DirectDraw...
DirectDraw is now included in Direct3D instead of being it's own library. If you are using a modern version of DirectX you should be just fine. If not, why are you using outdated software?
I'm using DX7 because thats what Andrés book uses. I want to stay simple until I fully dive into 3D! and keep everything coherant with the book
You would be. All versions of DirectX are backwards compatible to my knowledge. You would only have to change an include here or there, in fact I think it still recognizes ddraw.h.
Well damn! Now I find out! Ah well, I'm not tooo choked!
But you cannot use the D3DX text functions inside of DirectDraw. If you are using DirectDraw, and if you are I have no idea why, then you will have to create your own text functions and/or use GDI.
So if I convert everything to D3D, use a DX7 interface I still get DD right?
But I can't then tap into the D3D aspect right?
So could I use both interfaces? a DX9 and DX7 and use the Dx9 for text and a DX7 for DD?
As to why i'm using DX7, its because thats what the book uses, and for my first game, I want to keep it simple, and the same as the book.
Cheers
DW
I wouldn't recommend mixing interfaces. Use the most recent interfaces as it relates to the interface you need. Some interfaces, although they are considered DirectX9 are not up to version 9 as of yet. It can get quite confusing and most of the API interfaces have been updated to be much more version friendly to the programmer using them. But there are still some out there that although they are DirectX9 interfaces, they are really only version3 or 4 interfaces.
For the most part all of the Direct3D interfaces usually have the number 9 in them somewhere which makes it easy.
The problem you will run into when using older interfaces is that you have no way of knowing which interfaces were available at the time DirectX7 was readily being used and developed for. Even though all of DirectX is backwards-compatible it is not forwards-compatible because it's impossible to do that.
For Direct3D most all of the interfaces look like this:
IDirect3DTexture9
IDirect3DVertexBuffer9
IDirect3DIndexBuffer9
The D3DX interfaces and functions are not so straightforward and often look like this. Notice there is not a version number in the functions or interfaces.
ID3DXMESH
ID3DXSPMESH
D3DXVec3Normalize(D3DXVECTOR3 &in,D3DXVECTOR3 &out)
D3DXVECTOR3
D3DXMATRIX
DirectSound and DirectPlay are totally different from both of these as most of their interfaces are only up to about version 4.
Because of all of the interface version problems associated with not updating the entire API on each iteration of DirectX, several of the COM objects in DirectX have an associated Direct<type/version>Create() function. This function will call CoCreateInstance() for you as well as create the base interface pointer and then auto-update it to the newest one for you. Lamothe explains how to update the interface to the newest one in his book. However his method is fairly deprecated for all but DirectPlay and other interfaces that lack functions that do this for you. As of DirectX9, Direct3D, DirectInput, DirectMusic (DirectSound and DirectAudio combined), and some others have create functions which will pretty much do all of the work for you and return the pointer that was created - this pointer will point to the newest version of the interface available. Other interfaces like DirectShow and DirectPlay must be created in the same manner that Lamothe describes for DirectDraw.
Check the SDK for more information. If you are not developing for the latest version of DirectX, you are probably going to have a lot of problems determining which interfaces were available at the time your target version was released. You will need to get a hold of a completely different SDK than the one MS offers on their site. Perhaps they have the older SDKs in an archive somewhere on the site. I'm not sure about this, though.
Last edited by VirtualAce; 11-11-2004 at 10:57 PM.
ah ok.....
But is it possible to use D3D text stuff with DirectDraw? IN any way, without blowing somthing up?
DW
I don't think so. The D3DX text functions require a pointer to a valid IDirect3D9 interface which you will not have if you are using DirectDraw. But you can use GDI which is going to be slower, but it is more robust and allows you to use all kinds of formatting options. I'm sure that a lot of games out there do in fact use GDI to some extent. Text is something that is not fun to program nor is it all that rewarding. Re-inventing the wheel really doesn't help your game presentation much and if you have the frames to spare, I see no reason why you shouldn't use GDI in this case. Even the D3DX functions that use textured triangles don't support extensive formatting options.
The Windows text functions are extremely complex and extremely robust. In fact it is probably one of the most complex text systems in existence. You can find a lot of information about it over at www.msdn.com. The True Type specification is more of an Apple thing....but MS pretty much uses it extensively. Very complicated stuff.
Try it out. Load up your favorite game and fire up the frame rate counter on the screen. Now go to a screen that is not a front-end screen (most of these are bitmaps...not rendered text) and check the FPS. I think you will find that the FPS drops a lot in most, if not all, cases which would point to the fact that the game is probably using the GDI to write the text.
Do you know of any good GDI text tutorials?
the best tutorial would be the MSDN. Trust me, GDI makes it pretty easy. And since we're on the topic on using dated software, maybe you want to check out GDI+? I never used it personally, but I have read the docs. It is a bit easier than the GDI, and it's cleaner.
www.freetype.org
Enough said.
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers