Background Image


... one more topic on this subject ...

Many people would like to set an image in the background of their view.

I'm trying to do it.

I found interesting things and now, I manage to do it in a V2d_View. For those that are interested by the code, here it is (I only tested it on Windows) :
In void CYouAppView2D::OnInitialUpdate(){...}, just add :
TCollection_AsciiString BGFile ("c:\\temp\\bg.bmp");
Standard_CString bgimage = (Standard_CString)(BGFile.ToCString());
myV2dView->SetBackground(bgimage, Aspect_FM_TILED);

This code is OK for 2D Views.

Now, I would like to do the same for 3D Views and I get problems ... :

With nearly the same code :
Handle(WNT_Window) aWNTWindow;
aWNTWindow = new WNT_Window(((CBackgroundApp*)AfxGetApp())->GetGraphicDevice(),GetSafeHwnd());

after that, add :
TCollection_AsciiString BGFile ("c:\\temp\\bg.bmp");
Standard_CString bgimage = (Standard_CString)(BGFile.ToCString());
aWNTWindow->SetBackground(bgimage, Aspect_FM_TILED);

When you display the view, it still has its default color, but when you keep on resizing it, you see the image and the default color blinking ...

The image is loaded but the bg color is draw on top of it ...

Are there coders, here, ready to help me ?

Thank you,


Patrik Mueller's picture


I'm not so sure my idea is right, but you have the V3d_View in front of the window background. So it could be it first draws the image and then clears the V3d_View via drawing an OpenGL rectangle with background color??

Just a thought,


Stephane Routelous's picture


As Patrick said, the opengl rendering is mapped in te WNT_Window, so the background is not shown ( the 3d "overwrite" the window ).
IT's working in 2d because de 2d with OpenCASCADE doesn't use OpenGL but the win32 api with GDI ( On windows of course ).
The only way to set a bitmap as background is to add this feature in V3d_View,Visula3d_View,Graphic3d_GraphicDriver,OpenGL package etc..

BTW, there is a method from

Patrik Mueller's picture


a second solution would be the implementation of a textured "AIS_Billboard".
But when I see the screenshots from OCCs browser plugin - perhaps they have already included it in V5?