blob: 7ffcc9629f24cd69ca158ab3479bb34be2b04b66 [file] [log] [blame]
Mathias Agopian875d8e12013-06-07 15:35:48 -07001/*
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
Mathias Agopian875d8e12013-06-07 15:35:48 -070017#include <stdint.h>
Chia-I Wub027f802017-11-29 14:00:52 -080018#include <stdio.h>
19#include <stdlib.h>
Mathias Agopian875d8e12013-06-07 15:35:48 -070020
21#include "GLExtensions.h"
22
23namespace android {
24// ---------------------------------------------------------------------------
25
Chia-I Wub027f802017-11-29 14:00:52 -080026ANDROID_SINGLETON_STATIC_INSTANCE(GLExtensions)
Mathias Agopian875d8e12013-06-07 15:35:48 -070027
Chia-I Wub027f802017-11-29 14:00:52 -080028GLExtensions::GLExtensions() : mHaveFramebufferObject(false) {}
Mathias Agopian875d8e12013-06-07 15:35:48 -070029
Chia-I Wub027f802017-11-29 14:00:52 -080030void 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;
Mathias Agopian875d8e12013-06-07 15:35:48 -070035 mExtensions = (char const*)extensions;
36
37 char const* curr = (char const*)extensions;
38 char const* head = curr;
39 do {
40 head = strchr(curr, ' ');
Chia-I Wub027f802017-11-29 14:00:52 -080041 String8 s(curr, head ? head - curr : strlen(curr));
Mathias Agopian875d8e12013-06-07 15:35:48 -070042 if (s.length()) {
43 mExtensionList.add(s);
44 }
Chia-I Wub027f802017-11-29 14:00:52 -080045 curr = head + 1;
Mathias Agopian875d8e12013-06-07 15:35:48 -070046 } while (head);
47
48 if (hasExtension("GL_OES_framebuffer_object")) {
49 mHaveFramebufferObject = true;
50 }
51}
52
Chia-I Wub027f802017-11-29 14:00:52 -080053bool GLExtensions::hasExtension(char const* extension) const {
Mathias Agopian875d8e12013-06-07 15:35:48 -070054 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