OpenGL scale texture coordinates

  • Hi
    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;
    	glViewport( 0, 0, nWidth, nHeight );
    	glMatrixMode( GL_PROJECTION );
    	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.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.