| 391 | } |
| 392 | |
| 393 | void RenderMeshObject::bindMesh_( GLStaticHolder::ShaderType shaderType ) |
| 394 | { |
| 395 | MR_TIMER; |
| 396 | auto shader = GLStaticHolder::getShaderId( shaderType ); |
| 397 | GL_EXEC( glBindVertexArray( meshArrayObjId_ ) ); |
| 398 | GL_EXEC( glUseProgram( shader ) ); |
| 399 | |
| 400 | auto positions = loadVertPosBuffer_(); |
| 401 | bindVertexAttribArray( shader, "position", vertPosBuffer_, positions, 3, positions.dirty(), positions.glSize() != 0 ); |
| 402 | |
| 403 | auto normals = loadVertNormalsBuffer_(); |
| 404 | bindVertexAttribArray( shader, "normal", vertNormalsBuffer_, normals, 3, normals.dirty(), normals.glSize() != 0 ); |
| 405 | |
| 406 | auto colormaps = loadVertColorsBuffer_(); |
| 407 | bindVertexAttribArray( shader, "K", vertColorsBuffer_, colormaps, 4, colormaps.dirty(), colormaps.glSize() != 0 ); |
| 408 | |
| 409 | auto uvs = loadVertUVBuffer_(); |
| 410 | bindVertexAttribArray( shader, "texcoord", vertUVBuffer_, uvs, 2, uvs.dirty(), uvs.glSize() != 0 ); |
| 411 | |
| 412 | auto faces = loadFaceIndicesBuffer_(); |
| 413 | facesIndicesBuffer_.loadDataOpt( GL_ELEMENT_ARRAY_BUFFER, faces.dirty(), faces ); |
| 414 | |
| 415 | GL_EXEC( glActiveTexture( GL_TEXTURE0 ) ); |
| 416 | |
| 417 | if ( bool( dirty_ & DIRTY_TEXTURE ) ) |
| 418 | { |
| 419 | dirty_ &= ~DIRTY_TEXTURE; |
| 420 | if ( objMesh_->hasAncillaryTexture() ) |
| 421 | { |
| 422 | const auto& texture = objMesh_->getAncillaryTexture(); |
| 423 | |
| 424 | textureArray_.loadDataOpt( true, |
| 425 | { |
| 426 | .resolution = GlTexture2::ToResolution( texture.resolution ), |
| 427 | .internalFormat = GL_RGBA, |
| 428 | .format = GL_RGBA, |
| 429 | .type = GL_UNSIGNED_BYTE, |
| 430 | .wrap = texture.wrap, |
| 431 | .filter = texture.filter |
| 432 | }, |
| 433 | texture.pixels ); |
| 434 | } |
| 435 | else |
| 436 | { |
| 437 | const auto& textures = objMesh_->getTextures(); |
| 438 | |
| 439 | auto res = textures.empty() ? Vector2i() : textures.front().resolution; |
| 440 | auto wrap = textures.empty() ? WrapType::Clamp : textures.front().wrap; |
| 441 | auto filter = textures.empty() ? FilterType::Linear : textures.front().filter; |
| 442 | |
| 443 | auto& buffer = GLStaticHolder::getStaticGLBuffer(); |
| 444 | auto texSize = res.x * res.y; |
| 445 | auto pixels = buffer.prepareBuffer<Color>( size_t( texSize * textures.size() ) ); |
| 446 | size_t numTex = 0; |
| 447 | for ( const auto& tex : textures ) |
| 448 | std::copy( tex.pixels.begin(), tex.pixels.end(), &pixels[texSize * numTex++] ); |
| 449 | |
| 450 | GlTexture2DArray::Settings settings; |
nothing calls this directly
no test coverage detected