1 /* 2 * Copyright 2011 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 #ifndef GLES_V2_CONTEXT_H 18 #define GLES_V2_CONTEXT_H 19 20 #include <GLcommon/GLDispatch.h> 21 #include <GLcommon/GLEScontext.h> 22 #include <GLcommon/objectNameManager.h> 23 #include <utils/threads.h> 24 25 26 27 class GLESv2Context : public GLEScontext{ 28 public: 29 void init(); 30 GLESv2Context(); 31 virtual ~GLESv2Context(); 32 void setupArraysPointers(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct); 33 int getMaxTexUnits(); 34 35 // This whole att0 thing is about a incompatibility between GLES and OpenGL. 36 // GLES allows a vertex shader attribute to be in location 0 and have a 37 // current value, while OpenGL is not very clear about this, which results 38 // in each implementation doing something different. 39 void setAttribute0value(float x, float y, float z, float w); 40 void validateAtt0PreDraw(unsigned int count); 41 void validateAtt0PostDraw(void); 42 const float* getAtt0(void) {return m_attribute0value;} 43 44 protected: 45 bool needConvert(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLESpointer* p,GLenum array_id); 46 private: 47 void setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride,GLboolean normalized, int pointsIndex = -1); 48 void initExtensionString(); 49 50 float m_attribute0value[4]; 51 GLfloat* m_att0Array; 52 unsigned int m_att0ArrayLength; 53 bool m_att0NeedsDisable; 54 }; 55 56 #endif 57