CCGL-android.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  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 __CCGL_H__
  23. #define __CCGL_H__
  24. #include "platform/CCPlatformConfig.h"
  25. #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
  26. #define glClearDepth glClearDepthf
  27. #define glDeleteVertexArrays glDeleteVertexArraysOES
  28. #define glGenVertexArrays glGenVertexArraysOES
  29. #define glBindVertexArray glBindVertexArrayOES
  30. #define glMapBuffer glMapBufferOES
  31. #define glUnmapBuffer glUnmapBufferOES
  32. #define glTexImage3D glTexImage3DOES
  33. #define glCompressedTexImage3D glCompressedTexImage3DOES
  34. #define glCompressedTexSubImage3D glCompressedTexSubImage3DOES
  35. #define glTexSubImage3D glTexSubImage3DOES
  36. #define glDepthRange glDepthRangef
  37. #define glSubImage3D glSubImage3DOES
  38. #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
  39. #define GL_WRITE_ONLY GL_WRITE_ONLY_OES
  40. // GL_GLEXT_PROTOTYPES isn't defined in glplatform.h on android ndk r7
  41. // we manually define it here
  42. #include <GLES2/gl2platform.h>
  43. #ifndef GL_GLEXT_PROTOTYPES
  44. #define GL_GLEXT_PROTOTYPES 1
  45. #endif
  46. // normal process
  47. #include <GLES2/gl2.h>
  48. #include <GLES2/gl2ext.h>
  49. // gl2.h doesn't define GLchar on Android
  50. typedef char GLchar;
  51. // android defines GL_BGRA_EXT but not GL_BRGA
  52. #ifndef GL_BGRA
  53. #define GL_BGRA 0x80E1
  54. #endif
  55. //declare here while define in EGLView_android.cpp
  56. extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT;
  57. extern PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOESEXT;
  58. extern PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT;
  59. #define glGenVertexArraysOES glGenVertexArraysOESEXT
  60. #define glBindVertexArrayOES glBindVertexArrayOESEXT
  61. #define glDeleteVertexArraysOES glDeleteVertexArraysOESEXT
  62. #endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
  63. #endif // __CCGL_H__