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
Forums: 

Hi,

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.

See http://www.opencascade.org/org/forum/thread_11428/

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.

Pete

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 http://sourceforge.net/projects/qtocc . Whilst we are integrating Fotis' GEOM port from Salome, the widget hasn't changed much - apart from its class name.

Pete

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->Init();
myViewer->SetZBufferManagment( Standard_False ); //

Pete

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

http://qtocc.svn.sourceforge.net/viewvc/qtocc/ros/src/OpenGl/OpenGl_togl_redraw.c?r1=71&r2=72

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

Pete

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: http://img150.imageshack.us/my.php?image=transparencytu2.png

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.*/
// glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA);
// }

And the result is:
http://www.picvalley.net/v.php?p=u/930/1151738379.PNG

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:
http://www.picvalley.net/v.php?p=u/1117/945017649.PNG
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.

Pete

Sharjith Naramparambath's picture

Hi,
I am interested to see the diff of the work you did. Can you kindly publish it or mail it to sharjith@gmail.com

Thanks and Regards
N. Sharjith