For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

gradient background

Adrian's picture


i made some modifications to the OCC sources. It is possible to set an upper and a lower background color in v3d_view to have a nice opengl gradient background. (It is also possible to set a single background color as usual). If someone is interested, i coud publish the diff.

Svetlozar Kostadinov's picture

I am interested, please!

Jeanmi B's picture

Hi Adrian,

I am interested too.

P Dolbey's picture

You can do it using the V3d_View call back feature without changing the occ sources.


Actually I did change the source to run the call back higher up in the rendering code - but only to fix colorscales / blending.

Still interested to see your code.


Svetlozar Kostadinov's picture

Hello, Pete! I've tried your code from QtOCC, but something went wrong. In the view was displayed only the gradient and no objects. Nevermind, when I have enough time, I'll continue and fix it. Regards!

P Dolbey's picture

The gradient code works on all platforms. The latest versions of qtocc are available in SVN - see . Whilst we are integrating Fotis' GEOM port from Salome, the widget hasn't changed much - apart from its class name.


P Dolbey's picture

Here's a tip that might help. When you create your Viewer (not View) set the z-buffer auto management fo false, similar to

// Create the OCC Viewers
TCollection_ExtendedString a3DName( "Visual3D" );
myViewer = createViewer( "DISPLAY", a3DName.ToExtString(), "", 1000.0 );
myViewer->SetZBufferManagment( Standard_False ); //


Svetlozar Kostadinov's picture

Hi, Pete! If you're reading this, may I ask you (or someone who knows) how to make the gradient working for transparent objects too? What I have to fix?

P Dolbey's picture

You could try using my Open CASCADE patch to the OpenGl rendering call back - I seem to remember that it fixed many of the problems related to transparency. I've started putting all my OCC patch collection into the QtOCC svn repository on sourceforge.

The relevant changes can be seen in the difference list shown here

You'll need to recompile the TKOpenGl library. Let me know if this helps.


Svetlozar Kostadinov's picture

Thanks, I've applied the patch rev.72 and the transparency now looks better, but still something seems wrong. See on the screenshot:

The sphere is black, 10% transparent. The bigger box is green, 10% transparent. The little box is opaque. I think the blending is not done correctly. For transparent objects only the areas in front of other opaque objects (and grid) are blended correctly.

Svetlozar Kostadinov's picture

Hi, the transparency problem has been fixed with changing the blending function. I've borrowed the code from a recent thread in the forum. I mean:

// if (myView->ColorScaleIsDisplayed())
// {
/* Not needed on patched OCC 6.2 versions, but is the lowest
common denominator working code on collaborators OpenGL
graphics cards.*/
// }

And the result is:

But there's another problem, which is related to OCC, not the gradient callback itself. When the green box' display mode or transparency is changed, the green box "pops up" even if there is another object above it. Look here:
Do you know what causes the display priorities to go wrong?

P Dolbey's picture

I was going to suggest that you look at the bleanding function, but you beat me to it. The problem I was running into was that I was getting different effects on different graphice cards when displaying the "colorscale". If you're not using this feature then the blending function you're using now should be OK.

Unfortunately at work, the picvalley site is a prohibited site, so I'll try to take a look at home on my own kit.


Sharjith Naramparambath's picture

I am interested to see the diff of the work you did. Can you kindly publish it or mail it to

Thanks and Regards
N. Sharjith

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.