1875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian/* 2875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * Copyright (C) 2010 The Android Open Source Project 3875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * 4875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * Licensed under the Apache License, Version 2.0 (the "License"); 5875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * you may not use this file except in compliance with the License. 6875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * You may obtain a copy of the License at 7875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * 8875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * http://www.apache.org/licenses/LICENSE-2.0 9875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * 10875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * Unless required by applicable law or agreed to in writing, software 11875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * distributed under the License is distributed on an "AS IS" BASIS, 12875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * See the License for the specific language governing permissions and 14875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * limitations under the License. 15875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian */ 16875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 17875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian#include <stdlib.h> 18875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian#include <stdio.h> 19875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian#include <stdint.h> 20875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 21875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian#include "GLExtensions.h" 22875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 23875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopiannamespace android { 24875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian// --------------------------------------------------------------------------- 25875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 26875d8e1323536e16dcfc90c9674d7ad32116a69aMathias AgopianANDROID_SINGLETON_STATIC_INSTANCE( GLExtensions ) 27875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 28875d8e1323536e16dcfc90c9674d7ad32116a69aMathias AgopianGLExtensions::GLExtensions() 29875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian : mHaveFramebufferObject(false) 30875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian{ 31875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian} 32875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 33875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopianvoid GLExtensions::initWithGLStrings( 34875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian GLubyte const* vendor, 35875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian GLubyte const* renderer, 36875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian GLubyte const* version, 37875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian GLubyte const* extensions) 38875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian{ 39875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian mVendor = (char const*)vendor; 40875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian mRenderer = (char const*)renderer; 41875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian mVersion = (char const*)version; 42875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian mExtensions = (char const*)extensions; 43875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 44875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian char const* curr = (char const*)extensions; 45875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian char const* head = curr; 46875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian do { 47875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian head = strchr(curr, ' '); 48875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian String8 s(curr, head ? head-curr : strlen(curr)); 49875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian if (s.length()) { 50875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian mExtensionList.add(s); 51875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian } 52875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian curr = head+1; 53875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian } while (head); 54875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 55875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian if (hasExtension("GL_OES_framebuffer_object")) { 56875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian mHaveFramebufferObject = true; 57875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian } 58875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian} 59875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 60875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopianbool GLExtensions::hasExtension(char const* extension) const 61875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian{ 62875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian const String8 s(extension); 63875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian return mExtensionList.indexOf(s) >= 0; 64875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian} 65875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 66875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopianchar const* GLExtensions::getVendor() const { 67875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian return mVendor.string(); 68875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian} 69875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 70875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopianchar const* GLExtensions::getRenderer() const { 71875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian return mRenderer.string(); 72875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian} 73875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 74875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopianchar const* GLExtensions::getVersion() const { 75875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian return mVersion.string(); 76875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian} 77875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 78875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopianchar const* GLExtensions::getExtension() const { 79875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian return mExtensions.string(); 80875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian} 81875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 82875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian// --------------------------------------------------------------------------- 83875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian}; // namespace android 84