| 332 | } |
| 333 | |
| 334 | void DrawBatch::SetStartState() const { |
| 335 | Graphics *graphics = Graphics::Instance(); |
| 336 | Shaders *shaders = Shaders::Instance(); |
| 337 | Textures *textures = Textures::Instance(); |
| 338 | |
| 339 | graphics->setDepthFunc(depth_func); |
| 340 | graphics->setPolygonOffset(polygon_offset); |
| 341 | graphics->setGLState(gl_state); |
| 342 | |
| 343 | shaders->setProgram(shader_id); |
| 344 | |
| 345 | for (const auto &uniform : uniforms) { |
| 346 | uniform.Apply(); |
| 347 | } |
| 348 | |
| 349 | if (use_cam_pos) { |
| 350 | shaders->SetUniformVec3("cam_pos", ActiveCameras::Get()->GetPos()); |
| 351 | } |
| 352 | |
| 353 | if (use_time) { |
| 354 | shaders->SetUniformFloat("time", game_timer.GetRenderTime()); |
| 355 | } |
| 356 | |
| 357 | if (use_light) { |
| 358 | shaders->SetUniformVec3("ws_light", primary_light->pos); |
| 359 | shaders->SetUniformVec4("primary_light_color", vec4(primary_light->color, primary_light->intensity)); |
| 360 | } |
| 361 | |
| 362 | shaders->SetUniformVec4("uniform_color", color); |
| 363 | |
| 364 | for (int i = 0; i < kMaxTextures; i++) { |
| 365 | if (texture_ref[i].valid()) { |
| 366 | textures->bindTexture(texture_ref[i], i); |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | if (transparent && graphics->use_sample_alpha_to_coverage) { |
| 371 | glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | void DrawBatch::EndVertexArrays() const { |
| 376 | for (int i = 1; i < 8; i++) { |
no test coverage detected