glad OpenGL loader generator
David
d at dav1d.de
Mon Aug 5 16:59:45 PDT 2013
Am 06.08.2013 00:33, schrieb Justin Whear:
> On Tue, 06 Aug 2013 00:21:46 +0200, David wrote:
>> I was thinking of that, too, but caching the OpenGL call to
>> glGetStringi, I don't think you can prevent the linear searches.
>
> Why not something like this for the GL_VERSION >= 3 codepath in has_ext?
> -----------------------------------
> static auto availableExts;
>
> if (availableExts.empty)
> {
> int num;
> glGetIntegerv(GL_NUM_EXTENSIONS, &num);
> availableExts = new string[](num);
>
> foreach (i, ref extName; availableExts)
> extName = (cast(const(char)*)glGetStringi(GL_EXTENSIONS, i)).idup;
>
> availableExts.sort();
> }
>
> // Use binary search
> return assumeSorted(availableExts).contains(ext);
> -----------------------------------
>
Thanks, I will definitly look into improving it (when I wake up ;))
More information about the Digitalmars-d-announce
mailing list