draw_floor.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_DRAW_FLOOR_H
  9. #define IGL_DRAW_FLOOR_H
  10. #ifndef IGL_NO_OPENGL
  11. #include "igl_inline.h"
  12. namespace igl
  13. {
  14. // Draw a checkerboard floor aligned with current (X,Z) plane using OpenGL
  15. // calls. side=50 centered at (0,0):
  16. // (-25,-25)-->(-25,25)-->(25,25)-->(25,-25)
  17. //
  18. // Use glPushMatrix(), glScaled(), glTranslated() to arrange the floor.
  19. //
  20. // Inputs:
  21. // colorA float4 color
  22. // colorB float4 color
  23. //
  24. // Example:
  25. // // Draw a nice floor
  26. // glPushMatrix();
  27. // glCullFace(GL_BACK);
  28. // glEnable(GL_CULL_FACE);
  29. // glEnable(GL_LIGHTING);
  30. // glTranslated(0,-1,0);
  31. // if(project(Vector3d(0,0,0))(2) - project(Vector3d(0,1,0))(2) > -FLOAT_EPS)
  32. // {
  33. // draw_floor_outline();
  34. // }
  35. // draw_floor();
  36. // glPopMatrix();
  37. // glDisable(GL_CULL_FACE);
  38. //
  39. IGL_INLINE void draw_floor(const float * colorA, const float * colorB);
  40. // Wrapper with default colors
  41. IGL_INLINE void draw_floor();
  42. IGL_INLINE void draw_floor_outline(const float * colorA, const float * colorB);
  43. // Wrapper with default colors
  44. IGL_INLINE void draw_floor_outline();
  45. }
  46. #ifdef IGL_HEADER_ONLY
  47. # include "draw_floor.cpp"
  48. #endif
  49. #endif
  50. #endif