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

  • Home
  • SEARCH
  • 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 8383169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:05:52+00:00 2026-06-09T17:05:52+00:00

I want to dump raw texture data to disk (to read back later), and

  • 0

I want to dump raw texture data to disk (to read back later), and I’m not sure about glReadPixel will read from the currently bound texture.

How can I read the buffer from my texture?

  • 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-09T17:05:53+00:00Added an answer on June 9, 2026 at 5:05 pm

    glReadPixels function reads from framebuffers, not textures. To read a texture object you must use glGetTexImage but it isn’t available in OpenGL ES 🙁

    If you want to read the buffer from your texture then you can bind it to an FBO (FrameBuffer Object) and use glReadPixels:

    //Generate a new FBO. It will contain your texture.
    glGenFramebuffersOES(1, &offscreen_framebuffer);
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, offscreen_framebuffer);
    
    //Create the texture 
    glGenTextures(1, &my_texture);
    glBindTexture(GL_TEXTURE_2D, my_texture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,  width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    
    //Bind the texture to your FBO
    glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, my_texture, 0);
    
    //Test if everything failed    
    GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
    if(status != GL_FRAMEBUFFER_COMPLETE_OES) {
        printf("failed to make complete framebuffer object %x", status);
    }
    

    Then, you only must call to glReadPixels when you want to read from your texture:

    //Bind the FBO
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, offscreen_framebuffer);
    // set the viewport as the FBO won't be the same dimension as the screen
    glViewport(0, 0, width, height);
    
    GLubyte* pixels = (GLubyte*) malloc(width * height * sizeof(GLubyte) * 4);
    glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
    
    //Bind your main FBO again
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, screen_framebuffer);
    // set the viewport as the FBO won't be the same dimension as the screen
    glViewport(0, 0, screen_width, screen_height);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to dump data from db to file in view. But I have
I want to dump my data from the model of my app in Django.
I have two databases. I want to dump data from one table in 1st
Seeing lots of SOAP/RDS stuff, but just want to dump some MySQL data and/or
I want to retrieve stack trace from a user dump file programmatically . There
I want to validate below data using regex and python. Below is the dump
I have a two dump files of raw video and raw audio from an
I have a FloatBuffer of known size and just want to dump the data
For some reason, I want to dump a table from a database (sqlite3) in
I want to dump a backtrace from a C++ program in Linux in a

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.