GLExtensions.cpp revision b027f805c9a18893556353f44008683e20ebe049
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <stdint.h>
18#include <stdio.h>
19#include <stdlib.h>
20
21#include "GLExtensions.h"
22
23namespace android {
24// ---------------------------------------------------------------------------
25
26ANDROID_SINGLETON_STATIC_INSTANCE(GLExtensions)
27
28GLExtensions::GLExtensions() : mHaveFramebufferObject(false) {}
29
30void GLExtensions::initWithGLStrings(GLubyte const* vendor, GLubyte const* renderer,
31                                     GLubyte const* version, GLubyte const* extensions) {
32    mVendor = (char const*)vendor;
33    mRenderer = (char const*)renderer;
34    mVersion = (char const*)version;
35    mExtensions = (char const*)extensions;
36
37    char const* curr = (char const*)extensions;
38    char const* head = curr;
39    do {
40        head = strchr(curr, ' ');
41        String8 s(curr, head ? head - curr : strlen(curr));
42        if (s.length()) {
43            mExtensionList.add(s);
44        }
45        curr = head + 1;
46    } while (head);
47
48    if (hasExtension("GL_OES_framebuffer_object")) {
49        mHaveFramebufferObject = true;
50    }
51}
52
53bool GLExtensions::hasExtension(char const* extension) const {
54    const String8 s(extension);
55    return mExtensionList.indexOf(s) >= 0;
56}
57
58char const* GLExtensions::getVendor() const {
59    return mVendor.string();
60}
61
62char const* GLExtensions::getRenderer() const {
63    return mRenderer.string();
64}
65
66char const* GLExtensions::getVersion() const {
67    return mVersion.string();
68}
69
70char const* GLExtensions::getExtension() const {
71    return mExtensions.string();
72}
73
74// ---------------------------------------------------------------------------
75}; // namespace android
76