"Windowless" DirectX?

Menge

Centurion
Joined
Jul 3, 2003
Messages
108
Location
Recife - PE - Brazil
Is there a way to create a directx device that has no window attached to it? or just the screen?

i want to make an app which uses directx and draws with an alpha channel to the screen. much like this one does:
screenshot.jpg

this is MobyDock , which is a clone of apple's Dock program. it uses DirectX9 and draws to the screen transparently (with alpha). the blue background is the desktop already.

i want to make something similar. how to i make a directx window or device that draws this way?
 
I doubt the program is using DirectX to draw to the screen.

Most likely, the form is using a concept called Regions. It's built into windows and allows a form to take on a non-rectangular shape. The shape is up to you but can be semi-standard such as an oval, or follow the shape of a bitmap. Check out regions in the MSDN help for some samples and then search Google for the various Region related function names for sample code.

-Ner
 
ok i'll take a look.

but... do these regions support alpha blending within the desktop? i mean... if i load a png with various alpha values, will it apply to those regions?
 
No. I don't know of any way to get a partially blended form. Certain versions of windows support the transparency of a form, but I don't think it works other than as a single value for the whole form. I understand what you have/want, but I'm not sure it's possible without breaking up the form into multiple forms.

As far as DX is concerned, it MUST be tied to a window to do any drawing. I don't think I've ever heard of tieing it to the desktop. As for drawing, you can't draw outside of the form's boundary. So you'd have to be able to make the form fully transparent but still have DX drawing show up. I don't know if that's possible - I think I'd stick with the regions.

-Nerseus
 
i got directdraw to draw outside my form (all i needed to do was not have a clipping surface and it draws to the whole screen even if attached to the window)... but i couldn't manage to get it to draw an alpha blended png file (which is my desired format target). i can get direct3d to draw the alpha blended png... but only INSIDE the window.... not outside like DDraw... if i could destroy this clipping surface

there are a couple other "dock" programs around which do the same thing... but the others only use GDI+. how they do it? i don't know.

this one i mentioned seems to use GDI+ too... but it also uses DirectX for something (i suppose managing the pngs and forming the image?)

i was thinking of rendering to a surface which would be Cleared with Color.Transparent color and then drawn the icons over... and then creating a bitmap of this surface and then drawing as the BackgroundImage of the form (which makes the form alpha-blend... but i can't manage to create a bitmap of the surface. i've already rendered to the surface... but can't get the graphics object linked to a bitmap.

help?

this one i mentioned seems to use GDI+ too... but it also uses DIrectX for something (i suppose managing the pngs and forming the image?)
 
ek1,

thx. but that's not what i want... if u've seen the pic, i want alpha blending too. i've managed to do this quite fast using the UpdateLayeredWindow function.... it's quite good.... but unfortunately, as Windows sucks at graphics, it's slow when i blit images larger than 400x400 (only 10fps or even less)
 
In your first post, it is just showing a shaped form. In the "dock.jpg" I can't tell if any of it's alpha blended apart from what appears to be a gradient background probably on another shaped form.
Using DirectDraw to draw to the screen will not make the stuff you draw interactive and directdraw should be contained in a window because it Windows's GDI operations stuff up on other windows (WM_PAINT isn't sent when DirectDraw draws all over a window)
 
ok

lemme explain something... NOTHING u guys see is a shaped form... nor regions are being used... i found out.

its all layered windows. render to a Direct3D surface. LockRectangle on it, Create a Bitmap from the InternalData of the GraphicsStream u got, and through windows api update it to a layered window. that's it... here's what I did:

dev0822.jpg
 
hrm... here's the copying from Direct3D to the window. keeping in mind that "front" is the device's render target, or at least an A8R8G8B8 surface with the image to be copied. and the window has the WS_EX_LAYERED attribute

Code:
Rectangle dock=new Rectangle(new Point(0,0), new Size(500, ProgramConfig.IconSize));
Microsoft.DirectX.Direct3D.GraphicsStream Image=front.LockRectangle(dock, LockFlags.None);
				
Bitmap b=new Bitmap(dock.Width, dock.Height, Convert.ToInt32(this.Width*ProgramConfig.BMPFIX), System.Drawing.Imaging.PixelFormat.Format32bppArgb, Image.InternalData);

IntPtr Bmap=b.GetHbitmap(Color.FromArgb(0));
IntPtr memDc = CreateCompatibleDC(GetDC(IntPtr.Zero));
IntPtr oldBitmap = SelectObject(memDc, Bmap);

try
{
	size.cx=dock.Width;
	size.cy=dock.Height;
	UpdateLayeredWindow(LabelDisp.Handle, IntPtr.Zero, ref topPos, ref size, memDc, ref pointSource, 0, ref blend, ULW_ALPHA);
	if(Disp.Visible && ProgramDoing==ProgramState.Nothing)PopUp(false);
}
finally
{
	if (Bmap != IntPtr.Zero) 
	{
		SelectObject(memDc, oldBitmap);
		DeleteObject(Bmap);
	}
	DeleteDC(memDc);
	b.Dispose();
	Image=null;
	front.UnlockRectangle();
}

any optimizations are EXTREMELY welcome. the bitmap creation part is the slowest part of all... if i could only change the scan0 of the bitmap to the InternalData of the LockRectangle
 
Back
Top