CCGLBufferedNode.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /****************************************************************************
  2. Copyright (c) 2013 Zynga Inc.
  3. Copyright (c) 2013-2016 Chukong Technologies Inc.
  4. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  5. http://www.cocos2d-x.org
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. ****************************************************************************/
  22. #ifndef __CC_GL_BUFFERED_NODE__
  23. #define __CC_GL_BUFFERED_NODE__
  24. #include "platform/CCGL.h"
  25. /**
  26. * @js NA
  27. */
  28. class GLBufferedNode
  29. {
  30. public:
  31. /**
  32. * @js ctor
  33. */
  34. GLBufferedNode();
  35. /**
  36. * @js NA
  37. * @lua NA
  38. */
  39. virtual ~GLBufferedNode();
  40. /**@{
  41. * Load the given data into this Node's GL Buffer. Needed for WebGL, as it does not support client-side arrays.
  42. */
  43. void setGLBufferData(void *buf, GLuint bufSize, int slot);
  44. void setGLIndexData(void *buf, GLuint bufSize, int slot);
  45. /**@}*/
  46. /** Allocate 4 buffer objs per node, and index into them as slots.*/
  47. #define BUFFER_SLOTS 4
  48. /**Handle for vertex buffers.*/
  49. GLuint _bufferObject[BUFFER_SLOTS];
  50. /**Size in bytes for vertex buffers.*/
  51. GLuint _bufferSize[BUFFER_SLOTS];
  52. /**Handle for index buffers.*/
  53. GLuint _indexBufferObject[BUFFER_SLOTS];
  54. /**Size in bytes for index buffers.*/
  55. GLuint _indexBufferSize[BUFFER_SLOTS];
  56. };
  57. #endif // __CC_GL_BUFFERED_NODE__