root/OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osg/PolygonOffset.cpp @ 11264

Revision 11264, 2.5 kB (checked in by paulmartz, 4 years ago)

2.8 branch: Mergine recent changes to FBX. Revisions in this commit: r11251, r11252, r11262.

  • Property svn:mergeinfo set to
    /OpenSceneGraph/branches/OpenSceneGraph-2.8.2/src/osg/PolygonOffset.cpp:10664
    /OpenSceneGraph/trunk/src/osg/PolygonOffset.cpp:9769,9816-9818,9826-9827,9837-9843,9847,9850,9854-9857,9860-9861,9865,9869,9879-9880,9885,9895,9906,9910,9912,9932-9933,9948,9959-9960,9965,9968-9969,9990,10010,10012-10014,10030,10040-10041,10053,10057,10076,10079-10080,10082-10084,10088,10128,10149,10161,10208,10264,10283,10340,10391-10392,10408,10414,10417,10422,10440,10456,10487,10491,10520,10538,10622-10623,10625,10671-10672,10697,10722,10753,10758,10761,10788,10805,10809,10818,10851,10853-10855,10858,10887,10891-10892,10914,10923,10925,10932-10933,10938,10941-10942,10945,10961,11019,11032-11035,11056,11111,11123,11127,11131,11159,11165,11173,11175,11177,11180,11182,11194,11203,11237,11251-11252,11262
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under 
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13#include <string.h>
14
15#include <osg/GL>
16#include <osg/PolygonOffset>
17#include <osg/Notify>
18
19using namespace osg;
20
21static float s_FactorMultipler = 1.0f;
22static float s_UnitsMultipler = 1.0f;
23static bool s_MultiplerSet = false;
24
25void PolygonOffset::setFactorMultiplier(float multiplier)
26{
27    s_MultiplerSet = true;
28    s_FactorMultipler = multiplier;
29}
30
31float PolygonOffset::getFactorMultiplier()
32{
33    return s_FactorMultipler;
34}
35
36void PolygonOffset::setUnitsMultiplier(float multiplier)
37{
38    s_MultiplerSet = true;
39    s_UnitsMultipler = multiplier;
40}
41
42float PolygonOffset::getUnitsMultiplier()
43{
44    return s_UnitsMultipler;
45}
46
47bool PolygonOffset::areFactorAndUnitsMultipliersSet()
48{
49    return s_MultiplerSet;
50}
51
52
53void PolygonOffset::setFactorAndUnitsMultipliersUsingBestGuessForDriver()
54{
55    s_MultiplerSet = true;
56    // osg::notify(osg::NOTICE)<<"PolygonOffset::setFactorAndUnitMultipliersUsingBestGuessForDriver()"<<std::endl;
57
58#if 0
59    const GLubyte* renderer = glGetString(GL_RENDERER);
60    if (renderer)
61    {
62        if ((strstr((const char*)renderer,"Radeon")!=0) ||
63            (strstr((const char*)renderer,"RADEON")!=0) ||
64            (strstr((const char*)renderer,"ALL-IN-WONDER")!=0))
65        {
66            setFactorMultiplier(1.0f);
67            setUnitsMultiplier(128.0f);
68            osg::notify(osg::INFO)<<"PolygonOffset::setFactorAndUnitsMultipliersUsingBestGuessForDriver() apply ATI workaround."<<std::endl;
69        }
70    }
71#endif
72}
73
74
75PolygonOffset::PolygonOffset():
76    _factor(0.0f),
77    _units(0.0f)
78{
79}
80
81PolygonOffset::PolygonOffset(float factor, float units):
82    _factor(factor),
83    _units(units)
84{
85}
86
87PolygonOffset::~PolygonOffset()
88{
89}
90
91void PolygonOffset::apply(State&) const
92{
93    if (!s_MultiplerSet) setFactorAndUnitsMultipliersUsingBestGuessForDriver();
94
95    glPolygonOffset(_factor * s_FactorMultipler,
96                    _units * s_UnitsMultipler);
97}
Note: See TracBrowser for help on using the browser.