141a2e9735136f372de95652d0828600282c8e967mbansal#pragma once
241a2e9735136f372de95652d0828600282c8e967mbansal
341a2e9735136f372de95652d0828600282c8e967mbansal#include "FrameBuffer.h"
41e762b1f935c9d4a06af6dd56121590ca81d48b1mbansal#include "Renderer.h"
541a2e9735136f372de95652d0828600282c8e967mbansal
641a2e9735136f372de95652d0828600282c8e967mbansal#include <GLES2/gl2.h>
741a2e9735136f372de95652d0828600282c8e967mbansal
841a2e9735136f372de95652d0828600282c8e967mbansal#include <stdint.h>
941a2e9735136f372de95652d0828600282c8e967mbansal#include <stdio.h>
1041a2e9735136f372de95652d0828600282c8e967mbansal#include <stdlib.h>
1141a2e9735136f372de95652d0828600282c8e967mbansal
121e762b1f935c9d4a06af6dd56121590ca81d48b1mbansalclass SurfaceTextureRenderer: public Renderer {
1341a2e9735136f372de95652d0828600282c8e967mbansal  public:
1441a2e9735136f372de95652d0828600282c8e967mbansal    SurfaceTextureRenderer();
1541a2e9735136f372de95652d0828600282c8e967mbansal    virtual ~SurfaceTextureRenderer();
1641a2e9735136f372de95652d0828600282c8e967mbansal
1741a2e9735136f372de95652d0828600282c8e967mbansal    // Initialize OpenGL resources
1841a2e9735136f372de95652d0828600282c8e967mbansal    // @return true if successful
1941a2e9735136f372de95652d0828600282c8e967mbansal    bool InitializeGLProgram();
2041a2e9735136f372de95652d0828600282c8e967mbansal
211e762b1f935c9d4a06af6dd56121590ca81d48b1mbansal    bool DrawTexture(GLfloat *affine);
2241a2e9735136f372de95652d0828600282c8e967mbansal
2341a2e9735136f372de95652d0828600282c8e967mbansal    void SetViewportMatrix(int w, int h, int W, int H);
2441a2e9735136f372de95652d0828600282c8e967mbansal    void SetScalingMatrix(float xscale, float yscale);
2541a2e9735136f372de95652d0828600282c8e967mbansal    void SetSTMatrix(float *stmat);
2641a2e9735136f372de95652d0828600282c8e967mbansal
2741a2e9735136f372de95652d0828600282c8e967mbansal private:
2841a2e9735136f372de95652d0828600282c8e967mbansal    // Source code for shaders.
291e762b1f935c9d4a06af6dd56121590ca81d48b1mbansal    const char* VertexShaderSource() const;
301e762b1f935c9d4a06af6dd56121590ca81d48b1mbansal    const char* FragmentShaderSource() const;
3141a2e9735136f372de95652d0828600282c8e967mbansal
3241a2e9735136f372de95652d0828600282c8e967mbansal    // Attribute locations
3341a2e9735136f372de95652d0828600282c8e967mbansal    GLint  mScalingtransLoc;
3441a2e9735136f372de95652d0828600282c8e967mbansal    GLint muSTMatrixHandle;
3541a2e9735136f372de95652d0828600282c8e967mbansal    GLint maPositionHandle;
3641a2e9735136f372de95652d0828600282c8e967mbansal    GLint maTextureHandle;
3741a2e9735136f372de95652d0828600282c8e967mbansal
3841a2e9735136f372de95652d0828600282c8e967mbansal    GLfloat mViewportMatrix[16];
3941a2e9735136f372de95652d0828600282c8e967mbansal    GLfloat mScalingMatrix[16];
4041a2e9735136f372de95652d0828600282c8e967mbansal
411e762b1f935c9d4a06af6dd56121590ca81d48b1mbansal    GLfloat mSTMatrix[16];
4241a2e9735136f372de95652d0828600282c8e967mbansal
4341a2e9735136f372de95652d0828600282c8e967mbansal};
4441a2e9735136f372de95652d0828600282c8e967mbansal
45