TYPE3
[iec.git] / src / type3_AndroidCloud / anbox-master / src / anbox / graphics / emugl / TextureDraw.h
1 // Copyright (C) 2015 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef TEXTURE_DRAW_H
16 #define TEXTURE_DRAW_H
17
18 #include <EGL/egl.h>
19 #include <GLES2/gl2.h>
20
21 // Helper class used to draw a simple texture to the current framebuffer.
22 // Usage is pretty simple:
23 //
24 //   1) Create a TextureDraw instance, passing the current EGLDisplay to it.
25 //
26 //   2) Each time you want to draw a texture, call draw(texture, rotation),
27 //      where |texture| is the name of a GLES 2.x texture object, and
28 //      |rotation| is an angle in degrees describing the clockwise rotation
29 //      in the GL y-upwards coordinate space. This function fills the whole
30 //      framebuffer with texture content.
31 //
32 class TextureDraw {
33  public:
34   // Create a new instance.
35   TextureDraw(EGLDisplay display);
36
37   // Destructor
38   ~TextureDraw();
39
40   // Fill the current framebuffer with the content of |texture|, which must
41   // be the name of a GLES 2.x texture object.
42   bool draw(GLuint texture);
43
44  private:
45   GLuint mVertexShader;
46   GLuint mFragmentShader;
47   GLuint mProgram;
48   GLint mPositionSlot;
49   GLint mInCoordSlot;
50   GLint mTextureSlot;
51   GLuint mVertexBuffer;
52   GLuint mIndexBuffer;
53 };
54
55 #endif  // TEXTURE_DRAW_H