Do not support translation/rotation for textures we render

This commit is contained in:
Simon Fels 2016-11-09 09:42:57 +01:00
commit 905a1a9fb1
3 changed files with 8 additions and 27 deletions

View file

@ -57,20 +57,14 @@ GLuint createShader(GLint shaderType, const char* shaderText) {
}
// No scaling / projection since we want to fill the whole viewport with
// the texture, hence a trivial vertex shader that only supports clockwise
// rotation.
// the texture, hence a trivial vertex shader.
const char kVertexShaderSource[] =
"attribute vec4 position;\n"
"attribute vec2 inCoord;\n"
"varying lowp vec2 outCoord;\n"
"uniform float rotation;\n"
"uniform vec2 translation;\n"
"void main(void) {\n"
" float cs = cos(rotation);\n"
" float sn = sin(rotation);\n"
" gl_Position.x = position.x * cs + position.y * sn - translation.x;\n"
" gl_Position.y = position.y * cs - position.x * sn - translation.y;\n"
" gl_Position.x = position.x;\n"
" gl_Position.y = position.y;\n"
" gl_Position.zw = position.zw;\n"
" outCoord = inCoord;\n"
"}\n";
@ -142,15 +136,8 @@ TextureDraw::TextureDraw(EGLDisplay display) :
mInCoordSlot = s_gles2.glGetAttribLocation(mProgram, "inCoord");
s_gles2.glEnableVertexAttribArray(mInCoordSlot);
mRotationSlot = s_gles2.glGetUniformLocation(mProgram, "rotation");
mTranslationSlot = s_gles2.glGetUniformLocation(mProgram, "translation");
mTextureSlot = s_gles2.glGetUniformLocation(mProgram, "texture");
#if 0
printf("SLOTS position=%d inCoord=%d texture=%d rotation=%d\n",
mPositionSlot, mInCoordSlot, mTextureSlot, mRotationSlot);
#endif
// Create vertex and index buffers.
s_gles2.glGenBuffers(1, &mVertexBuffer);
s_gles2.glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer);
@ -165,7 +152,7 @@ TextureDraw::TextureDraw(EGLDisplay display) :
GL_STATIC_DRAW);
}
bool TextureDraw::draw(GLuint texture, float rotation, float dx, float dy) {
bool TextureDraw::draw(GLuint texture) {
if (!mProgram) {
ERR("%s: no program\n", __FUNCTION__);
return false;
@ -220,9 +207,6 @@ bool TextureDraw::draw(GLuint texture, float rotation, float dx, float dy) {
s_gles2.glBindTexture(GL_TEXTURE_2D, texture);
s_gles2.glUniform1i(mTextureSlot, 0);
// setup the |rotation| uniform value.
s_gles2.glUniform1f(mRotationSlot, rotation * M_PI / 180.);
s_gles2.glUniform2f(mTranslationSlot, dx, dy);
#if 1
// Validate program, just to be sure.