Hey Robert
>
> Thanks for the more detailed explanation. From what I can make out you are
> able to render the 3 models to a pbuffer than render this with transparency
> over the desktop OK, this part if functioning as intended. Is this correct?
>
Yes this is correct!
As for the HUD Ill try getting it working in a standard OSG graphics context
first as you said. Probably the best idea.
As far as your suggestions for optimization. I think I understand. However I
was under the impression that the osg::Image was the pbuffer.
In order to to my transparent screen trick I have a struct:
Code:
typedef struct
{
int width;
int height;
int pitch;
HDC hdc;
HBITMAP hBitmap;
BITMAPINFO info;
BYTE *pPixels;
} Scene;
Then I initiate the struct with some init values. Then the I do a memcpy from
the pbuffer/image to the struct:
Code:
for (int i = 0; i < g_image->t(); ++i)
{
memcpy(&g_scene.pPixels[g_scene.pitch * i],
&g_image->data()[((sHeight - 1) - i) * (sWidth * 4)],
sWidth * 4);
}
Here g_image is my osg::image and g_scene is my struct. Once I have copied the
data I redraw to my "layered window" . This method takes care of applying the
necessary actions using BLENDFUNCTION and UpdateLayeredWindow.
Code:
void RedrawLayeredWindow()
{
// The call to UpdateLayeredWindow() is what makes a non-rectangular
// window possible. To enable per pixel alpha blending we pass in the
// argument ULW_ALPHA, and provide a BLENDFUNCTION structure filled in
// to do per pixel alpha blending.
HDC hdc = GetDC(g_hWnd);
if (hdc)
{
HGDIOBJ hPrevObj = 0;
POINT ptDest = { 0, 0 };
POINT ptSrc = { 0, 0 };
SIZE client = { g_scene.width,
g_scene.height };
BLENDFUNCTION blendFunc = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
hPrevObj =
SelectObject(g_scene.hdc, g_scene.hBitmap);
ClientToScreen(g_hWnd, &ptDest);
UpdateLayeredWindow(
g_hWnd,
hdc,
&ptDest,
&client,
g_scene.hdc,
&ptSrc,
0,
&blendFunc,
ULW_ALPHA);
SelectObject(g_scene.hdc, hPrevObj);
ReleaseDC(g_hWnd, hdc);
}
}
I suppose I could use something other than an OSG::Image to bind to the BYTE
property of my struct. The thing is Im still quite new to a lot of this so I
don't know how I would do that.
Let me know if Ive been unclear. Its also a challenge explaining this stuff
for me as well :S
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=60891#60891
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org