blob: 76bbcc1bfeb39a42882158261f292185226d0224 [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
17#include <stdlib.h>
18#include <stdio.h>
19#include <stdint.h>
20
21#include "GLExtensions.h"
22
23namespace android {
24// ---------------------------------------------------------------------------
25
26ANDROID_SINGLETON_STATIC_INSTANCE( GLExtensions )
27
28GLExtensions::GLExtensions()
29 : mHaveFramebufferObject(false)
30{
31}
32
33void GLExtensions::initWithGLStrings(
34 GLubyte const* vendor,
35 GLubyte const* renderer,
36 GLubyte const* version,
37 GLubyte const* extensions)
38{
39 mVendor = (char const*)vendor;
40 mRenderer = (char const*)renderer;
41 mVersion = (char const*)version;
42 mExtensions = (char const*)extensions;
43
44 char const* curr = (char const*)extensions;
45 char const* head = curr;
46 do {
47 head = strchr(curr, ' ');
48 String8 s(curr, head ? head-curr : strlen(curr));
49 if (s.length()) {
50 mExtensionList.add(s);
51 }
52 curr = head+1;
53 } while (head);
54
55 if (hasExtension("GL_OES_framebuffer_object")) {
56 mHaveFramebufferObject = true;
57 }
58}
59
60bool GLExtensions::hasExtension(char const* extension) const
61{
62 const String8 s(extension);
63 return mExtensionList.indexOf(s) >= 0;
64}
65
66char const* GLExtensions::getVendor() const {
67 return mVendor.string();
68}
69
70char const* GLExtensions::getRenderer() const {
71 return mRenderer.string();
72}
73
74char const* GLExtensions::getVersion() const {
75 return mVersion.string();
76}
77
78char const* GLExtensions::getExtension() const {
79 return mExtensions.string();
80}
81
82// ---------------------------------------------------------------------------
83}; // namespace android