<div dir="ltr"><div class="gmail_extra"><div class="gmail_extra">You need to tell SDL what OpenGL kind and version before you create a window. For example if you want OpenGLES 2.0 you would write:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>SDL_Init(SDL_INIT_VIDEO);</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">    </span>SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">    </span></div><div class="gmail_extra">If you want normal OpenGL 4.0 you would write:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">    </span>SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);</div><div class="gmail_extra"><br></div><div class="gmail_extra">Then you can create the SDL and load the appropriate OpenGL function prototypes using:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>glClear := SDL_GL_GetProcAddress('glClear');</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">     </span></div><div class="gmail_extra">It's up to you to know which functions are part of which which OpenGL spec, and you should need to load the functions dynamically to stubs:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>var glClear: procedure(mask: GLbitfield); cdecl;</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span></div><div class="gmail_extra">Don't forget, if you want a specific values for stencil bits, pixel order, multisampling levels and other stuff, you need to set those values before you create a window. Check the return values of SDL_CreateWindow and SDL_GL_CreateContext to see if anything above fails, for example the target device doesn't support OpenGL 4.0.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8); // 8x anti-aliasing, must be called before SDL_CreateWindow</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 16); // 16 bit stencil buffer, must be called before SDL_CreateWindow</div></div></div>