root/OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osg/PolygonOffset.cpp
@
11264
| Revision 11264, 2.5 kB (checked in by paulmartz, 3 years ago) | |
|---|---|
|
|
| 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 | |
| 19 | using namespace osg; |
| 20 | |
| 21 | static float s_FactorMultipler = 1.0f; |
| 22 | static float s_UnitsMultipler = 1.0f; |
| 23 | static bool s_MultiplerSet = false; |
| 24 | |
| 25 | void PolygonOffset::setFactorMultiplier(float multiplier) |
| 26 | { |
| 27 | s_MultiplerSet = true; |
| 28 | s_FactorMultipler = multiplier; |
| 29 | } |
| 30 | |
| 31 | float PolygonOffset::getFactorMultiplier() |
| 32 | { |
| 33 | return s_FactorMultipler; |
| 34 | } |
| 35 | |
| 36 | void PolygonOffset::setUnitsMultiplier(float multiplier) |
| 37 | { |
| 38 | s_MultiplerSet = true; |
| 39 | s_UnitsMultipler = multiplier; |
| 40 | } |
| 41 | |
| 42 | float PolygonOffset::getUnitsMultiplier() |
| 43 | { |
| 44 | return s_UnitsMultipler; |
| 45 | } |
| 46 | |
| 47 | bool PolygonOffset::areFactorAndUnitsMultipliersSet() |
| 48 | { |
| 49 | return s_MultiplerSet; |
| 50 | } |
| 51 | |
| 52 | |
| 53 | void 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 | |
| 75 | PolygonOffset::PolygonOffset(): |
| 76 | _factor(0.0f), |
| 77 | _units(0.0f) |
| 78 | { |
| 79 | } |
| 80 | |
| 81 | PolygonOffset::PolygonOffset(float factor, float units): |
| 82 | _factor(factor), |
| 83 | _units(units) |
| 84 | { |
| 85 | } |
| 86 | |
| 87 | PolygonOffset::~PolygonOffset() |
| 88 | { |
| 89 | } |
| 90 | |
| 91 | void 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.
