* Init: Initialize the GL with needed data. We add on the things * needed for textures * - load image data into generated glBuffers * - configure samplerObj in fragment shader * @param assetMgr android assetManager from java side */
| 51 | * @param assetMgr android assetManager from java side |
| 52 | */ |
| 53 | void TexturedTeapotRender::Init(AAssetManager* assetMgr) { |
| 54 | // initialize the basic things from TeapotRenderer, no change |
| 55 | TeapotRenderer::Init(); |
| 56 | |
| 57 | // Need flip Y, so as top/bottom image |
| 58 | std::vector<std::string> textures{ |
| 59 | std::string("Textures/right.tga"), // GL_TEXTURE_CUBE_MAP_POSITIVE_X |
| 60 | std::string("Textures/left.tga"), // GL_TEXTURE_CUBE_MAP_NEGATIVE_X |
| 61 | std::string("Textures/bottom.tga"), // GL_TEXTURE_CUBE_MAP_NEGATIVE_Y |
| 62 | std::string("Textures/top.tga"), // GL_TEXTURE_CUBE_MAP_POSITIVE_Y |
| 63 | std::string("Textures/front.tga"), // GL_TEXTURE_CUBE_MAP_POSITIVE_Z |
| 64 | std::string("Textures/back.tga") // GL_TEXTURE_CUBE_MAP_NEGATIVE_Z |
| 65 | }; |
| 66 | |
| 67 | texObj_ = new Texture(textures, assetMgr); |
| 68 | assert(texObj_); |
| 69 | |
| 70 | std::vector<std::string> samplers; |
| 71 | std::vector<GLint> units; |
| 72 | texObj_->GetActiveSamplerInfo(samplers, units); |
| 73 | for (size_t idx = 0; idx < samplers.size(); idx++) { |
| 74 | GLint sampler = |
| 75 | glGetUniformLocation(shader_param_.program_, samplers[idx].c_str()); |
| 76 | glUniform1i(sampler, units[idx]); |
| 77 | } |
| 78 | |
| 79 | texObj_->Activate(); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Render() function: |
nothing calls this directly
no test coverage detected