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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:16:51+00:00 2026-05-23T13:16:51+00:00

I am using GLUT for my windowing system to output some images onto the

  • 0

I am using GLUT for my windowing system to output some images onto the screen.
I also want to output the images to files. This has been a challenge. In some window resolution (such as 256×256, 1024×1024, 1920×1200), glReadPixels produce exact same image files as the screen. However when I resize the window (ex/ 655×652, 529×566 and do the screen capturing, images are zagged and seems like pixels have shifted linearly.

Any help will be appreciated!

EDIT – I am adding some code leading up to the glReadPixels call.

glGetIntegerv(GL_VIEWPORT, dimensions);
width = dimensions[2];
height = dimensions[3];
screencapture = (unsigned char*)malloc(width*height*sizeof(unsigned char));
glReadPixels(0,0,width, height, GL_GREEN, GL_UNSIGNED_BYTE, screencapture);

EDIT2 – I forgot to mention resizing the window with the mouse some times do produce good images. I guess it happens when I get the resolution just right.

  • 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-23T13:16:51+00:00Added an answer on May 23, 2026 at 1:16 pm

    The solution to your problem would be to either account for the extra bytes at the end of each line that is not a multiple of 4 wide (skipping over them), or to change GL_PACK_ALIGNMENT to 1 (using glPixelStore).

    (see my above comment)

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

Sidebar

Related Questions

How do I draw a text string onto the screen using GLUT / OpenGL
I'm attempting to draw text to the screen using GLUT in 2d. I want
I've been using GLUT for menu'es in openGl programs for some time now, but
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
I am using OpenGL/GLUT to implement Bresenham's line drawing algorithm and having some issues
I have been following this tutorial series for OpenGL : GLUT : http://www.lighthouse3d.com/opengl/glut/ I
I read something from here that said using GLUT is considered unprofessional. Swiftless has
I've been programming opengl using glut as my window handler, lately i've been thinking
In my C++ graphics application using OpenGL and GLUT, I want to enable depth
I have this code in which a user draws some polygon using mouse pointer

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.