MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / innerCreateTexture

Method innerCreateTexture

Engine/source/gfx/gl/gfxGLTextureManager.cpp:85–225  ·  view source on GitHub ↗

----------------------------------------------------------------------------- innerCreateTexture ----------------------------------------------------------------------------- This just creates the texture, no info is actually loaded to it. We do that later.

Source from the content-addressed store, hash-verified

83//-----------------------------------------------------------------------------
84// This just creates the texture, no info is actually loaded to it. We do that later.
85void GFXGLTextureManager::innerCreateTexture( GFXGLTextureObject *retTex,
86 U32 height,
87 U32 width,
88 U32 depth,
89 GFXFormat format,
90 GFXTextureProfile *profile,
91 U32 numMipLevels,
92 bool forceMips)
93{
94 // No 24 bit formats. They trigger various oddities because hardware (and Apple's drivers apparently...) don't natively support them.
95 if (format == GFXFormatR8G8B8)
96 format = GFXFormatR8G8B8A8;
97 else if (format == GFXFormatR8G8B8_SRGB)
98 format = GFXFormatR8G8B8A8_SRGB;
99
100 retTex->mFormat = format;
101 retTex->mIsZombie = false;
102 retTex->mIsNPoT2 = false;
103
104 GLenum binding = ( (height == 1 || width == 1) && ( height != width ) ) ? GL_TEXTURE_1D : ( (depth == 0) ? GL_TEXTURE_2D : GL_TEXTURE_3D );
105 if((profile->testFlag(GFXTextureProfile::RenderTarget) || profile->testFlag(GFXTextureProfile::ZTarget)) && (!isPow2(width) || !isPow2(height)) && !depth)
106 retTex->mIsNPoT2 = true;
107 retTex->mBinding = binding;
108
109 // Bind it
110 PRESERVE_TEXTURE(binding);
111 glBindTexture(retTex->getBinding(), retTex->getHandle());
112
113 // Create it
114 // @todo OPENGL - Creating mipmaps for compressed formats. Not supported on OpenGL ES and bugged on AMD. We use mipmaps present on file.
115 if( forceMips && !retTex->mIsNPoT2 && !ImageUtil::isCompressedFormat(format) )
116 {
117 retTex->mMipLevels = numMipLevels > 1 ? numMipLevels : 0;
118 }
119 else if(profile->testFlag(GFXTextureProfile::NoMipmap) || profile->testFlag(GFXTextureProfile::RenderTarget) || numMipLevels == 1 || retTex->mIsNPoT2)
120 {
121 retTex->mMipLevels = 1;
122 }
123 else
124 {
125 retTex->mMipLevels = numMipLevels;
126 }
127
128 // @todo OPENGL - OpenGL ES2 not support mipmaps on NPOT textures
129#if 0
130 if(!retTex->mIsNPoT2)
131 {
132 if(!isPow2(width))
133 width = getNextPow2(width);
134 if(!isPow2(height))
135 height = getNextPow2(height);
136 if(depth && !isPow2(depth))
137 depth = getNextPow2(depth);
138 }
139#endif
140
141 AssertFatal(GFXGLTextureInternalFormat[format] != GL_ZERO, "GFXGLTextureManager::innerCreateTexture - invalid internal format");
142 AssertFatal(GFXGLTextureFormat[format] != GL_ZERO, "GFXGLTextureManager::innerCreateTexture - invalid format");

Callers

nothing calls this directly

Calls 13

isPow2Function · 0.85
isCompressedFormatFunction · 0.85
getNextPow2Function · 0.85
getMaxMipmapsFunction · 0.85
getMaxFunction · 0.85
getCompressedSurfaceSizeFunction · 0.85
testFlagMethod · 0.80
dMemsetFunction · 0.50
U32Enum · 0.50
dFreeFunction · 0.50
getBindingMethod · 0.45
getHandleMethod · 0.45

Tested by

no test coverage detected