You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.9 KiB

  1. #include "fullscreenquad.h"
  2. void FullScreenQuad::Init()
  3. {
  4. mVertexBuffer = new VertexBuffer();
  5. mVertexBuffer->SetSize(4);
  6. mVertexBuffer->SetTexcoord(0, 0.0f, 0.0f);
  7. mVertexBuffer->SetTexcoord(1, 1.0f, 0.0f);
  8. mVertexBuffer->SetTexcoord(2, 0.0f, 1.0f);
  9. mVertexBuffer->SetTexcoord(3, 1.0f, 1.0f);
  10. mShader = new Shader();
  11. }
  12. void FullScreenQuad::Draw() {
  13. //�����
  14. float identity[] = {
  15. 1.0f,0.0f,0.0f,0.0f,
  16. 0.0f,1.0f,0.0f,0.0f,
  17. 0.0f,0.0f,1.0f,0.0f,
  18. 0.0f,0.0f,0.0f,1.0f,
  19. };
  20. mVertexBuffer->SetPosition(0, -1.0f, -1.0f, 0.0f);
  21. mVertexBuffer->SetPosition(1, 1.0f, -1.0f, 0.0f);
  22. mVertexBuffer->SetPosition(2, -1.0f, 1.0f, 0.0f);
  23. mVertexBuffer->SetPosition(3, 1.0f, 1.0f, 0.0f);
  24. mVertexBuffer->Bind();
  25. mShader->Bind(identity, identity, identity);
  26. glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  27. mVertexBuffer->Unbind();
  28. }
  29. void FullScreenQuad::DrawToLeftTop() {
  30. float identity[] = {
  31. 1.0f,0.0f,0.0f,0.0f,
  32. 0.0f,1.0f,0.0f,0.0f,
  33. 0.0f,0.0f,1.0f,0.0f,
  34. 0.0f,0.0f,0.0f,1.0f,
  35. };
  36. mVertexBuffer->SetPosition(0, -1.0f, 0.0f, -1.0f);
  37. mVertexBuffer->SetPosition(1, 0.0f, 0.0f, -1.0f);
  38. mVertexBuffer->SetPosition(2, -1.0f, 1.0f, -1.0f);
  39. mVertexBuffer->SetPosition(3, 0.0f, 1.0f, -1.0f);
  40. mVertexBuffer->Bind();
  41. mShader->Bind(identity, identity, identity);
  42. glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  43. mVertexBuffer->Unbind();
  44. }
  45. void FullScreenQuad::DrawToLeftBottom() {
  46. float identity[] = {
  47. 1.0f,0.0f,0.0f,0.0f,
  48. 0.0f,1.0f,0.0f,0.0f,
  49. 0.0f,0.0f,1.0f,0.0f,
  50. 0.0f,0.0f,0.0f,1.0f,
  51. };
  52. mVertexBuffer->SetPosition(0, -1.0f, -1.0f, -1.0f);
  53. mVertexBuffer->SetPosition(1, 0.0f, -1.0f, -1.0f);
  54. mVertexBuffer->SetPosition(2, -1.0f, 0.0f, -1.0f);
  55. mVertexBuffer->SetPosition(3, 0.0f, 0.0f, -1.0f);
  56. mVertexBuffer->Bind();
  57. mShader->Bind(identity, identity, identity);
  58. glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  59. mVertexBuffer->Unbind();
  60. }
  61. void FullScreenQuad::DrawToRightTop() {
  62. float identity[] = {
  63. 1.0f,0.0f,0.0f,0.0f,
  64. 0.0f,1.0f,0.0f,0.0f,
  65. 0.0f,0.0f,1.0f,0.0f,
  66. 0.0f,0.0f,0.0f,1.0f,
  67. };
  68. mVertexBuffer->SetPosition(0, 0.0f, 0.0f, -1.0f);
  69. mVertexBuffer->SetPosition(1, 1.0f, 0.0f, -1.0f);
  70. mVertexBuffer->SetPosition(2, 0.0f, 1.0f, -1.0f);
  71. mVertexBuffer->SetPosition(3, 1.0f, 1.0f, -1.0f);
  72. mVertexBuffer->Bind();
  73. mShader->Bind(identity, identity, identity);
  74. glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  75. mVertexBuffer->Unbind();
  76. }
  77. void FullScreenQuad::DrawToRightBottom() {
  78. float identity[] = {
  79. 1.0f,0.0f,0.0f,0.0f,
  80. 0.0f,1.0f,0.0f,0.0f,
  81. 0.0f,0.0f,1.0f,0.0f,
  82. 0.0f,0.0f,0.0f,1.0f,
  83. };
  84. mVertexBuffer->SetPosition(0, 0.0f, -1.0f, -1.0f);
  85. mVertexBuffer->SetPosition(1, 1.0f, -1.0f, -1.0f);
  86. mVertexBuffer->SetPosition(2, 0.0f, 0.0f, -1.0f);
  87. mVertexBuffer->SetPosition(3, 1.0f, 0.0f, -1.0f);
  88. mVertexBuffer->Bind();
  89. mShader->Bind(identity, identity, identity);
  90. glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  91. mVertexBuffer->Unbind();
  92. }