Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: how to make a non smooth zoom

  1. #1
    Junior Member Newbie
    Join Date
    May 2009
    Location
    Brazil
    Posts
    6

    how to make a non smooth zoom

    Hello!

    I've been trying to make a zoom on openGL without smoothing the pixels, cause I need to see each pixel when I zoom in the imagem. But I still didn't have any success on this. I'm loading the image using SDL, then loading it like texture to openGL, and zooming with glTranslate(); I tried using glScale, but it still smooth the pixels. Is there any flag or function to disable the smooth on openGL?

    Thx.
    SSantos

  2. #2
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Nov 2010
    Posts
    2,466

    Re: how to make a non smooth zoom

    pixels?
    are u talking about a texture? if so use GL_NEAREST instead of GL_LINEAR when u specify the texture_filtering

  3. #3
    Member Contributor
    Join Date
    May 2009
    Posts
    57

    Re: how to make a non smooth zoom

    Yes indeed that's the way to do this

  4. #4
    Junior Member Newbie
    Join Date
    May 2009
    Location
    Brazil
    Posts
    6

    Re: how to make a non smooth zoom

    yeah, I'm talking about texture. I'm using this:

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

    and it still smooth when I zoom in, is anything wrong in that?
    SSantos

  5. #5
    Junior Member Newbie
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    14

    Re: how to make a non smooth zoom

    hi, i might be wrong cause im a noob as well.

    but i did some similar non-smoothing zoom feature for my openGL videoplayer, by using LINEAR for the texture, not NEAREST (isnt it? cause linear take the pixel as it is, while nearest smooths it?), and modify the z axis of the glTranslatef, with keyboard input

  6. #6
    Junior Member Newbie
    Join Date
    May 2009
    Location
    Brazil
    Posts
    6

    Re: how to make a non smooth zoom

    I just tried using GL_LINEAR and it still smooth the image when I zoom in.
    SSantos

  7. #7
    Junior Member Newbie
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    14

    Re: how to make a non smooth zoom

    im sorry i was wrong, i dont think linear is the right solution for you.
    in my app, if i use nearest, then the picture is jagged, so i use linear to load the real pixel value.
    btw, i found nice sample to test texture filtering parameters:
    http://www.xmission.com/~nate/tutors.html
    the texture tutorial program.

  8. #8
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: how to make a non smooth zoom

    For zoom, it is MAGnification filter you have to change :
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

  9. #9
    Member Newbie
    Join Date
    Oct 2009
    Posts
    34

    Re: how to make a non smooth zoom

    When you sampling a texture with GL_NEAREST, it will search the nearest texel in the texture for the given texture coordinates. So, this won't be smooth. The center of the sampled pixel is represented as a red point on the image.

    Using GL_LINEAR will make a linear interpolation using the four nearest texels. Each texel's weight is proportional with the area of the rectangle formed with the center of the catercorner texel and the uv point. So, this will be "smooth".



    If it's still smooth with GL_LINEAR, maybe there's some option in the nvidia or ati control center that could force linear filtering of textures.

  10. #10
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: how to make a non smooth zoom

    thekend, your last sentence does not makes any sense.

    And the OP wants "zoom on openGL without smoothing the pixels", and that means GL_TEXTURE_MAG_FILTER, GL_NEAREST.

Page 1 of 2 12 LastLast

Similar Threads

  1. How to make smooth animation of tiles, while they loading?
    By Kovaczboi in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-10-2018, 09:59 AM
  2. Replies: 0
    Last Post: 01-06-2015, 09:42 AM
  3. How to implement smooth ZOOM???
    By immy in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 05-07-2002, 06:41 AM
  4. Make a zoom
    By Bra'Tac in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-02-2001, 10:05 AM
  5. Replies: 0
    Last Post: 03-15-2001, 02:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean