MCPcopy Create free account
hub / github.com/Kitware/VTK / GetShiftAndScale

Method GetShiftAndScale

Rendering/OpenGL2/vtkTextureObject.cxx:730–778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

728}
729
730void vtkTextureObject::GetShiftAndScale(float& shift, float& scale)
731{
732 shift = 1.0;
733 scale = 1.0;
734
735 // check to see if this is an int format
736 GLenum iresult = this->Context->GetDefaultTextureInternalFormat(
737 vtkGetVTKType(this->Type), this->Components, true, false, this->UseSRGBColorSpace);
738
739 // using an int texture format, no shift scale
740 if (iresult == this->InternalFormat)
741 {
742 return;
743 }
744
745 // for all float type internal formats
746 switch (this->Type)
747 {
748 case GL_BYTE:
749 scale = (VTK_SIGNED_CHAR_MAX - VTK_SIGNED_CHAR_MIN) / 2.0;
750 shift = scale + VTK_SIGNED_CHAR_MIN;
751 break;
752 case GL_UNSIGNED_BYTE:
753 scale = VTK_UNSIGNED_CHAR_MAX;
754 shift = 0.0;
755 break;
756 case GL_SHORT:
757 // this may be off a tad
758 scale = (VTK_SHORT_MAX - VTK_SHORT_MIN) / 2.0;
759 shift = scale + VTK_SHORT_MIN;
760 break;
761 case GL_UNSIGNED_SHORT:
762 scale = VTK_UNSIGNED_SHORT_MAX;
763 shift = 0.0;
764 break;
765 case GL_INT:
766 // this may be off a tad
767 scale = (1.0 * VTK_INT_MAX - VTK_INT_MIN) / 2.0;
768 shift = scale + VTK_INT_MIN;
769 break;
770 case GL_UNSIGNED_INT:
771 scale = static_cast<float>(VTK_UNSIGNED_INT_MAX);
772 shift = 0.0;
773 break;
774 case GL_FLOAT:
775 default:
776 break;
777 }
778}
779
780//------------------------------------------------------------------------------
781unsigned int vtkTextureObject::GetFormat(int vtktype, int numComps, bool shaderSupportsTextureInt)

Callers 1

ExecuteMethod · 0.80

Calls 2

vtkGetVTKTypeFunction · 0.85

Tested by

no test coverage detected