Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. OpenGL scale texture coordinates
Forum Updated to NodeBB v4.3 + New Features

OpenGL scale texture coordinates

Scheduled Pinned Locked Moved General and Desktop
openglshader
1 Posts 1 Posters 1.7k 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 21 Sept 2015, 10:32 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

    1/1

    21 Sept 2015, 10:32

    • Login

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