Jump to content
  • Advertisement
Sign in to follow this  
shvalb

Running Graphics without a Window Handle

This topic is 5062 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I'm a beginner in Direct-X and I work on a project that uses Direct-X and in this project we open a Window and render geometry objects to the screen and taking the output and creating Avi files from it. (I hope I describe it well) My assignment is to eliminate the window, meaning, do all the rendering and everything but without displaying it to the screen, is that possible ?? if YES, how ?? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
When you call the Present() function for your Direct3D device, it has a parameter called hDestWindowOverride, which I guess you could use to change the window the data outputs to. If this window was hidden then the contents wouldn't be displayed.

However, another way would be to get the current render target and read the data from it. This is done using the GetRenderTarget() method of the Direct3D device. This returns you a surface which you can then call LockRect() on and get the memory with the information in.

Some example code (not totally complete or correct!)



IDirect3DSurface9 *renderTargetSurface = NULL;

D3DDevice->GetRenderTarget(0, &renderTargetSurface);

D3DLOCKED_RECT lockedRect;

renderTargetSurface->LockRect(lockedRect, NULL, 0);

// read your data however you want from lockedRect.pBits...

renderTargetSurface->UnlockRect();

renderTargetSurface->Release();





You may choose to write over the data in the surface so it's black again, so when you call Present() (if you choose to) it doesn't render anything to the window except blankness.

-Mezz

Share this post


Link to post
Share on other sites
It is my understanding that you can pass NULL as a window handle, and DX will use the desktop in place of the window. I haven't actually gotten this to work myself, but I haven't fooled around with it that much.

Share this post


Link to post
Share on other sites
rendering to the desktop isn't good, let me explain, my program run as a plugin on a server and it supposed to generate small videoclips, actually it suppose to generate many small video clips, the number of clip is dynamically created, so if in a specific moment there are let's say 10 videoclips and they would be placed on the screen so there is no more room for another one and at this specific moment I will have to generate another one...there won't be any space available for it and that's bad!

so, it's crucial for my program to be able to render graphics withou openening a window, and the million dollar question is: is this possible ??? and ofcourse, how ??

Share this post


Link to post
Share on other sites
In the service properties dialog, under Login tab is a checbox "allow this service to interact with the desktop", that enables the current service to create windows and interact with them (to create a d3d device object, for example).

It is not required to actually draw anything on the actual desktop window, but you do need a window handle to initialize the device.

EDIT: Of course, it is very possible to run a server program in user desktop also - however, the service concept works better in this type of applications.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!