summaryrefslogtreecommitdiffstats
path: root/jni/feature_mos/src/mosaic_renderer/SurfaceTextureRenderer.h
blob: ea2b81adea3f5e7c80873f775e15f6a32d07ab90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once

#include "FrameBuffer.h"
#include "Renderer.h"

#include <GLES2/gl2.h>

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

class SurfaceTextureRenderer: public Renderer {
  public:
    SurfaceTextureRenderer();
    virtual ~SurfaceTextureRenderer();

    // Initialize OpenGL resources
    // @return true if successful
    bool InitializeGLProgram();

    bool DrawTexture(GLfloat *affine);

    void SetViewportMatrix(int w, int h, int W, int H);
    void SetScalingMatrix(float xscale, float yscale);
    void SetSTMatrix(float *stmat);

 private:
    // Source code for shaders.
    const char* VertexShaderSource() const;
    const char* FragmentShaderSource() const;

    // Attribute locations
    GLint  mScalingtransLoc;
    GLint muSTMatrixHandle;
    GLint maPositionHandle;
    GLint maTextureHandle;

    GLfloat mViewportMatrix[16];
    GLfloat mScalingMatrix[16];

    GLfloat mSTMatrix[16];

};