| 467 | }; |
| 468 | |
| 469 | class BindTexture |
| 470 | { |
| 471 | BindTexture(const BindTexture &) = delete; |
| 472 | |
| 473 | public: |
| 474 | GLenum bind; |
| 475 | int unit; |
| 476 | static GLenum getBindEnum(GLenum e) |
| 477 | { |
| 478 | switch (e) |
| 479 | { |
| 480 | case gl20::TEXTURE_1D: |
| 481 | return gl20::TEXTURE_BINDING_1D; |
| 482 | case gl20::TEXTURE_2D: |
| 483 | return gl20::TEXTURE_BINDING_2D; |
| 484 | case gl20::TEXTURE_3D: |
| 485 | return gl20::TEXTURE_BINDING_3D; |
| 486 | default: |
| 487 | LogError("Unknown texture enum %d", static_cast<int>(e)); |
| 488 | return gl20::TEXTURE_BINDING_2D; |
| 489 | } |
| 490 | } |
| 491 | BindTexture(GLuint id, GLint unit = 0, GLenum bind = gl20::TEXTURE_2D) : bind(bind), unit(unit) |
| 492 | { |
| 493 | ActiveTexture a(unit); |
| 494 | GLuint prevID; |
| 495 | gl20::GetIntegerv(getBindEnum(bind), reinterpret_cast<GLint *>(&prevID)); |
| 496 | if (prevID == id) |
| 497 | { |
| 498 | return; |
| 499 | } |
| 500 | gl20::BindTexture(bind, id); |
| 501 | } |
| 502 | }; |
| 503 | |
| 504 | template <GLenum param> class TexParam |
| 505 | { |