Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. OpenGL scale texture coordinates
Qt 6.12 LTS is out! See what's new in the release blog

OpenGL scale texture coordinates

Scheduled Pinned Locked Moved General and Desktop
openglshader
1 Posts 1 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex M
    wrote on last edited by
    #1

    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;
        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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt
    • Unsolved