00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045
00046 #include <OSGConfig.h>
00047
00048 #include <OSGGLEXT.h>
00049
00050 #include "OSGDrawActionBase.h"
00051 #include "OSGWindow.h"
00052
00053 #include "OSGPointChunk.h"
00054
00055 OSG_USING_NAMESPACE
00056
00074
00075
00076
00077
00078 StateChunkClass PointChunk::_class("Point");
00079
00080 UInt32 PointChunk::_arbPointParameters;
00081 UInt32 PointChunk::_nvPointSprite;
00082 UInt32 PointChunk::_funcPointParameterf;
00083 UInt32 PointChunk::_funcPointParameterfv;
00084
00085
00086
00087
00088
00089 void PointChunk::initMethod (void)
00090 {
00091 }
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 #ifndef GL_VERSION_1_4
00105 # define GL_FUNC_POINT_PARAMETERF OSG_DLSYM_UNDERSCORE"glPointParameterfEXT"
00106 # define GL_FUNC_POINT_PARAMETERFV OSG_DLSYM_UNDERSCORE"glPointParameterfvEXT"
00107 #else
00108 # define GL_FUNC_POINT_PARAMETERF OSG_DLSYM_UNDERSCORE"glPointParameterf"
00109 # define GL_FUNC_POINT_PARAMETERFV OSG_DLSYM_UNDERSCORE"glPointParameterfv"
00110 #endif
00111
00112
00113 PointChunk::PointChunk(void) :
00114 Inherited()
00115 {
00116 _arbPointParameters =
00117 Window::registerExtension("GL_EXT_point_parameters");
00118 _nvPointSprite =
00119 Window::registerExtension("GL_NV_point_sprite");
00120 _funcPointParameterf = Window::registerFunction(
00121 GL_FUNC_POINT_PARAMETERF, _arbPointParameters, 0x0104);
00122 _funcPointParameterfv = Window::registerFunction(
00123 GL_FUNC_POINT_PARAMETERFV, _arbPointParameters, 0x0104);
00124 }
00125
00126 PointChunk::PointChunk(const PointChunk &source) :
00127 Inherited(source)
00128 {
00129 }
00130
00131 PointChunk::~PointChunk(void)
00132 {
00133 }
00134
00135
00136
00137 const StateChunkClass *PointChunk::getClass(void) const
00138 {
00139 return &_class;
00140 }
00141
00142
00143
00144 void PointChunk::changed(BitVector whichField, UInt32 origin)
00145 {
00146 Inherited::changed(whichField, origin);
00147 }
00148
00149 void PointChunk::dump( UInt32 ,
00150 const BitVector ) const
00151 {
00152 SLOG << "Dump PointChunk NI" << std::endl;
00153 }
00154
00155
00156
00157 void PointChunk::activate(DrawActionBase *action, UInt32)
00158 {
00159 if(getSize() != 1.f)
00160 glPointSize(getSize());
00161
00162 if(getSmooth())
00163 glEnable(GL_POINT_SMOOTH);
00164
00165 #if GL_ARB_point_parameters
00166 if(getMinSize() >= 0.f)
00167 {
00168 if(action->getWindow()->hasExtension(_arbPointParameters))
00169 {
00170
00171 void (OSG_APIENTRY*pointparameterf)(GLenum pname, GLfloat param) =
00172 (void (OSG_APIENTRY*)(GLenum pname, GLfloat param))
00173 action->getWindow()->getFunction( _funcPointParameterf );
00174
00175 void (OSG_APIENTRY*pointparameterfv)(GLenum pname,
00176 const GLfloat *param) =
00177 (void (OSG_APIENTRY*)(GLenum pname, const GLfloat *param))
00178 action->getWindow()->getFunction( _funcPointParameterfv );
00179
00180 pointparameterf(GL_POINT_SIZE_MIN_ARB, getMinSize());
00181 pointparameterf(GL_POINT_SIZE_MAX_ARB, getMaxSize());
00182 pointparameterf(GL_POINT_FADE_THRESHOLD_SIZE_ARB,
00183 getFadeThreshold());
00184
00185 GLfloat att[3] = { getConstantAttenuation(),
00186 getLinearAttenuation(),
00187 getQuadraticAttenuation() };
00188
00189 pointparameterfv(GL_POINT_DISTANCE_ATTENUATION_ARB, att);
00190 }
00191
00192 }
00193 #endif
00194
00195 #if GL_NV_point_sprite
00196 if(getSprite())
00197 {
00198 if(action->getWindow()->hasExtension(_nvPointSprite))
00199 {
00200
00201 void (OSG_APIENTRY*pointparameterf)(GLenum pname, GLfloat param) =
00202 (void (OSG_APIENTRY*)(GLenum pname, GLfloat param))
00203 action->getWindow()->getFunction( _funcPointParameterf );
00204
00205 pointparameterf(GL_POINT_SPRITE_R_MODE_NV, Real32(getRMode()));
00206
00207 glEnable(GL_POINT_SPRITE_NV);
00208 }
00209
00210 }
00211 #endif
00212
00213 #if ! defined(GL_ARB_point_parameters) && ! defined(GL_NV_point_sprite)
00214 action;
00215 #endif
00216 }
00217
00218 void PointChunk::changeFrom( DrawActionBase *action,
00219 StateChunk * old_chunk,
00220 UInt32 )
00221 {
00222 PointChunk *old = dynamic_cast<PointChunk *>(old_chunk);
00223
00224 if(getSize() != old->getSize())
00225 glPointSize(getSize());
00226
00227 if(getSmooth() && !old->getSmooth())
00228 {
00229 glEnable(GL_POINT_SMOOTH);
00230 }
00231 else if(!getSmooth() && old->getSmooth())
00232 {
00233 glDisable(GL_POINT_SMOOTH);
00234 }
00235
00236 #if GL_ARB_point_parameters
00237 if(getMinSize() >= 0.f)
00238 {
00239 if(action->getWindow()->hasExtension(_arbPointParameters))
00240 {
00241
00242 void (OSG_APIENTRY*pointparameterf)(GLenum pname, GLfloat param) =
00243 (void (OSG_APIENTRY*)(GLenum pname, GLfloat param))
00244 action->getWindow()->getFunction( _funcPointParameterf );
00245
00246 void (OSG_APIENTRY*pointparameterfv)(GLenum pname,
00247 const GLfloat *param) =
00248 (void (OSG_APIENTRY*)(GLenum pname, const GLfloat *param))
00249 action->getWindow()->getFunction( _funcPointParameterfv );
00250
00251 pointparameterf(GL_POINT_SIZE_MIN_ARB, getMinSize());
00252 pointparameterf(GL_POINT_SIZE_MAX_ARB, getMaxSize());
00253 pointparameterf(GL_POINT_FADE_THRESHOLD_SIZE_ARB,
00254 getFadeThreshold());
00255
00256 GLfloat att[3] = { getConstantAttenuation(),
00257 getLinearAttenuation(),
00258 getQuadraticAttenuation() };
00259
00260 pointparameterfv(GL_POINT_DISTANCE_ATTENUATION_ARB, att);
00261 }
00262
00263 }
00264 else if(old->getMinSize() >= 0.f)
00265 {
00266 if(action->getWindow()->hasExtension(_arbPointParameters))
00267 {
00268
00269 void (OSG_APIENTRY*pointparameterf)(GLenum pname, GLfloat param) =
00270 (void (OSG_APIENTRY*)(GLenum pname, GLfloat param))
00271 action->getWindow()->getFunction( _funcPointParameterf );
00272
00273 void (OSG_APIENTRY*pointparameterfv)(GLenum pname,
00274 const GLfloat *param) =
00275 (void (OSG_APIENTRY*)(GLenum pname, const GLfloat *param))
00276 action->getWindow()->getFunction( _funcPointParameterfv );
00277
00278 pointparameterf(GL_POINT_SIZE_MIN_ARB, 0);
00279 pointparameterf(GL_POINT_SIZE_MAX_ARB, 1e10);
00280 pointparameterf(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 1);
00281
00282 GLfloat att[3] = { 1, 0, 0 };
00283
00284 pointparameterfv(GL_POINT_DISTANCE_ATTENUATION_ARB, att);
00285 }
00286 }
00287 #endif
00288
00289 #if GL_NV_point_sprite
00290 if(getSprite() && !old->getSprite())
00291 {
00292 if(action->getWindow()->hasExtension(_nvPointSprite))
00293 {
00294
00295 void (OSG_APIENTRY*pointparameterf)(GLenum pname, GLfloat param) =
00296 (void (OSG_APIENTRY*)(GLenum pname, GLfloat param))
00297 action->getWindow()->getFunction( _funcPointParameterf );
00298
00299 pointparameterf(GL_POINT_SPRITE_R_MODE_NV, Real32(getRMode()));
00300
00301 glEnable(GL_POINT_SPRITE_NV);
00302 }
00303
00304 }
00305 else if(!getSprite() && old->getSprite())
00306 {
00307 if(action->getWindow()->hasExtension(_nvPointSprite))
00308 {
00309 glDisable(GL_POINT_SPRITE_NV);
00310 }
00311
00312 }
00313 #endif
00314
00315 #if ! defined(GL_ARB_point_parameters) && ! defined(GL_NV_point_sprite)
00316 action;
00317 #endif
00318 }
00319
00320 void PointChunk::deactivate ( DrawActionBase *action, UInt32 )
00321 {
00322 if(getSize() != 1.f)
00323 glPointSize(1.f);
00324
00325 if(getSmooth())
00326 glDisable(GL_POINT_SMOOTH);
00327
00328 #if GL_ARB_point_parameters
00329 if(getMinSize() >= 0.f)
00330 {
00331 if(action->getWindow()->hasExtension(_arbPointParameters))
00332 {
00333
00334 void (OSG_APIENTRY*pointparameterf)(GLenum pname, GLfloat param) =
00335 (void (OSG_APIENTRY*)(GLenum pname, GLfloat param))
00336 action->getWindow()->getFunction( _funcPointParameterf );
00337
00338 void (OSG_APIENTRY*pointparameterfv)(GLenum pname,
00339 const GLfloat *param) =
00340 (void (OSG_APIENTRY*)(GLenum pname, const GLfloat *param))
00341 action->getWindow()->getFunction( _funcPointParameterfv );
00342
00343 pointparameterf(GL_POINT_SIZE_MIN_ARB, 0);
00344 pointparameterf(GL_POINT_SIZE_MAX_ARB, 1e10);
00345 pointparameterf(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 1);
00346
00347 GLfloat att[3] = { 1, 0, 0 };
00348
00349 pointparameterfv(GL_POINT_DISTANCE_ATTENUATION_ARB, att);
00350 }
00351
00352 }
00353 #endif
00354
00355 #if GL_NV_point_sprite
00356 if(getSprite())
00357 {
00358 if(action->getWindow()->hasExtension(_nvPointSprite))
00359 {
00360 glDisable(GL_POINT_SPRITE_NV);
00361 }
00362
00363 }
00364 #endif
00365
00366 #if ! defined(GL_ARB_point_parameters) && ! defined(GL_NV_point_sprite)
00367 action;
00368 #endif
00369 }
00370
00371
00372
00373 bool PointChunk::isTransparent(void) const
00374 {
00375 return getMinSize() >= 0.f;
00376 }
00377
00378 Real32 PointChunk::switchCost(StateChunk *)
00379 {
00380 return 0;
00381 }
00382
00383 bool PointChunk::operator < (const StateChunk &other) const
00384 {
00385 return this < &other;
00386 }
00387
00388 bool PointChunk::operator == (const StateChunk &other) const
00389 {
00390 PointChunk const *tother = dynamic_cast<PointChunk const*>(&other);
00391
00392 if(!tother)
00393 return false;
00394
00395 if(tother == this)
00396 return true;
00397
00398 if(getSize() != tother->getSize() ||
00399 getSmooth() != tother->getSmooth() ||
00400 getMinSize() != tother->getMinSize() ||
00401 getMaxSize() != tother->getMaxSize() ||
00402 getConstantAttenuation() != tother->getConstantAttenuation() ||
00403 getLinearAttenuation() != tother->getLinearAttenuation() ||
00404 getQuadraticAttenuation() != tother->getQuadraticAttenuation() ||
00405 getFadeThreshold() != tother->getFadeThreshold() ||
00406 getSprite() != tother->getSprite() ||
00407 getRMode() != tother->getRMode()
00408 )
00409 return false;
00410
00411 return true;
00412 }
00413
00414 bool PointChunk::operator != (const StateChunk &other) const
00415 {
00416 return ! (*this == other);
00417 }
00418
00419
00420
00421
00422
00423
00424 #ifdef OSG_SGI_CC
00425 #pragma set woff 1174
00426 #endif
00427
00428 #ifdef OSG_LINUX_ICC
00429 #pragma warning( disable : 177 )
00430 #endif
00431
00432 namespace
00433 {
00434 static Char8 cvsid_cpp [] = "@(#)$Id: $";
00435 static Char8 cvsid_hpp [] = OSGPOINTCHUNKBASE_HEADER_CVSID;
00436 static Char8 cvsid_inl [] = OSGPOINTCHUNKBASE_INLINE_CVSID;
00437
00438 static Char8 cvsid_fields_hpp[] = OSGPOINTCHUNKFIELDS_HEADER_CVSID;
00439 }
00440
00441 #ifdef __sgi
00442 #pragma reset woff 1174
00443 #endif
00444