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

Method bindGpuProgram

RenderSystems/GL/src/OgreGLRenderSystem.cpp:2274–2341  ·  view source on GitHub ↗

---------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2272 }
2273 //---------------------------------------------------------------------
2274 void GLRenderSystem::bindGpuProgram(GpuProgram* prg)
2275 {
2276 if (!prg)
2277 {
2278 OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
2279 "Null program bound.",
2280 "GLRenderSystem::bindGpuProgram");
2281 }
2282
2283 GLGpuProgramBase* glprg = dynamic_cast<GLGpuProgramBase*>(prg);
2284
2285 // Unbind previous gpu program first.
2286 //
2287 // Note:
2288 // 1. Even if both previous and current are the same object, we can't
2289 // bypass re-bind completely since the object itself maybe modified.
2290 // But we can bypass unbind based on the assumption that object
2291 // internally GL program type shouldn't be changed after it has
2292 // been created. The behavior of bind to a GL program type twice
2293 // should be same as unbind and rebind that GL program type, even
2294 // for difference objects.
2295 // 2. We also assumed that the program's type (vertex or fragment) should
2296 // not be changed during it's in using. If not, the following switch
2297 // statement will confuse GL state completely, and we can't fix it
2298 // here. To fix this case, we must coding the program implementation
2299 // itself, if type is changing (during load/unload, etc), and it's inuse,
2300 // unbind and notify render system to correct for its state.
2301 //
2302 switch (prg->getType())
2303 {
2304 case GPT_VERTEX_PROGRAM:
2305 if (mCurrentVertexProgram != glprg)
2306 {
2307 if (mCurrentVertexProgram)
2308 mCurrentVertexProgram->unbindProgram();
2309 mCurrentVertexProgram = glprg;
2310 }
2311 break;
2312
2313 case GPT_FRAGMENT_PROGRAM:
2314 if (mCurrentFragmentProgram != glprg)
2315 {
2316 if (mCurrentFragmentProgram)
2317 mCurrentFragmentProgram->unbindProgram();
2318 mCurrentFragmentProgram = glprg;
2319 }
2320 break;
2321 case GPT_GEOMETRY_PROGRAM:
2322 if (mCurrentGeometryProgram != glprg)
2323 {
2324 if (mCurrentGeometryProgram)
2325 mCurrentGeometryProgram->unbindProgram();
2326 mCurrentGeometryProgram = glprg;
2327 }
2328 break;
2329 case GPT_COMPUTE_PROGRAM:
2330 case GPT_DOMAIN_PROGRAM:
2331 case GPT_HULL_PROGRAM:

Callers

nothing calls this directly

Calls 3

getTypeMethod · 0.45
unbindProgramMethod · 0.45
bindProgramMethod · 0.45

Tested by

no test coverage detected