sdlGlExtensionSupported function

bool sdlGlExtensionSupported(
  1. String? extension
)

Check if an OpenGL extension is supported for the current context.

This function operates on the current GL context; you must have created a context and it must be current before calling this function. Do not assume that all contexts you create will have the same set of extensions available, or that recreating an existing context will offer the same extensions again.

While it's probably not a massive overhead, this function is not an O(1) operation. Check the extensions you care about after creating the GL context and save that information somewhere instead of calling the function every time you need to know.

\param extension the name of the extension to check \returns SDL_TRUE if the extension is supported, SDL_FALSE otherwise.

\since This function is available since SDL 2.0.0.

extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char *extension)

Implementation

bool sdlGlExtensionSupported(String? extension) {
  final sdlGlExtensionSupportedLookupFunction = libSdl2.lookupFunction<
      Int32 Function(Pointer<Utf8> extension),
      int Function(Pointer<Utf8> extension)>('SDL_GL_ExtensionSupported');
  final extensionPointer =
      extension != null ? extension.toNativeUtf8() : nullptr;
  final result = sdlGlExtensionSupportedLookupFunction(extensionPointer) == 1;
  calloc.free(extensionPointer);
  return result;
}