draw_floor.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_OPENGL2_DRAW_FLOOR_H
  9. #define IGL_OPENGL2_DRAW_FLOOR_H
  10. #include "../igl_inline.h"
  11. namespace igl
  12. {
  13. namespace opengl2
  14. {
  15. // Draw a checkerboard floor aligned with current (X,Z) plane using ../opengl/OpenGL_
  16. // calls. side=50 centered at (0,0):
  17. // (-25,-25)-->(-25,25)-->(25,25)-->(25,-25)
  18. //
  19. // Use glPushMatrix(), glScaled(), glTranslated() to arrange the floor.
  20. //
  21. // Inputs:
  22. // colorA float4 color
  23. // colorB float4 color
  24. //
  25. // Example:
  26. // // Draw a nice floor
  27. // glPushMatrix();
  28. // glCullFace(GL_BACK);
  29. // glEnable(GL_CULL_FACE);
  30. // glEnable(GL_LIGHTING);
  31. // glTranslated(0,-1,0);
  32. // if(project(Vector3d(0,0,0))(2) - project(Vector3d(0,1,0))(2) > -FLOAT_EPS)
  33. // {
  34. // draw_floor_outline();
  35. // }
  36. // draw_floor();
  37. // glPopMatrix();
  38. // glDisable(GL_CULL_FACE);
  39. //
  40. IGL_INLINE void draw_floor(
  41. const float * colorA,
  42. const float * colorB,
  43. const int GridSizeX=100,
  44. const int GridSizeY=100);
  45. // Wrapper with default colors
  46. IGL_INLINE void draw_floor();
  47. IGL_INLINE void draw_floor_outline(
  48. const float * colorA,
  49. const float * colorB,
  50. const int GridSizeX=100,
  51. const int GridSizeY=100);
  52. // Wrapper with default colors
  53. IGL_INLINE void draw_floor_outline();
  54. }
  55. }
  56. #ifndef IGL_STATIC_LIBRARY
  57. # include "draw_floor.cpp"
  58. #endif
  59. #endif