Do not support translation/rotation for textures we render
This commit is contained in:
parent
1aeedaf199
commit
905a1a9fb1
3 changed files with 8 additions and 27 deletions
|
|
@ -335,7 +335,7 @@ bool ColorBuffer::blitFromCurrentReadBuffer()
|
|||
s_gles2.glViewport(0, 0, m_width, m_height);
|
||||
|
||||
// render m_blitTex
|
||||
m_helper->getTextureDraw()->draw(m_blitTex, 0., 0, 0);
|
||||
m_helper->getTextureDraw()->draw(m_blitTex);
|
||||
|
||||
// Restore previous viewport.
|
||||
s_gles2.glViewport(vport[0], vport[1], vport[2], vport[3]);
|
||||
|
|
@ -380,7 +380,7 @@ bool ColorBuffer::bindToRenderbuffer() {
|
|||
|
||||
bool ColorBuffer::post(float rotation, float dx, float dy) {
|
||||
// NOTE: Do not call m_helper->setupContext() here!
|
||||
return m_helper->getTextureDraw()->draw(m_resizer->update(m_tex), rotation, dx, dy);
|
||||
return m_helper->getTextureDraw()->draw(m_resizer->update(m_tex));
|
||||
}
|
||||
|
||||
void ColorBuffer::readback(unsigned char* img) {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -38,11 +38,8 @@ public:
|
|||
~TextureDraw();
|
||||
|
||||
// Fill the current framebuffer with the content of |texture|, which must
|
||||
// be the name of a GLES 2.x texture object. |rotationDegrees| is a
|
||||
// clockwise rotation angle in degrees (clockwise in the GL Y-upwards
|
||||
// coordinate space). |dx,dy| is the translation of the image towards the
|
||||
// origin.
|
||||
bool draw(GLuint texture, float rotationDegrees, float dx, float dy);
|
||||
// be the name of a GLES 2.x texture object.
|
||||
bool draw(GLuint texture);
|
||||
|
||||
private:
|
||||
EGLDisplay mDisplay;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue