2 * Copyright 2013 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef SF_RENDER_ENGINE_PROGRAM_H
18 #define SF_RENDER_ENGINE_PROGRAM_H
22 #include <GLES2/gl2.h>
24 #include "Description.h"
25 #include "ProgramCache.h"
32 * Abstracts a GLSL program comprising a vertex and fragment shader
36 // known locations for position and texture coordinates
37 enum { position=0, texCoords=1 };
39 Program(const ProgramCache::Key& needs, const char* vertex, const char* fragment);
42 /* whether this object is usable */
45 /* Binds this program to the GLES context */
48 /* Returns the location of the specified attribute */
49 GLuint getAttrib(const char* name) const;
51 /* Returns the location of the specified uniform */
52 GLint getUniform(const char* name) const;
54 /* set-up uniforms from the description */
55 void setUniforms(const Description& desc);
59 GLuint buildShader(const char* source, GLenum type);
60 String8& dumpShader(String8& result, GLenum type);
62 // whether the initialization succeeded
65 // Name of the OpenGL program and shaders
68 GLuint mFragmentShader;
70 /* location of the projection matrix uniform */
71 GLint mProjectionMatrixLoc;
73 /* location of the color matrix uniform */
74 GLint mColorMatrixLoc;
76 /* location of the texture matrix uniform */
77 GLint mTextureMatrixLoc;
79 /* location of the sampler uniform */
82 /* location of the alpha plane uniform */
85 /* location of the color uniform */
88 GLint mSamplerMaskLoc;
89 GLint mMaskAlphaThresholdLoc;
93 } /* namespace android */
95 #endif /* SF_RENDER_ENGINE_PROGRAM_H */