MCPcopy Create free account
hub / github.com/cinder/Cinder / createTextureCubeMapImpl

Method createTextureCubeMapImpl

src/cinder/gl/Texture.cpp:1946–1981  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1944
1945template<typename T>
1946TextureCubeMapRef TextureCubeMap::createTextureCubeMapImpl( const ImageSourceRef &imageSource, const Format &format )
1947{
1948 std::vector<CubeMapFaceRegion> faceRegions;
1949
1950 // Infer the layout based on image aspect ratio
1951 ivec2 imageSize( imageSource->getWidth(), imageSource->getHeight() );
1952 float minDim = (float)std::min( imageSize.x, imageSize.y );
1953 float maxDim = (float)std::max( imageSize.x, imageSize.y );
1954 float aspect = minDim / maxDim;
1955 if( abs( aspect - 1 / 6.0f ) < abs( aspect - 3 / 4.0f ) ) { // closer to 1:6 than to 4:3, so row or column
1956 faceRegions = ( imageSize.x > imageSize.y ) ? calcCubeMapHorizontalRegions( imageSource ) : calcCubeMapVerticalRegions( imageSource );
1957 }
1958 else { // else, horizontal or vertical cross
1959 faceRegions = ( imageSize.x > imageSize.y ) ? calcCubeMapHorizontalCrossRegions( imageSource ) : calcCubeMapVerticalCrossRegions( imageSource );
1960 }
1961
1962 Area faceArea = faceRegions.front().mArea;
1963 ivec2 faceSize = faceArea.getSize();
1964
1965 SurfaceT<T> masterSurface( imageSource, SurfaceConstraintsDefault() );
1966 SurfaceT<T> images[6];
1967
1968 for( uint8_t f = 0; f < 6; ++f ) {
1969 images[f] = SurfaceT<T>( faceSize.x, faceSize.y, masterSurface.hasAlpha(), SurfaceConstraints() );
1970 images[f].copyFrom( masterSurface, faceRegions[f].mArea, faceRegions[f].mOffset );
1971 if( faceRegions[f].mFlip ) {
1972 ip::flipVertical( &images[f] );
1973 ip::flipHorizontal( &images[f] );
1974 }
1975 }
1976
1977 if( format.mDeleter )
1978 return TextureCubeMapRef( new TextureCubeMap( images, format ), format.mDeleter );
1979 else
1980 return TextureCubeMapRef( new TextureCubeMap( images, format ) );
1981}
1982
1983TextureCubeMapRef TextureCubeMap::create( const ImageSourceRef images[6], const Format &format )
1984{

Callers

nothing calls this directly

Calls 15

absFunction · 0.85
flipVerticalFunction · 0.85
flipHorizontalFunction · 0.85
minFunction · 0.50
maxFunction · 0.50
getWidthMethod · 0.45
getHeightMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected