Skip to main content
gamedev.net
🔒 Locked

Direct3D question...

Started by DarkCloud14 7 replies 850+ views
Original Post
DarkCloud14
DarkCloud14
Hi, is it possible to get somehow an existing Direct3D Device ?? I wanted to create a Mod for Half-Life and add some nice new effects with Direct3D but the problem is that I can't directly access the Direct3D Device Half-Life uses for rendering etc.. When I create a new Device and try to draw e.g. an texture the screen flickers because the game now renders the half-life game first then my texture and then the game again..... THX
DarkCloud14
DarkCloud14
Uhm how does such a DirectX wrapper work or better where can I find
an example ???

THX
Squirell
Squirell
I can't remeber for sure but it I think there might be some functions along the lines of GetDevice() for certain things (such as textures and meshes) that returns the device. I'm not sure exactly what so poke around in the SDK and see if you can't find something, I'll look sometime too.
wasd
wasd
Writing a program that tries to directly access a device belonging to another program wont work, because there's no way to synchronise the calls to the graphics card, so you'd get something like this:

SetRenderstate (HL)
Draw (HL)
SetRenderstate (Yours)
SetRenderstate (HL - Overriding yours)
Draw (HL)
Draw (Yours)

And it would just be a mess. Plus, I think devices are private to their owning program. What you're better off doing is writing a GL driver for Half-Life. Half-Life allows you to specify external GL drivers (Place your .dll in the "gldrv" folder and add a reference to it to the drvmap.txt file in the same directory). This way, you can write a wrapper for OpenGL commands which uses Direct3D (It'll be a bit tricky, but should be possible), then add your own features.
superpig
superpig
Quote:
Original post by f8k8
And it would just be a mess. Plus, I think devices are private to their owning program. What you're better off doing is writing a GL driver for Half-Life. Half-Life allows you to specify external GL drivers (Place your .dll in the "gldrv" folder and add a reference to it to the drvmap.txt file in the same directory). This way, you can write a wrapper for OpenGL commands which uses Direct3D (It'll be a bit tricky, but should be possible), then add your own features.
I think that's your best solution. That way you can guarantee they're using Direct3D, too - otherwise you might find your mod running into problems when it tries to retrieve a Direct3D device from the OpenGL renderer. [wink]

Are you sure it's not something you can achieve via the Triangle API, though? I don't know of any other mods that provide their own renderers, and while I guess you could just have your renderer hand off to one of the prewritten ones, it's not exactly pretty.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
DarkCloud14
DarkCloud14
@superpig I'll use TGA Fonts to draw the say text etc. but the problem is, that you can only load and draw sprites with TriAPI
and if you try to load the tga with the integrated VGUI TGA Loader
you can just set the position of the text and the height and width of the image.. so you can't tell the programm "hey my first character is e.g. 16 pixel width and 16 pixel height and it's at position x, y ...

So I'll try to find another way to do that...
It's easy to add some OpenGL effects cause it'll use the present "device"
if there's already one but with Direct3D as I read now it isn't as easy...

I just wanted to add this feature(and some others too like volumetric fog)
to both video modes OpenGL and Direct3D but at the moment it seems that I can just add it to OpenGL without changing hl.exe ...

@Zybl I've send a PM to your gamedev Account..

[Edited by - DarkCloud14 on July 12, 2004 3:15:29 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.