c++ - glReadPixels not updating the value -


glreadpixels not getting updated draw point.

  glcolor3f(1.0f, 0.0f, 0.0f);    glbegin(gl_points);     glvertex2f(x,y);   glend();   glreadpixels(x, y, 1, 1, gl_rgb, gl_unsigned_byte, pixel);    printf("after coloring %d %d %d\n", (int)pixel[0], (int)pixel[1] , (int)pixel[2]); 

the values of pixel[0], pixel[1] , pixel[2] coming out 0 expected value 255, 0, 0. me resolve issue :)

this due number of issues

  • model ndc space transformation not set produce 1:1 mapping vertex coordinates pixel location

  • you did try set such transformation, points end in neighbor pixel, due roundoff errors , because opengl pixel centers kind of unintuitive (they make sense, mathematically)

  • the read buffer not set buffer you're drawing (gldrawbuffer, glreadbuffer)

post full code , able reproduce , further.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -