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

Method BuildCellTextures

Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx:3862–3920  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

3860
3861//------------------------------------------------------------------------------
3862void vtkOpenGLPolyDataMapper::BuildCellTextures(
3863 vtkRenderer* ren, vtkActor* actor, vtkCellArray* prims[4], int representation)
3864{
3865 // create the cell scalar array adjusted for ogl Cells
3866 std::vector<unsigned char> newColors;
3867 std::vector<float> newNorms;
3868 this->AppendCellTextures(
3869 ren, actor, prims, representation, newColors, newNorms, this->CurrentInput, this->CellCellMap);
3870
3871 // allocate as needed
3872 if (this->HaveCellScalars)
3873 {
3874 if (!this->CellScalarTexture)
3875 {
3876 this->CellScalarTexture = vtkTextureObject::New();
3877 this->CellScalarBuffer = vtkOpenGLBufferObject::New();
3878 this->CellScalarBuffer->SetType(vtkOpenGLBufferObject::TextureBuffer);
3879 }
3880 this->CellScalarTexture->SetContext(static_cast<vtkOpenGLRenderWindow*>(ren->GetVTKWindow()));
3881 this->CellScalarBuffer->Upload(newColors, vtkOpenGLBufferObject::TextureBuffer);
3882 this->CellScalarTexture->CreateTextureBuffer(static_cast<unsigned int>(newColors.size() / 4), 4,
3883 VTK_UNSIGNED_CHAR, this->CellScalarBuffer);
3884 }
3885
3886 if (this->HaveCellNormals)
3887 {
3888 if (!this->CellNormalTexture)
3889 {
3890 this->CellNormalTexture = vtkTextureObject::New();
3891 this->CellNormalBuffer = vtkOpenGLBufferObject::New();
3892 this->CellNormalBuffer->SetType(vtkOpenGLBufferObject::TextureBuffer);
3893 }
3894 this->CellNormalTexture->SetContext(static_cast<vtkOpenGLRenderWindow*>(ren->GetVTKWindow()));
3895
3896 // do we have float texture support ?
3897 int ftex = static_cast<vtkOpenGLRenderWindow*>(ren->GetRenderWindow())
3898 ->GetDefaultTextureInternalFormat(VTK_FLOAT, 4, false, true, false);
3899
3900 if (ftex)
3901 {
3902 this->CellNormalBuffer->Upload(newNorms, vtkOpenGLBufferObject::TextureBuffer);
3903 this->CellNormalTexture->CreateTextureBuffer(
3904 static_cast<unsigned int>(newNorms.size() / 4), 4, VTK_FLOAT, this->CellNormalBuffer);
3905 }
3906 else
3907 {
3908 // have to convert to unsigned char if no float support
3909 std::vector<unsigned char> ucNewNorms;
3910 ucNewNorms.resize(newNorms.size());
3911 for (size_t i = 0; i < newNorms.size(); i++)
3912 {
3913 ucNewNorms[i] = 127.0 * (newNorms[i] + 1.0);
3914 }
3915 this->CellNormalBuffer->Upload(ucNewNorms, vtkOpenGLBufferObject::TextureBuffer);
3916 this->CellNormalTexture->CreateTextureBuffer(static_cast<unsigned int>(newNorms.size() / 4),
3917 4, VTK_UNSIGNED_CHAR, this->CellNormalBuffer);
3918 }
3919 }

Callers 1

BuildBufferObjectsMethod · 0.95

Calls 11

AppendCellTexturesMethod · 0.95
GetVTKWindowMethod · 0.80
CreateTextureBufferMethod · 0.80
NewFunction · 0.50
SetTypeMethod · 0.45
SetContextMethod · 0.45
UploadMethod · 0.45
sizeMethod · 0.45
GetRenderWindowMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected