Changeset 11830
- Timestamp:
- 10/08/10 13:20:56 (3 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 4 modified
-
include/osg/GLU (modified) (1 diff)
-
include/osg/Texture3D (modified) (2 diffs)
-
src/osg/Texture3D.cpp (modified) (4 diffs)
-
src/osg/glu/libutil/mipmap.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osg/GLU
r11829 r11830 68 68 extern OSG_EXPORT GLint gluBuild2DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); 69 69 extern OSG_EXPORT GLint gluBuild2DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data); 70 extern OSG_EXPORT GLint gluBuild3DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); 71 extern OSG_EXPORT GLint gluBuild3DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); 70 71 typedef void (GL_APIENTRY * GLTexImage3DProc) ( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); 72 73 /** Small variation on normal gluBuild3DMipmapLevels as we pass in the function pointer to glTexImage3D rather than rely on GLU style querry for this functon pointer.*/ 74 extern OSG_EXPORT GLint gluBuild3DMipmapLevels (GLTexImage3DProc glTextImage3DProc, GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); 75 76 /** Small variation on normal gluBuild3DMipmapLevels as we pass in the function pointer to glTexImage3D rather than rely on GLU style querry for this functon pointer.*/ 77 extern OSG_EXPORT GLint gluBuild3DMipmaps (GLTexImage3DProc glTextImage3DProc, GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); 72 78 73 79 /* ErrorCode */ -
OpenSceneGraph/trunk/include/osg/Texture3D
r11823 r11830 161 161 GLint maxTexture3DSize() const { return _maxTexture3DSize; } 162 162 163 void glTexImage3D( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) const; 164 void glTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels) const; 165 void glCopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) const; 166 167 bool isCompressedTexImage3DSupported() const { return _glCompressedTexImage3D!=0; } 168 void glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data) const; 169 170 bool isCompressedTexSubImage3DSupported() const { return _glCompressedTexSubImage3D!=0; } 171 void glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ) const; 172 173 void gluBuild3DMipmaps( GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *data) const; 174 175 protected: 176 177 ~Extensions() {} 178 179 bool _isTexture3DSupported; 180 bool _isTexture3DFast; 181 GLint _maxTexture3DSize; 163 bool isCompressedTexImage3DSupported() const { return glCompressedTexImage3D!=0; } 164 165 bool isCompressedTexSubImage3DSupported() const { return glCompressedTexSubImage3D!=0; } 182 166 183 167 typedef void (GL_APIENTRY * GLTexImage3DProc) ( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); … … 186 170 typedef void (GL_APIENTRY * CompressedTexSubImage3DArbProc) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); 187 171 typedef void (GL_APIENTRY * GLCopyTexSubImageProc) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ); 188 typedef void (GL_APIENTRY * GLUBuild3DMipMapsProc) ( GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *data); 189 190 GLTexImage3DProc _glTexImage3D; 191 GLTexSubImage3DProc _glTexSubImage3D; 192 CompressedTexImage3DArbProc _glCompressedTexImage3D; 193 CompressedTexSubImage3DArbProc _glCompressedTexSubImage3D; 194 GLCopyTexSubImageProc _glCopyTexSubImage3D; 195 GLUBuild3DMipMapsProc _gluBuild3DMipmaps; 196 172 173 GLTexImage3DProc glTexImage3D; 174 GLTexSubImage3DProc glTexSubImage3D; 175 CompressedTexImage3DArbProc glCompressedTexImage3D; 176 CompressedTexSubImage3DArbProc glCompressedTexSubImage3D; 177 GLCopyTexSubImageProc glCopyTexSubImage3D; 178 179 protected: 180 181 ~Extensions() {} 182 183 bool _isTexture3DSupported; 184 bool _isTexture3DFast; 185 GLint _maxTexture3DSize; 197 186 }; 198 187 -
OpenSceneGraph/trunk/src/osg/Texture3D.cpp
r11808 r11830 428 428 numMipmapLevels = 1; 429 429 430 extensions->gluBuild3DMipmaps( target, _internalFormat, 431 image->s(),image->t(),image->r(), 432 (GLenum)image->getPixelFormat(), (GLenum)image->getDataType(), 433 image->data() ); 430 gluBuild3DMipmaps( extensions->glTexImage3D, 431 target, _internalFormat, 432 image->s(),image->t(),image->r(), 433 (GLenum)image->getPixelFormat(), (GLenum)image->getDataType(), 434 image->data() ); 434 435 435 436 } … … 579 580 _maxTexture3DSize = rhs._maxTexture3DSize; 580 581 581 _glTexImage3D = rhs._glTexImage3D; 582 _glTexSubImage3D = rhs._glTexSubImage3D; 583 _glCopyTexSubImage3D = rhs._glCopyTexSubImage3D; 584 _gluBuild3DMipmaps = rhs._gluBuild3DMipmaps; 582 glTexImage3D = rhs.glTexImage3D; 583 glTexSubImage3D = rhs.glTexSubImage3D; 584 glCompressedTexImage3D = rhs.glCompressedTexImage3D; 585 glCompressedTexSubImage3D = rhs.glCompressedTexSubImage3D; 586 glCopyTexSubImage3D = rhs.glCopyTexSubImage3D; 585 587 } 586 588 … … 591 593 if (rhs._maxTexture3DSize<_maxTexture3DSize) _maxTexture3DSize = rhs._maxTexture3DSize; 592 594 593 if (!rhs._glTexImage3D) _glTexImage3D = 0; 594 if (!rhs._glTexSubImage3D) _glTexSubImage3D = 0; 595 if (!rhs._glCompressedTexImage3D) _glTexImage3D = 0; 596 if (!rhs._glCompressedTexSubImage3D) _glTexSubImage3D = 0; 597 if (!rhs._glCopyTexSubImage3D) _glCopyTexSubImage3D = 0; 598 if (!rhs._gluBuild3DMipmaps) _gluBuild3DMipmaps = 0; 595 if (!rhs.glTexImage3D) glTexImage3D = 0; 596 if (!rhs.glTexSubImage3D) glTexSubImage3D = 0; 597 if (!rhs.glCompressedTexImage3D) glCompressedTexImage3D = 0; 598 if (!rhs.glCompressedTexSubImage3D) glCompressedTexSubImage3D = 0; 599 if (!rhs.glCopyTexSubImage3D) glCopyTexSubImage3D = 0; 599 600 } 600 601 … … 608 609 glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &_maxTexture3DSize); 609 610 610 setGLExtensionFuncPtr(_glTexImage3D,"glTexImage3D","glTexImage3DEXT"); 611 setGLExtensionFuncPtr(_glTexSubImage3D,"glTexSubImage3D","glTexSubImage3DEXT"); 612 setGLExtensionFuncPtr(_glCompressedTexImage3D,"glCompressedTexImage3D","glCompressedTexImage3DARB"); 613 setGLExtensionFuncPtr(_glCompressedTexSubImage3D,"glCompressedTexSubImage3D","glCompressedTexSubImage3DARB"); 614 setGLExtensionFuncPtr(_glCopyTexSubImage3D,"glCopyTexSubImage3D","glCopyTexSubImage3DEXT"); 615 setGLExtensionFuncPtr(_gluBuild3DMipmaps,"gluBuild3DMipmaps"); 616 617 } 618 619 void Texture3D::Extensions::glTexImage3D( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) const 620 { 621 // ::glTexImage3D( target, level, internalFormat, width, height, depth, border, format, type, pixels); 622 if (_glTexImage3D) 623 { 624 _glTexImage3D( target, level, internalFormat, width, height, depth, border, format, type, pixels); 625 } 626 else 627 { 628 OSG_WARN<<"Error: glTexImage3D not supported by OpenGL driver"<<std::endl; 629 } 630 } 631 632 void Texture3D::Extensions::glTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels) const 633 { 634 // ::glTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); 635 if (_glTexSubImage3D) 636 { 637 _glTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); 638 } 639 else 640 { 641 OSG_WARN<<"Error: glTexSubImage3D not supported by OpenGL driver"<<std::endl; 642 } 643 } 644 645 void Texture3D::Extensions::glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data) const 646 { 647 if (_glCompressedTexImage3D) 648 { 649 _glCompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data); 650 } 651 else 652 { 653 OSG_WARN<<"Error: glCompressedTexImage3D not supported by OpenGL driver"<<std::endl; 654 } 655 } 656 657 void Texture3D::Extensions::glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ) const 658 { 659 if (_glCompressedTexSubImage3D) 660 { 661 _glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); 662 } 663 else 664 { 665 OSG_WARN<<"Error: glCompressedTexImage2D not supported by OpenGL driver"<<std::endl; 666 } 667 } 668 669 void Texture3D::Extensions::glCopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) const 670 { 671 // ::glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height); 672 if (_glCopyTexSubImage3D) 673 { 674 _glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height); 675 } 676 else 677 { 678 OSG_WARN<<"Error: glCopyTexSubImage3D not supported by OpenGL driver"<<std::endl; 679 } 680 } 681 682 void Texture3D::Extensions::gluBuild3DMipmaps( GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *data) const 683 { 684 // ::gluBuild3DMipmaps(target, internalFormat, width, height, depth, format, type, data); 685 if (_gluBuild3DMipmaps) 686 { 687 _gluBuild3DMipmaps(target, internalFormat, width, height, depth, format, type, data); 688 } 689 else 690 { 691 OSG_WARN<<"Error: gluBuild3DMipmaps not supported by OpenGL driver"<<std::endl; 692 } 693 } 611 setGLExtensionFuncPtr(glTexImage3D,"glTexImage3D","glTexImage3DEXT"); 612 setGLExtensionFuncPtr(glTexSubImage3D,"glTexSubImage3D","glTexSubImage3DEXT"); 613 setGLExtensionFuncPtr(glCompressedTexImage3D,"glCompressedTexImage3D","glCompressedTexImage3DARB"); 614 setGLExtensionFuncPtr(glCompressedTexSubImage3D,"glCompressedTexSubImage3D","glCompressedTexSubImage3DARB"); 615 setGLExtensionFuncPtr(glCopyTexSubImage3D,"glCopyTexSubImage3D","glCopyTexSubImage3DEXT"); 616 617 } -
OpenSceneGraph/trunk/src/osg/glu/libutil/mipmap.cpp
r11829 r11830 74 74 GLenum, GLenum, GLint, GLint, GLint, 75 75 const void *); 76 static int gluBuild3DMipmapLevelsCore(GL enum, GLint,76 static int gluBuild3DMipmapLevelsCore(GLTexImage3DProc gluTexImage3D, GLenum, GLint, 77 77 GLsizei, GLsizei, GLsizei, 78 78 GLsizei, GLsizei, GLsizei, … … 6635 6635 } 6636 6636 } /* halve1DimagePackedPixel() */ 6637 6638 /*===========================================================================*/6639 6640 // Note from Robert Osfield, follows is a quick hack to windows compiling, will need to6641 // reactor code to properly manage extension checking platforms/GL targets.6642 #if defined(_WIN32) || defined(__WIN32__)6643 #define RESOLVE_3D_TEXTURE_SUPPORT6644 #endif6645 6646 #ifdef RESOLVE_3D_TEXTURE_SUPPORT6647 /*6648 * This section ensures that GLU 1.3 will load and run on6649 * a GL 1.1 implementation. It dynamically resolves the6650 * call to glTexImage3D() which might not be available.6651 * Or is it might be supported as an extension.6652 * Contributed by Gerk Huisma <gerk@five-d.demon.nl>.6653 */6654 6655 typedef void (GLAPIENTRY *TexImage3Dproc)( GLenum target, GLint level,6656 GLenum internalFormat,6657 GLsizei width, GLsizei height,6658 GLsizei depth, GLint border,6659 GLenum format, GLenum type,6660 const GLvoid *pixels );6661 6662 static TexImage3Dproc pTexImage3D = 0;6663 6664 #if !defined(_WIN32) && !defined(__WIN32__)6665 # include <dlfcn.h>6666 # include <sys/types.h>6667 #else6668 #include <windows.h>6669 WINGDIAPI PROC WINAPI wglGetProcAddress(LPCSTR);6670 #endif6671 6672 static void gluTexImage3D( GLenum target, GLint level,6673 GLenum internalFormat,6674 GLsizei width, GLsizei height,6675 GLsizei depth, GLint border,6676 GLenum format, GLenum type,6677 const GLvoid *pixels )6678 {6679 if (!pTexImage3D) {6680 #if defined(_WIN32) || defined(__WIN32__)6681 pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3D");6682 if (!pTexImage3D)6683 pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3DEXT");6684 #else6685 void *libHandle = dlopen("libgl.so", RTLD_LAZY);6686 pTexImage3D = TexImage3Dproc) dlsym(libHandle, "glTexImage3D" );6687 if (!pTexImage3D)6688 pTexImage3D = (TexImage3Dproc) dlsym(libHandle,"glTexImage3DEXT");6689 dlclose(libHandle);6690 #endif6691 }6692 6693 /* Now call glTexImage3D */6694 if (pTexImage3D)6695 pTexImage3D(target, level, internalFormat, width, height,6696 depth, border, format, type, pixels);6697 }6698 6699 #else6700 6701 /* Only bind to a GL 1.2 implementation: */6702 #define gluTexImage3D glTexImage3D6703 6704 #endif6705 6637 6706 6638 static GLint imageSize3D(GLint width, GLint height, GLint depth, … … 7443 7375 7444 7376 7445 static void closestFit3D(GLenum target, GLint width, GLint height, GLint depth, 7377 static void closestFit3D(GLTexImage3DProc gluTexImage3D, 7378 GLenum target, GLint width, GLint height, GLint depth, 7446 7379 GLint internalFormat, GLenum format, GLenum type, 7447 7380 GLint *newWidth, GLint *newHeight, GLint *newDepth) … … 7753 7686 } /* halveImagePackedPixel3D() */ 7754 7687 7755 static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat, 7688 static int gluBuild3DMipmapLevelsCore(GLTexImage3DProc gluTexImage3D, 7689 GLenum target, GLint internalFormat, 7756 7690 GLsizei width, 7757 7691 GLsizei height, … … 8476 8410 } /* gluBuild3DMipmapLevelsCore() */ 8477 8411 8478 GLint GLAPIENTRY 8479 gluBuild3DMipmapLevels(GLenum target, GLint internalFormat,8480 GLsizei width, GLsizei height, GLsizei depth,8481 GLenum format, GLenum type,8482 GLint userLevel, GLint baseLevel, GLint maxLevel,8483 const void *data)8412 GLint GLAPIENTRY gluBuild3DMipmapLevels(GLTexImage3DProc gluTexImage3D, 8413 GLenum target, GLint internalFormat, 8414 GLsizei width, GLsizei height, GLsizei depth, 8415 GLenum format, GLenum type, 8416 GLint userLevel, GLint baseLevel, GLint maxLevel, 8417 const void *data) 8484 8418 { 8485 8419 int level, levels; … … 8506 8440 return GLU_INVALID_VALUE; 8507 8441 8508 return gluBuild3DMipmapLevelsCore( target, internalFormat,8442 return gluBuild3DMipmapLevelsCore(gluTexImage3D, target, internalFormat, 8509 8443 width, height, depth, 8510 8444 width, height, depth, … … 8514 8448 } /* gluBuild3DMipmapLevels() */ 8515 8449 8516 GLint GLAPIENTRY 8517 gluBuild3DMipmaps(GLenum target, GLint internalFormat,8518 GLsizei width, GLsizei height, GLsizei depth,8519 GLenum format, GLenum type, const void *data)8450 GLint GLAPIENTRY gluBuild3DMipmaps(GLTexImage3DProc gluTexImage3D, 8451 GLenum target, GLint internalFormat, 8452 GLsizei width, GLsizei height, GLsizei depth, 8453 GLenum format, GLenum type, const void *data) 8520 8454 { 8521 8455 GLint widthPowerOf2, heightPowerOf2, depthPowerOf2; … … 8533 8467 } 8534 8468 8535 closestFit3D( target,width,height,depth,internalFormat,format,type,8469 closestFit3D(gluTexImage3D, target,width,height,depth,internalFormat,format,type, 8536 8470 &widthPowerOf2,&heightPowerOf2,&depthPowerOf2); 8537 8471 … … 8542 8476 if (level > levels) levels=level; 8543 8477 8544 return gluBuild3DMipmapLevelsCore( target, internalFormat,8478 return gluBuild3DMipmapLevelsCore(gluTexImage3D, target, internalFormat, 8545 8479 width, height, depth, 8546 8480 widthPowerOf2, heightPowerOf2,
