Why I need exchange X, Y axis bitmap pixel for correct drawing through glDrawPixels?
For i := 0 to ImageHeight - 1 do
For j := 0 to ImageWidth - 1 do
PixCol := Bitmap.Canvas.Pixels [j, i];
Image[ImageHeight - i - 1][j] := PixCol and $FF;
Image[ImageHeight - i - 1][j] := (PixCol and $FF00) shr 8;
Image[ImageHeight - i - 1][j] := (PixCol and $FF0000) shr 16;
glDrawPixels(ImageWidth, ImageHeight, GL_RGB, GL_UNSIGNED_BYTE, @Image);
Images in OpenGL are column minor.
+1 pixel in memory is + 1 pixel to the right, it is just the convention that OpenGL uses.
Your image array uses subscript j as the minor axis (w.r.t. i)and increments it up to image width. So this is correct.
You address the image as bytes so there is an additional minor axis for the color components.
You also use -i rather than i, this again is convention and depends which image format you use. OpenGL has a convention that images start lower left and progress upwards, some image formats start top left and need to be flipped as you have done here.
P.S. globally substitute j for column or xpos and substitute i for row or ypos and you’ll have a clearer understanding I think.