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

Revision 11208, 2.5 kB (checked in by paulmartz, 5 years ago)

Merge 10664 to 2.8 branch (MSFBO workaround for OS X).

  • Property svn:mergeinfo set to
    /OpenSceneGraph/branches/OpenSceneGraph-2.8.2/src/osg/PolygonOffset.cpp:10664
    /OpenSceneGraph/trunk/src/osg/PolygonOffset.cpp:10083-10084
  • 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.