Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7085341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:24:46+00:00 2026-05-28T07:24:46+00:00

I am trying to use a hardware optimized 2D library to zoom (non-interpolated scaling)

  • 0

I am trying to use a hardware optimized 2D library to zoom (non-interpolated scaling) in and out of an image. Right now I am

  1. Loading the original image
  2. Making a copy of the original image
  3. Using the 2D library to “zoom” into the copy
  4. Generating textures using glTexImage2D from the images
  5. Applying them to rectangles that I drew

I can’t upload images (yet) but here is a link to a screenshot.
http://img.photobucket.com/albums/v336/prankstar008/zoom.png

I would like to zoom in and out of the image on the right by a certain amount every frame, and rather than kill my performance by using glTexImage2D every time, I would like to render to a texture. My questions are

  1. Is this a valid application of rendering to a texture? For clarification, the 2D library takes a pointer to a buffer filled with raw RGB(A) data, and returns a pointer to the new data with the 2D operation applied.
  2. I think most of my confusion has to do with how textures interact with shaders. Can someone explain the simplest way to apply a texture to a surface in GLES2? I obviously have something working, and I can post snippets of code if necessary.
  3. Also for clarification, although I’m not sure it matters, this is being run on Android.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:24:46+00:00Added an answer on May 28, 2026 at 7:24 am

    1) No, it is not. If you just want to zoom in and out of the image (without using your zoom library), then rendering to another texture would be a waste of time. You can zoom directly in your view.

    2) Shaders are programs, that are capable of calculating and transforming coordinates (that is usually done in vertex shaders) and are able to use those coordinates to read from texture (that can only be done in fragment shader at the time).

    I believe your shaders could look like this:

    precision mediump float;
    
    uniform matrix4 modelviewProjectionMatrix; // input transformation matrix
    
    attribute vec3 position;
    attribute vec2 texcoord; // input coordinates of each vertex
    
    varying vec2 _texcoord; // output coordinate for fragment shader
    
    void main()
    {
        gl_Position = modelviewProjectionMatrix * vec4(position, 1.0); // transform position
        _texcoord = texcoord; // copy texcoord
    }
    

    That was vertex shader, and now fragment shader:

    precision mediump float;
    
    varying vec2 _texcoord; // input coordinate from vertex shader
    
    uniform sampler2D _sampler; // handle of a texturing unit (e.g. 0 for GL_TEXTURE0)
    
    void main()
    {
        gl_FragColor = glTexture2D(_sampler, _texcoord); // read texture
    }
    

    What you can do, is to include a zoom parameter (so called uniform) in vertex shader:

    precision mediump float;
    
    uniform float zoom; // zoom
    uniform matrix4 modelviewProjectionMatrix; // input transformation matrix
    
    attribute vec3 position;
    attribute vec2 texcoord; // input coordinates of each vertex
    
    varying vec2 _texcoord; // output coordinate for fragment shader
    
    void main()
    {
        gl_Position = modelviewProjectionMatrix * vec4(position, 1.0); // transform position
        _texcoord = (texcoord - .5) * zoom + .5; // zoom texcoord
    }
    

    There are no changes in fragment shader. This just calculates different coordinates for it, and that’s how simple it is. To set zoom, you need to:

    int zoomLocation = glGetUniformLocation(yourProgram, "zoom");
    // this is done in init, where you call glGetUniformLocation(yourProgram, "modelviewProjectionMatrix")
    // also, zoomLocation is not local variable, it needs to be stored somewhere to be used later when drawing
    
    glUniform1f(zoomLocation, 1 + .5f * (float)Math.sin(System.nanotime() * 1e-8f));
    // this will set zoom that will animatically zoom in and out of the texture (must be called after glUseProgram(yourProgram))
    

    Now this will cause both textures to zoom in and out. To fix this (I assume you only want the right texture to be zooming), you need to:

    // draw the second quad
    
    glUniform1f(zoomLocation, 1);
    // this will set no zoom (1:1 scale)
    
    // draw the first quad
    

    I hope this helps …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to port over the Hardware Serial library that now comes with
I can't find much information out there on Android's hardware compass. I keep trying
I'm trying to use devcon.exe to check the status of various pieces of hardware.
I'm trying to use the .NET Micro Framework's Microsoft.SPOT.Hardware.InterruptPort class. However, the documentation perplexes
I'm trying to use a mutex to protect access to some hardware from multiple
I was trying use a set of filter functions to run the appropriate routine,
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I am trying use a Java Uploader in a ROR app (for its ease
Hi I'm trying use a datepicker on a field I have. I'm trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.