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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:32:17+00:00 2026-05-27T09:32:17+00:00

I’m trying to use QGLbuffer to display an image. Sequence is something like: initializeGL()

  • 0

I’m trying to use QGLbuffer to display an image.
Sequence is something like:

initializeGL() {
  glbuffer= QGLBuffer(QGLBuffer::PixelUnpackBuffer);        
  glbuffer.create();
  glbuffer.bind();
  glbuffer.allocate(image_width*image_height*4); // RGBA
  glbuffer.release();
}

// Attempting to write an image directly the graphics memory.
// map() should map the texture into the address space and give me an address in the   
// to write directly to  but always returns NULL
unsigned char* dest = glbuffer.map(QGLBuffer::WriteOnly);  FAILS
MyGetImageFunction( dest );         
glbuffer.unmap();

paint() {
  glbuffer.bind();
    glBegin(GL_QUADS);
    glTexCoord2i(0,0); glVertex2i(0,height());
    glTexCoord2i(0,1); glVertex2i(0,0);
    glTexCoord2i(1,1); glVertex2i(width(),0);
    glTexCoord2i(1,0); glVertex2i(width(),height());
    glEnd();             
  glbuffer.release();
}

There aren’t any examples of using GLBuffer in this way, it’s pretty new

Edit — for search here is the working solution ——-

 // Where glbuffer is defined as  
 glbuffer= QGLBuffer(QGLBuffer::PixelUnpackBuffer); 

// sequence to get a pointer into a PBO, write data to it and copy it to a texture
glbuffer.bind(); // bind before doing anything
unsigned char *dest = (unsigned char*)glbuffer.map(QGLBuffer::WriteOnly);
MyGetImageFunction(dest);                           
glbuffer.unmap(); // need to unbind before the rest of openGL can access the PBO

glBindTexture(GL_TEXTURE_2D,texture);                       
// Note 'NULL' because memory is now onboard the card                                                                                   
glTexSubImage2D(GL_TEXTURE_2D, 0, 0,0, image_width, image_height, glFormatExt, glType, NULL);  
glbuffer.release();  // but don't release until finished the copy


// PaintGL function
glBindTexture(GL_TEXTURE_2D,textures);
glBegin(GL_QUADS);
    glTexCoord2i(0,0); glVertex2i(0,height());
    glTexCoord2i(0,1); glVertex2i(0,0);
    glTexCoord2i(1,1); glVertex2i(width(),0);
    glTexCoord2i(1,0); glVertex2i(width(),height());
glEnd();             
  • 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-27T09:32:18+00:00Added an answer on May 27, 2026 at 9:32 am

    You should bind the buffer before mapping it!

    In the documentation for QGLBuffer::map:

    It is assumed that create() has been called on this buffer and that it has been bound to the current context.

    In addition to VJovic’s comments, I think you are missing a few points about PBOs:

    A pixel unpack buffer does not give you a pointer to the graphics texture. It is a separate piece of memory allocated on the graphics card to which you can write to directly from the CPU.

    The buffer can be copied into a texture by a glTexSubImage2D(….., 0) call, with the texture being bound as well, which you do not do. (0 is the offset into the pixel buffer). The copy is needed partly because textures have a different layout than linear pixel buffers.

    See this page for a good explanation of PBO usages (I used it a few weeks ago to do async texture upload).

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace

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.