Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: Grab the screen, make a a smaller version of it in a texture

Hybrid View

  1. #1
    Intern Contributor
    Join Date
    May 2011
    Location
    Alabama, USA
    Posts
    66

    Grab the screen, make a a smaller version of it in a texture

    Hello everyone. This is what I would like to accomplish: Use glReadPixels to grab what's currently on the screen into a texture and then shrink that texture by a certain factor. The degree to which it shrinks horizontally and vertically may be different so the aspect ratio may not be preserved. Any ideas on how to go about doing this?

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264
    If you want to use GLU, it has a function call gluScaleImage.
    My library also has scale function glhScaleImage_asm386.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  3. #3
    Intern Contributor
    Join Date
    May 2011
    Location
    Alabama, USA
    Posts
    66
    Cool! Thanks V-man! I also discovered an algorithm, probably older than I am, that uses nearest-neighbor sampling to accomplish scaling up or down of an image. Thank you for all your help.

  4. #4
    Intern Contributor
    Join Date
    May 2011
    Location
    Alabama, USA
    Posts
    66
    Oh, one other thing, just thought I'd post a link to the algorithm I found online. Here it is:

    http://tech-algorithm.com/articles/n...image-scaling/

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,181
    Do you want to do this at run-time? gluScaleImage or any other method that requires reading from the framebuffer is going to be hugely inappropriate if so.

  6. #6
    Intern Contributor
    Join Date
    May 2011
    Location
    Alabama, USA
    Posts
    66
    Well, I'm actually doing the scaling of the screen image in my initRendering function. Why would gluScaleImage be inappropriate during run-time?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •