LAMW - DrawTexture Bug lazarus / 43-Android ---------------------------------------------------------------------- Handoko · 2017-11-12 13:04 Tested on LAMW rev 684, jCanvasES2.DrawTexture always draws the texture flipped horizontally. This issue also happens on AppDemo1 > OpenGL2 2D, I compared the result on the screen and the original image file, they're flipped. I found the bug is in Laz_And-GLESv2_Canvas.pas: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure jCanvasES2.DrawTexture(const Texture : TxgElement; const Pt4 : Txy4CW; Z : Single;                                 Alpha : Single; Effect : TxgShader = Shader_Texture);var  T : Array[0..3] of TXY;  P : Array[0..3] of TXYZ; // i : Integer;begin  //  if not FInitialized then Exit;  P[0] := _XY_Z(Pt4[2],Z);  P[1] := _XY_Z(Pt4[1],Z);  P[2] := _XY_Z(Pt4[3],Z);  P[3] := _XY_Z(Pt4[0],Z);  //  T[0] := _XY(1,0);  T[1] := _XY(1,1);  T[2] := _XY(0,0);  T[3] := _XY(0,1);  //  SetShader  (Effect);  SetAlpha   (Alpha );  //  SetVertex  (@P );  SetColor   (nil);  SetTexture (@T );  BindTexture(Texture);  //  glDrawArrays(GL_TRIANGLE_STRIP,0,4);end; Here is the code I suggest to fix the bug: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure jCanvasES2.DrawTexture(const Texture : TxgElement; const Pt4 : Txy4CW; Z : Single;                                 Alpha : Single; Effect : TxgShader = Shader_Texture);var  T : Array[0..3] of TXY;  P : Array[0..3] of TXYZ;begin  //  if not FInitialized then Exit;  P[0] := _XY_Z(Pt4[2],Z);  P[1] := _XY_Z(Pt4[1],Z);  P[2] := _XY_Z(Pt4[3],Z);  P[3] := _XY_Z(Pt4[0],Z);  //  T[0] := _XY(0,0);  T[1] := _XY(0,1);  T[2] := _XY(1,0);  T[3] := _XY(1,1);  //  SetShader  (Effect);  SetAlpha   (Alpha );  //  SetVertex  (@P );  SetColor   (nil);  SetTexture (@T );  BindTexture(Texture);  //  glDrawArrays(GL_TRIANGLE_STRIP,0,4);end; The screenshots below are the test results using the original code (left) and my suggestion (right): ---------------------------------------------------------------------- jmpessoa · 2017-11-12 17:44 Great! I applied your patch!! [and a minor change/fix in "androidwidgets.pas" to improve support to jForm method "ReInit"  and a "must have" fix in "androidthemes.pas" by @A.S to prevent IDE crash when open multi-forms app like "AppDemo1"] Thanks to All!