bbopengl_.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #define GLAPI
  2. #include "bbopengl.h"
  3. #include <stdio.h>
  4. #if __EMSCRIPTEN__
  5. void GLAPIENTRY glClearDepthf( GLclampf depth );
  6. void GLAPIENTRY bbglClearDepth( GLclampd depth ){
  7. glClearDepthf( (GLclampf)depth );
  8. }
  9. #else
  10. #define SDL_GL_CONTEXT_PROFILE_MASK 21
  11. #define SDL_GL_CONTEXT_PROFILE_ES 0x0004
  12. void *SDL_GL_GetProcAddress( const char *proc );
  13. int SDL_GL_ExtensionSupported( const char *ext );
  14. int SDL_GL_GetAttribute( int attr,int *value );
  15. void (GLAPIENTRY*bbglClearDepthf)( GLclampf depth );
  16. void GLAPIENTRY bbglClearDepthd( GLclampd depth ){
  17. bbglClearDepthf( (GLclampf)depth );
  18. }
  19. #endif
  20. void bbglInit(){
  21. #if __EMSCRIPTEN__
  22. BBGL_ES=1;
  23. BBGL_draw_buffers=SDL_GL_ExtensionSupported( "GL_WEBGL_draw_buffers" );
  24. #else
  25. ${INITS}
  26. int profile=0;
  27. SDL_GL_GetAttribute( SDL_GL_CONTEXT_PROFILE_MASK,&profile );
  28. BBGL_ES=( profile==SDL_GL_CONTEXT_PROFILE_ES );
  29. if( BBGL_ES ){
  30. bbglClearDepthf=SDL_GL_GetProcAddress( "glClearDepthf" );
  31. bbglClearDepth=bbglClearDepthd;
  32. if( BBGL_draw_buffers=SDL_GL_ExtensionSupported( "GL_EXT_draw_buffers" ) ){ //For MRTSs
  33. bbglDrawBuffers=SDL_GL_GetProcAddress( "glDrawBuffersEXT" );
  34. }else if( BBGL_draw_buffers=SDL_GL_ExtensionSupported( "GL_NV_draw_buffers" ) ){ //For MRTs on nvidia shield!
  35. bbglDrawBuffers=SDL_GL_GetProcAddress( "glDrawBuffersNV" );
  36. }
  37. }else if( bbglDrawBuffers ){
  38. BBGL_draw_buffers=1;
  39. }
  40. #endif
  41. BBGL_depth_texture=SDL_GL_ExtensionSupported( "GL_EXT_depth_texture" ) ||
  42. SDL_GL_ExtensionSupported( "GL_ANGLE_depth_texture" ) ||
  43. SDL_GL_ExtensionSupported( "GL_WEBGL_depth_texture" ) ||
  44. SDL_GL_ExtensionSupported( "GL_OES_depth_texture" );
  45. BBGL_seamless_cube_map=SDL_GL_ExtensionSupported( "GL_ARB_seamless_cube_map" );
  46. BBGL_texture_filter_anisotropic=SDL_GL_ExtensionSupported( "GL_ARB_texture_filter_anisotropic" ) ||
  47. SDL_GL_ExtensionSupported( "GL_EXT_texture_filter_anisotropic" );
  48. BBGL_standard_derivatives=!BBGL_ES || SDL_GL_ExtensionSupported( "GL_OES_standard_derivatives" );
  49. }