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

Method GFXGLStateBlock

Engine/source/gfx/gl/gfxGLStateBlock.cpp:38–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38GFXGLStateBlock::GFXGLStateBlock(const GFXStateBlockDesc& desc) :
39 mDesc(desc),
40 mCachedHashValue(desc.getHashValue())
41{
42 static Map<GFXSamplerStateDesc, U32> mSamplersMap;
43
44 for(int i = 0; i < GFX_TEXTURE_STAGE_COUNT; ++i)
45 {
46 GLuint &id = mSamplerObjects[i];
47 GFXSamplerStateDesc &ssd = mDesc.samplers[i];
48 Map<GFXSamplerStateDesc, U32>::Iterator itr = mSamplersMap.find(ssd);
49 if(itr == mSamplersMap.end())
50 {
51 glGenSamplers(1, &id);
52
53 glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, minificationFilter(ssd.minFilter, ssd.mipFilter, 1) );
54 glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GFXGLTextureFilter[ssd.magFilter]);
55 glSamplerParameteri(id, GL_TEXTURE_WRAP_S, GFXGLTextureAddress[ssd.addressModeU]);
56 glSamplerParameteri(id, GL_TEXTURE_WRAP_T, GFXGLTextureAddress[ssd.addressModeV]);
57 glSamplerParameteri(id, GL_TEXTURE_WRAP_R, GFXGLTextureAddress[ssd.addressModeW]);
58
59 //compare modes
60 const bool comparison = ssd.samplerFunc != GFXCmpNever;
61 glSamplerParameteri(id, GL_TEXTURE_COMPARE_MODE, comparison ? GL_COMPARE_R_TO_TEXTURE_ARB : GL_NONE );
62 glSamplerParameteri(id, GL_TEXTURE_COMPARE_FUNC, GFXGLCmpFunc[ssd.samplerFunc]);
63
64 if (static_cast< GFXGLDevice* >(GFX)->supportsAnisotropic())
65 glSamplerParameterf(id, GL_TEXTURE_MAX_ANISOTROPY_EXT, ssd.maxAnisotropy);
66
67 mSamplersMap[ssd] = id;
68 }
69 else
70 id = itr->value;
71 }
72}
73
74GFXGLStateBlock::~GFXGLStateBlock()
75{

Callers

nothing calls this directly

Calls 5

minificationFilterFunction · 0.85
supportsAnisotropicMethod · 0.80
getHashValueMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected