@@ -57,7 +57,11 @@ extern int video_refresh_rate;
57
57
static int glsl_version [2 ];
58
58
59
59
const char * vertex_shader_default_tex_src =
60
+ #ifdef __APPLE__
61
+ "#version 150\n"
62
+ #else
60
63
"#version 130\n"
64
+ #endif
61
65
"\n"
62
66
"in vec4 VertexCoord;\n"
63
67
"in vec2 TexCoord;\n"
@@ -71,7 +75,11 @@ const char* vertex_shader_default_tex_src =
71
75
"}\n" ;
72
76
73
77
const char * fragment_shader_default_tex_src =
78
+ #ifdef __APPLE__
79
+ "#version 150\n"
80
+ #else
74
81
"#version 130\n"
82
+ #endif
75
83
"\n"
76
84
"in vec2 texCoord;\n"
77
85
"uniform sampler2D Texture;\n"
@@ -84,7 +92,11 @@ const char* fragment_shader_default_tex_src =
84
92
"}\n" ;
85
93
86
94
const char * vertex_shader_default_color_src =
95
+ #ifdef __APPLE__
96
+ "#version 150\n"
97
+ #else
87
98
"#version 130\n"
99
+ #endif
88
100
"\n"
89
101
"in vec4 VertexCoord;\n"
90
102
"in vec4 Color;\n"
@@ -98,7 +110,11 @@ const char* vertex_shader_default_color_src =
98
110
"}\n" ;
99
111
100
112
const char * fragment_shader_default_color_src =
113
+ #ifdef __APPLE__
114
+ "#version 150\n"
115
+ #else
101
116
"#version 130\n"
117
+ #endif
102
118
"\n"
103
119
"in vec4 color;\n"
104
120
"\n"
@@ -770,6 +786,13 @@ int gl3_init(SDL_Window* window, sdl_render_driver requested_render_driver, SDL_
770
786
771
787
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER , 1 );
772
788
789
+ #ifdef __APPLE__
790
+ // without an explicit request for the core profile 3.0 macOS falls back to default ancient 2.1
791
+ SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION , 3 );
792
+ SDL_GL_SetAttribute (SDL_GL_CONTEXT_MINOR_VERSION , 0 );
793
+ SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK , SDL_GL_CONTEXT_PROFILE_CORE );
794
+ #endif
795
+
773
796
context = SDL_GL_CreateContext (window );
774
797
775
798
if (!context )
@@ -1637,11 +1660,21 @@ int gl3_renderer_available(struct sdl_render_driver* driver)
1637
1660
if (available < 0 )
1638
1661
{
1639
1662
available = 0 ;
1663
+
1664
+ // GL SetAttribute should be done *before* window creation for the attributes to apply on
1665
+ // context creation (seems to depend on OpenGL impl. but it souldn't hurt other platforms
1666
+ // to do it here (earlier than before)
1667
+ SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION , 3 );
1668
+ SDL_GL_SetAttribute (SDL_GL_CONTEXT_MINOR_VERSION , 0 );
1669
+
1670
+ #ifdef __APPLE__
1671
+ // without an explicit request for the core profile 3.0 macOS falls back to default ancient 2.1
1672
+ SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK , SDL_GL_CONTEXT_PROFILE_CORE );
1673
+ #endif
1674
+
1640
1675
SDL_Window * window = SDL_CreateWindow ("GL3 test" , SDL_WINDOWPOS_UNDEFINED , SDL_WINDOWPOS_UNDEFINED , 1 , 1 , SDL_WINDOW_HIDDEN | SDL_WINDOW_OPENGL );
1641
1676
if (window )
1642
1677
{
1643
- SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION , 3 );
1644
- SDL_GL_SetAttribute (SDL_GL_CONTEXT_MINOR_VERSION , 0 );
1645
1678
1646
1679
SDL_GLContext context = SDL_GL_CreateContext (window );
1647
1680
if (context )
0 commit comments