Login  Register

Re: Strange phenomenon about glDrawPixels, Any one can help me ?

Posted by elect on Aug 07, 2015; 7:47am
URL: https://forum.jogamp.org/Strange-phenomenon-about-glDrawPixels-Any-one-can-help-me-tp4035033p4035044.html

george2008 wrote
>There is probably a problem of alignment:
>http://forum.jogamp.org/glTexImage2D-error-td4033393.html

Do you have any plan to fix it ?

It works like this, you need a buffer

(h-1) * (w + (alignemnt - w % alignment)) + w

bytes big

given:

int w = 587;
int h = 888;
alignment = 4 byte

your buffer will be

   887 * (587 + (4 - 587 % 4)) + 587 =
= 887 * (587 + 1) + 587 = 522143

bytes

This is because data gets loaded line by line based on the alignment, except the last line which seems it doesnt matter

int h = 587;
int w = 888;

works out of the box because w fits perfectly the 4 bytes alignment (888 % 4 = 0)

https://www.opengl.org/wiki/Common_Mistakes#Texture_upload_and_pixel_reads