| 356 | } |
| 357 | |
| 358 | bool Material::parseShader(Pass* pass, Properties* shaderProperties) |
| 359 | { |
| 360 | // vertexShader |
| 361 | const char* vertShader = getOptionalString(shaderProperties, "vertexShader", nullptr); |
| 362 | |
| 363 | // fragmentShader |
| 364 | const char* fragShader = getOptionalString(shaderProperties, "fragmentShader", nullptr); |
| 365 | |
| 366 | // compileTimeDefines, since axmol-1.1 no longer support compile time defines |
| 367 | // const char* compileTimeDefines = getOptionalString(shaderProperties, "defines", ""); |
| 368 | |
| 369 | if (vertShader && fragShader) |
| 370 | { |
| 371 | auto program = ProgramManager::getInstance()->loadProgram(vertShader, fragShader); |
| 372 | auto programState = new backend::ProgramState(program); |
| 373 | pass->setProgramState(programState); |
| 374 | |
| 375 | // Parse uniforms only if the GLProgramState was created |
| 376 | auto property = shaderProperties->getNextProperty(); |
| 377 | while (property) |
| 378 | { |
| 379 | if (isValidUniform(property)) |
| 380 | { |
| 381 | parseUniform(programState, shaderProperties, property); |
| 382 | } |
| 383 | |
| 384 | property = shaderProperties->getNextProperty(); |
| 385 | } |
| 386 | |
| 387 | auto space = shaderProperties->getNextNamespace(); |
| 388 | while (space) |
| 389 | { |
| 390 | const char* name = space->getNamespace(); |
| 391 | if (strcmp(name, "sampler") == 0) |
| 392 | { |
| 393 | parseSampler(programState, space); |
| 394 | } |
| 395 | space = shaderProperties->getNextNamespace(); |
| 396 | } |
| 397 | programState->release(); |
| 398 | } |
| 399 | |
| 400 | return true; |
| 401 | } |
| 402 | |
| 403 | bool Material::parseUniform(backend::ProgramState* programState, Properties* properties, const char* uniformName) |
| 404 | { |
nothing calls this directly
no test coverage detected