Background image in V3d_View

Hi, I tried to add a background image in a 3D view...and it doesn't work. I obtained only a black filled rectangle on the screen. The tests were done with .GIF and .BMP files, in centered and stretched mode.
I work with OCC 5.1 on W2000 with a NVIDIA Quadro II video card.
It is not a big problem, but if someone know how to do...
Best regards

Forum supervisor's picture

Hello Jerome,

To have a look how this new functionality works you may use the Draw Test Harness. Make sure you install Open CASCADE binaries in Release mode (on Windows). Then launch the AIS Viewer among all harnesses and use the following commands:
Draw > vinit
Draw > vsetbg $env(CSF_MDTVTexturesDirectory)/2d_bumps.rgb TILED

This will display several images tiled.
To consult the source code that does the work use the command:
Draw > getsource vsetbg
and visit the suggested source file.

Best regards,
Forum supervisor

Jerome's picture

It's working in test harness but not in my app, even with cascade in release mode. The only difference is that I'm using a view in a splitter in place of a mainframe window like in test harness!.
Maybe I've missed something.

Philippe CARRET's picture

Hello Jerome,

Here is one answer for Win32

I know nothing about Test harness and I could'nt make it work with previous reply but it helped me to find the new function "SetBackgroundImage" and try it.

With OCC 5.1 (installed on D:\ here) it works perfectly well
I just modified the MFC Sample 07 3d Viewer just below . You must change the filename to fit your needs of course.

To make it work YOU MUST first compile mfcsample project and put the lib in some correct library. I've modified the setting of project mfcsample.dsw to output directly files to :

// CViewer3dView drawing
void CViewer3dView::OnInitialUpdate()

myView = GetDocument()->GetViewer()->CreateView();

// set the default mode in wireframe ( not hidden line ! )
// store for restore state after rotation (witch is in Degenerated mode)
myDegenerateModeIsOn = Standard_True;

Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =

Handle(WNT_Window) aWNTWindow = new WNT_Window(theGraphicDevice,GetSafeHwnd ());
if (!aWNTWindow->IsMapped()) aWNTWindow->Map();

// Standard_Integer w=100 , h=100 ; /* Debug Matrox */
// aWNTWindow->Size (w,h) ; /* Keeps me unsatisfied (rlb)..... */
/* Resize is not supposed to be done on */
/* Matrox */
/* I suspect another problem elsewhere */
// ::PostMessage ( GetSafeHwnd () , WM_SIZE , SIZE_RESTORED , w + h*65536 ) ;

// store the mode ( nothing , dynamic zooming, dynamic ... )
myCurrentMode = CurAction3d_Nothing;

Standard_CString FileName("D:\\OpenCASCADE5.1\\ros\\src\\Textures\\MyScreenTexture.gif");
Aspect_FillMethod FillStyle(Aspect_FM_NONE);//Aspect_FM_STRETCH
Standard_Boolean update(Standard_True);
myView->SetBackgroundImage(FileName, FillStyle, update) ;

Markus Nickels's picture

As I explained in a previous post, the problem is, that the background image is displayed as "black" when other objects were displayed previously - e.g. the trihedron.

The solution is to display the background image firstly and then the other objects.

Kind regards

Markus Nickels

Markus Nickels's picture

Look at this thread:

Kind regards