Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
OpenGL scale texture coordinates
Alex M last edited by
I use opengl shader for apply median filter to image. Input image I copy to in_fbo buffer. All work fine.
QGLFramebufferObject *in_fbo, *out_fbo; out_fbo->bind(); glViewport( 0, 0, nWidth, nHeight ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( 0.0, nWidth, 0.0, nHeight, -1.0, 1.0 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); glEnable( GL_TEXTURE_2D ); out_fbo->drawTexture( QPointF(0.0,0.0), in_fbo->texture( ), GL_TEXTURE_2D );
But in shader code I need divide position of vertex by width and height of image, because texture coordinates are normalized to a range between 0 and 1.
vec2 texCoord = vec2( pos.x / float( imgWidth ), pos.y / float( imgHeight ) );
How I can scale texture coordinates? I want have texture coordinates in range between 0 and imgWidth, It is important for me.