summaryrefslogtreecommitdiffstats
path: root/jni/feature_mos/src/mosaic_renderer/WarpRenderer.h
blob: 2f50c6f349cfa9b94b15c4225abf95296f6dcb37 (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
45
46
47
48
49
50
#pragma once

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

#include <GLES2/gl2.h>

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

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

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

    void SetViewportMatrix(int w, int h, int W, int H);
    void SetScalingMatrix(float xscale, float yscale);
    void SetRotation(int degree);
    bool DrawTexture(GLfloat *affine);

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

    GLuint mTexHandle;                  // Handle to s_texture.
    GLuint mTexCoordHandle;             // Handle to a_texCoord.
    GLuint mTriangleVerticesHandle;     // Handle to vPosition.

    // Attribute locations
    GLint  mPositionLoc;
    GLint  mAffinetransLoc;
    GLint  mViewporttransLoc;
    GLint  mScalingtransLoc;
    GLint  mTexCoordLoc;
    GLint  mRotationtransLoc;

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

    // Sampler location
    GLint mSamplerLoc;
};