TextureFormat.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include <iostream>
  2. #include "wrapper/TextureFormat.h"
  3. TextureFormat::TextureFormat(GLint internalformat, GLenum format, GLenum type, bool depth) :
  4. internalformat(internalformat), format(format), type(type), depth(depth) {
  5. }
  6. TextureFormat TextureFormat::color8(int channels) {
  7. switch(channels) {
  8. case 1: return TextureFormat(GL_RED, GL_RED, GL_UNSIGNED_BYTE);
  9. case 2: return TextureFormat(GL_RG, GL_RG, GL_UNSIGNED_BYTE);
  10. case 3: return TextureFormat(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE);
  11. case 4: return TextureFormat(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
  12. }
  13. std::cout << channels << " is not a valid amount of channels\n";
  14. return TextureFormat(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
  15. }
  16. TextureFormat TextureFormat::float16(int channels) {
  17. switch(channels) {
  18. case 1: return TextureFormat(GL_R16F, GL_RED, GL_FLOAT);
  19. case 2: return TextureFormat(GL_RG16F, GL_RG, GL_FLOAT);
  20. case 3: return TextureFormat(GL_RGB16F, GL_RGB, GL_FLOAT);
  21. case 4: return TextureFormat(GL_RGBA16F, GL_RGBA, GL_FLOAT);
  22. }
  23. std::cout << channels << " is not a valid amount of channels\n";
  24. return TextureFormat(GL_RGBA16F, GL_RGBA, GL_FLOAT);
  25. }
  26. TextureFormat TextureFormat::float32(int channels) {
  27. switch(channels) {
  28. case 1: return TextureFormat(GL_R32F, GL_RED, GL_FLOAT);
  29. case 2: return TextureFormat(GL_RG32F, GL_RG, GL_FLOAT);
  30. case 3: return TextureFormat(GL_RGB32F, GL_RGB, GL_FLOAT);
  31. case 4: return TextureFormat(GL_RGBA32F, GL_RGBA, GL_FLOAT);
  32. }
  33. std::cout << channels << " is not a valid amount of channels\n";
  34. return TextureFormat(GL_RGBA32F, GL_RGBA, GL_FLOAT);
  35. }
  36. TextureFormat TextureFormat::depth16() {
  37. return TextureFormat(GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_FLOAT, true);
  38. }
  39. TextureFormat TextureFormat::depth32() {
  40. return TextureFormat(GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_FLOAT, true);
  41. }
  42. TextureFormat TextureFormat::unknown() {
  43. return TextureFormat(-1, -1, -1, false);
  44. }