| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | #ifndef OSGPRODUCER_VISUAL_CHOOSER |
|---|
| 15 | #define OSGPRODUCER_VISUAL_CHOOSER 1 |
|---|
| 16 | |
|---|
| 17 | #include <vector> |
|---|
| 18 | |
|---|
| 19 | #include <osg/Referenced> |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | namespace osgProducer { |
|---|
| 23 | |
|---|
| 24 | class VisualChooser : public osg::Referenced |
|---|
| 25 | { |
|---|
| 26 | public : |
|---|
| 27 | VisualChooser( void ); |
|---|
| 28 | |
|---|
| 29 | enum AttributeName { |
|---|
| 30 | UseGL, |
|---|
| 31 | BufferSize, |
|---|
| 32 | Level, |
|---|
| 33 | RGBA, |
|---|
| 34 | DoubleBuffer, |
|---|
| 35 | Stereo, |
|---|
| 36 | AuxBuffers, |
|---|
| 37 | RedSize, |
|---|
| 38 | GreenSize, |
|---|
| 39 | BlueSize, |
|---|
| 40 | AlphaSize, |
|---|
| 41 | DepthSize, |
|---|
| 42 | StencilSize, |
|---|
| 43 | AccumRedSize, |
|---|
| 44 | AccumGreenSize, |
|---|
| 45 | AccumBlueSize, |
|---|
| 46 | AccumAlphaSize, |
|---|
| 47 | Samples, |
|---|
| 48 | SampleBuffers |
|---|
| 49 | }; |
|---|
| 50 | #if 0 |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | void setVisual( VisualInfo *vinfo ); |
|---|
| 56 | #endif |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | void setSimpleConfiguration(bool doublebuffer = true); |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | void clear() ; |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | void addAttribute( AttributeName attribute ); |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | void addAttribute( AttributeName attribute, int parameter ); |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | void addExtendedAttribute( unsigned int attribute ); |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | void addExtendedAttribute( unsigned int attribute, int parameter ); |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | bool isDoubleBuffer() const; |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | void setBufferSize( unsigned int size ); |
|---|
| 93 | |
|---|
| 94 | void setLevel( int level ); |
|---|
| 95 | |
|---|
| 96 | void useRGBA(); |
|---|
| 97 | |
|---|
| 98 | void useDoubleBuffer(); |
|---|
| 99 | |
|---|
| 100 | void useStereo(); |
|---|
| 101 | |
|---|
| 102 | void setAuxBuffers( unsigned int num ); |
|---|
| 103 | |
|---|
| 104 | void setRedSize( unsigned int size ); |
|---|
| 105 | |
|---|
| 106 | void setGreenSize( unsigned int size ); |
|---|
| 107 | |
|---|
| 108 | void setBlueSize( unsigned int size ); |
|---|
| 109 | |
|---|
| 110 | void setAlphaSize( unsigned int size ); |
|---|
| 111 | |
|---|
| 112 | void setDepthSize( unsigned int size ); |
|---|
| 113 | |
|---|
| 114 | void setStencilSize( unsigned int size ); |
|---|
| 115 | |
|---|
| 116 | void setAccumRedSize( unsigned int size ); |
|---|
| 117 | |
|---|
| 118 | void setAccumGreenSize( unsigned int size ); |
|---|
| 119 | |
|---|
| 120 | void setAccumBlueSize( unsigned int size ); |
|---|
| 121 | |
|---|
| 122 | void setAccumAlphaSize( unsigned int size ); |
|---|
| 123 | |
|---|
| 124 | void setSampleBuffers( unsigned int size ); |
|---|
| 125 | |
|---|
| 126 | void setSamples( unsigned int size ); |
|---|
| 127 | |
|---|
| 128 | void setVisualID( unsigned int id ); |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | #if 0 |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | VisualInfo *choose( Display *dpy, int screen, bool strict_adherence=false); |
|---|
| 148 | |
|---|
| 149 | unsigned int getVisualID() const; |
|---|
| 150 | |
|---|
| 151 | bool getStrictAdherence(); |
|---|
| 152 | void setStrictAdherence(bool); |
|---|
| 153 | #endif |
|---|
| 154 | |
|---|
| 155 | protected: |
|---|
| 156 | ~VisualChooser(void); |
|---|
| 157 | |
|---|
| 158 | public : |
|---|
| 159 | |
|---|
| 160 | struct VisualAttribute |
|---|
| 161 | { |
|---|
| 162 | unsigned int _attribute; |
|---|
| 163 | bool _has_parameter; |
|---|
| 164 | int _parameter; |
|---|
| 165 | bool _is_extension; |
|---|
| 166 | |
|---|
| 167 | VisualAttribute( AttributeName attribute, int parameter ) : |
|---|
| 168 | _attribute(attribute), |
|---|
| 169 | _has_parameter(true), |
|---|
| 170 | _parameter(parameter), |
|---|
| 171 | _is_extension(false) {} |
|---|
| 172 | |
|---|
| 173 | VisualAttribute( AttributeName attribute ) : |
|---|
| 174 | _attribute(attribute), |
|---|
| 175 | _has_parameter(false), |
|---|
| 176 | _parameter(0), |
|---|
| 177 | _is_extension(false) {} |
|---|
| 178 | |
|---|
| 179 | VisualAttribute( unsigned int attribute, int parameter ) : |
|---|
| 180 | _attribute(attribute), |
|---|
| 181 | _has_parameter(true), |
|---|
| 182 | _parameter(parameter), |
|---|
| 183 | _is_extension(true) {} |
|---|
| 184 | |
|---|
| 185 | VisualAttribute( unsigned int attribute ) : |
|---|
| 186 | _attribute(attribute), |
|---|
| 187 | _has_parameter(false), |
|---|
| 188 | _parameter(0), |
|---|
| 189 | _is_extension(true) {} |
|---|
| 190 | |
|---|
| 191 | unsigned int attribute() const { return _attribute; } |
|---|
| 192 | bool hasParameter() const { return _has_parameter; } |
|---|
| 193 | int parameter() const { return _parameter; } |
|---|
| 194 | bool isExtension() const { return _is_extension; } |
|---|
| 195 | }; |
|---|
| 196 | |
|---|
| 197 | void applyAttribute(const VisualAttribute &va, std::vector<int> &attribs); |
|---|
| 198 | void resetVisualInfo(); |
|---|
| 199 | |
|---|
| 200 | std::vector <VisualAttribute> _visual_attributes; |
|---|
| 201 | |
|---|
| 202 | unsigned int _visual_id; |
|---|
| 203 | bool _strictAdherence; |
|---|
| 204 | }; |
|---|
| 205 | |
|---|
| 206 | } |
|---|
| 207 | #endif |
|---|