Is there any way to repeat a texture under FMX (just like GL_REPEAT under OpenGL ?)

Is there any way to repeat a texture under FMX (just like GL_REPEAT under OpenGL ?)

http://open.gl/media/img/c3_clamping.png
http://open.gl/media/img/c3_clamping.png

Comments

  1. It depends on the platform.

    It should repeat in DX9 (Default in XE2 on Windows). Hacking in fmx units required in XE4, for Mac and for Windows DX10. I don't know about XE5 or XE6.

    Below is what I have tried in XE4, it tells you the places where to look.

    FMX.Context.DX10.pas
    procedure TDX10Context.SetTexture
    if WantTextureRepeat then
    begin
      Desc.AddressU := D3D10_TEXTURE_ADDRESS_WRAP;
      Desc.AddressV := D3D10_TEXTURE_ADDRESS_WRAP;
      Desc.AddressW := D3D10_TEXTURE_ADDRESS_WRAP;
    end
    else
    begin
      Desc.AddressU := D3D10_TEXTURE_ADDRESS_CLAMP;
      Desc.AddressV := D3D10_TEXTURE_ADDRESS_CLAMP;
      Desc.AddressW := D3D10_TEXTURE_ADDRESS_CLAMP;
    end;

    FMX.Context.Mac
    class procedure TContextOpenGL.DoInitializeTexture;
    begin
    //    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    //    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    end;

    FMX.Context.GLES.pas
    //it compiles but does not work
    class procedure TContextOpenGL.DoInitializeTexture
    if WantTextureRepeat then
    begin
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    end
    else
    begin
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    end;

    see QC116051 (Open)

    ReplyDelete

Post a Comment