MCPcopy Create free account
hub / github.com/OGRECave/ogre / _createGLTexResource

Method _createGLTexResource

RenderSystems/GLES2/src/OgreGLES2Texture.cpp:74–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72 }
73
74 void GLES2Texture::_createGLTexResource()
75 {
76 const RenderSystemCapabilities *renderCaps =
77 Root::getSingleton().getRenderSystem()->getCapabilities();
78
79 const bool nonPowerOfTwoSupported = renderCaps->hasCapability(RSC_NON_POWER_OF_2_TEXTURES) ||
80 ( renderCaps->getNonPOW2TexturesLimited() &&
81 mNumRequestedMipmaps == 0 );
82
83 if( !nonPowerOfTwoSupported )
84 {
85 // Convert to nearest power-of-two size if required
86 mWidth = Bitwise::firstPO2From(mWidth);
87 mHeight = Bitwise::firstPO2From(mHeight);
88 mDepth = Bitwise::firstPO2From(mDepth);
89 }
90
91 // set HardwareBuffer::Usage for TU_RENDERTARGET if nothing else specified
92 if((mUsage & TU_RENDERTARGET) && (mUsage & ~TU_RENDERTARGET) == 0)
93 mUsage |= HardwareBuffer::HBU_DYNAMIC;
94
95 // Adjust format if required
96 mFormat = TextureManager::getSingleton().getNativeFormat(mTextureType, mFormat, mUsage);
97
98 if(mFormat == PF_BYTE_RGB && mHwGamma)
99 mFormat = PF_BYTE_RGBA; // we want a colour renderable format for mipmaps, so switch to RGBA
100
101 GLenum texTarget = getGLES2TextureTarget();
102
103 // Generate texture name
104 OGRE_CHECK_GL_ERROR(glGenTextures(1, &mTextureID));
105
106 // Set texture type
107 mRenderSystem->_getStateCacheManager()->bindGLTexture(texTarget, mTextureID);
108
109 if (renderCaps->hasCapability(RSC_DEBUG))
110 OGRE_CHECK_GL_ERROR(glLabelObjectEXT(GL_TEXTURE, mTextureID, -1, mName.c_str()));
111
112 // If we can do automip generation and the user desires this, do so
113 mMipmapsHardwareGenerated = !PixelUtil::isCompressed(mFormat);
114
115 // glGenerateMipmap require all mip levels to be prepared. So override how many this texture has.
116 if((mUsage & TU_AUTOMIPMAP) && mMipmapsHardwareGenerated && mNumRequestedMipmaps)
117 mNumMipmaps = getMaxMipmaps();
118
119 if(mRenderSystem->hasMinGLVersion(3, 0) || mRenderSystem->checkExtension("GL_APPLE_texture_max_level"))
120 mRenderSystem->_getStateCacheManager()->setTexParameteri(texTarget, GL_TEXTURE_MAX_LEVEL_APPLE, mNumRequestedMipmaps ? mNumMipmaps + 1 : 0);
121
122 if(mTextureType == TEX_TYPE_EXTERNAL_OES && mNumRequestedMipmaps > 0) {
123 OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Mipmaps are not available for TEX_TYPE_EXTERNAL_OES", "GLES2Texture::_createGLTexResource");
124 }
125
126 bool hasGLES30 = mRenderSystem->hasMinGLVersion(3, 0);
127
128 // Set up texture swizzling (not available in WebGL2)
129 if (hasGLES30 && (OGRE_PLATFORM != OGRE_PLATFORM_EMSCRIPTEN))
130 {
131 if(PixelUtil::isLuminance(mFormat))

Callers

nothing calls this directly

Calls 7

getComponentCountFunction · 0.85
getRenderSystemMethod · 0.80
hasMinGLVersionMethod · 0.80
checkExtensionMethod · 0.80
getNativeFormatMethod · 0.45
bindGLTextureMethod · 0.45
setTexParameteriMethod · 0.45

Tested by

no test coverage detected