Description: Create a texture buffer basically a 1D texture that can be very large for passing data into the fragment shader
| 1077 | // Create a texture buffer basically a 1D texture that can be |
| 1078 | // very large for passing data into the fragment shader |
| 1079 | bool vtkTextureObject::CreateTextureBuffer( |
| 1080 | unsigned int numValues, int numComps, int dataType, vtkOpenGLBufferObject* bo) |
| 1081 | { |
| 1082 | assert(this->Context); |
| 1083 | |
| 1084 | // Now, determine texture parameters using the arguments. |
| 1085 | this->GetDataType(dataType); |
| 1086 | this->GetInternalFormat(dataType, numComps, false); |
| 1087 | this->GetFormat(dataType, numComps, false); |
| 1088 | |
| 1089 | if (!this->InternalFormat || !this->Format || !this->Type) |
| 1090 | { |
| 1091 | vtkErrorMacro("Failed to determine texture parameters."); |
| 1092 | return false; |
| 1093 | } |
| 1094 | |
| 1095 | this->Target = GL_TEXTURE_BUFFER; |
| 1096 | this->Components = numComps; |
| 1097 | this->Width = numValues; |
| 1098 | this->Height = 1; |
| 1099 | this->Depth = 1; |
| 1100 | this->NumberOfDimensions = 1; |
| 1101 | this->BufferObject = bo; |
| 1102 | |
| 1103 | this->Context->ActivateTexture(this); |
| 1104 | this->CreateTexture(); |
| 1105 | this->Bind(); |
| 1106 | |
| 1107 | int maxSize = -1; |
| 1108 | this->Context->GetState()->vtkglGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &maxSize); |
| 1109 | if (maxSize > 0 && static_cast<unsigned int>(maxSize) < numValues) |
| 1110 | { |
| 1111 | vtkErrorMacro("Attempt to use a texture buffer exceeding your hardware's limits. " |
| 1112 | "This can happen when trying to color by cell data with a large dataset. " |
| 1113 | "Hardware limit is " |
| 1114 | << maxSize << " values while " << numValues << " was requested."); |
| 1115 | } |
| 1116 | |
| 1117 | // Source texture data from the PBO. |
| 1118 | glTexBuffer(this->Target, this->InternalFormat, this->BufferObject->GetHandle()); |
| 1119 | |
| 1120 | vtkOpenGLCheckErrorMacro("failed at glTexBuffer"); |
| 1121 | |
| 1122 | this->Deactivate(); |
| 1123 | |
| 1124 | return true; |
| 1125 | } |
| 1126 | |
| 1127 | #else |
| 1128 |
no test coverage detected