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 8965059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:43:50+00:00 2026-06-15T16:43:50+00:00

So basically I was messing about with LWJGL for a while now, and I

  • 0

So basically I was messing about with LWJGL for a while now, and I came to a sudden stop with with annoyances surrounding glReadPixels().
And why it will only read from left-bottom -> top-right.
So I am here to answer my own question since I figured all this stuff out,
And I am hoping my discoveries might be of some use to someone else.

As a side-note I am using:

glOrtho(0, WIDTH, 0 , HEIGHT, 1, -1);
  • 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-06-15T16:43:51+00:00Added an answer on June 15, 2026 at 4:43 pm

    So here it is my screen-capture code which can be implemented in any LWJGL application C:

    //=========================getScreenImage==================================//
        private void screenShot(){
                 //Creating an rbg array of total pixels
                 int[] pixels = new int[WIDTH * HEIGHT];
                 int bindex;
                 // allocate space for RBG pixels
                 ByteBuffer fb = ByteBuffer.allocateDirect(WIDTH * HEIGHT * 3);
    
                 // grab a copy of the current frame contents as RGB
                 glReadPixels(0, 0, WIDTH, HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, fb);
    
                 BufferedImage imageIn = new BufferedImage(WIDTH, HEIGHT,BufferedImage.TYPE_INT_RGB);
                 // convert RGB data in ByteBuffer to integer array
                 for (int i=0; i < pixels.length; i++) {
                     bindex = i * 3;
                     pixels[i] =
                         ((fb.get(bindex) << 16))  +
                         ((fb.get(bindex+1) << 8))  +
                         ((fb.get(bindex+2) << 0));
                 }
                 //Allocate colored pixel to buffered Image
                 imageIn.setRGB(0, 0, WIDTH, HEIGHT, pixels, 0 , WIDTH);
    
                 //Creating the transformation direction (horizontal)
                 AffineTransform at =  AffineTransform.getScaleInstance(1, -1);
                 at.translate(0, -imageIn.getHeight(null));
    
                 //Applying transformation
                 AffineTransformOp opRotated = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
                 BufferedImage imageOut = opRotated.filter(imageIn, null);
    
                 try {//Try to screate image, else show exception.
                     ImageIO.write(imageOut, format , fileLoc);
                 }
                 catch (Exception e) {
                     System.out.println("ScreenShot() exception: " +e);
                 }
             }
    

    I hope this has been useful.
    For any questions or comments on the code, ask/suggest as you like. C:
    Hugs,
    Rose.

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

Sidebar

Related Questions

Basically, I have a UIImageView that will loop through 8 PNGs over 0.5 seconds.
I have a tricky problem that I've been messing about with for a few
I am learning about piping and shell in a Systems class. I'm messing around
I've worked with many APIs and it's never usually an easy task. Messing about
I have a relatively simple case. I basically want to store data about links
I've only been using R for about 2 weeks, so I'm probably missing something
Basically this is a follow up of this question about most vexing parse. I
I was messing about with reset after reading stuff in the Pro Git book.
I am about to embark on a programming journey, which undoubtedly will end in
For those who don't know about this sort of thing. It's basically 3D vector

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.