A2D引擎

A2D的alpha效率没有Asphyre高,但贴图效率比Asphyre好。

A2D作者是继承了Delphix的各方面优点而写的基于Direct3D和OpenGl的2D引擎,可选择使用二者中的一个来渲染。

我实际测试过,做为A2D来讲,似乎更偏重于OpenGL。

另外用A2D写类传奇游戏,在UI上,需要自己添加一些代码,以获取点像素值,其他与Delphix类似。

得到点像素值的函数,我也共享一下


推荐大家使用Asphyre,用这个写游戏,还是挺方便的

而且Asphyre和A2d,Hge等基于Direct3D的引擎,都是原生32位的,,不会出现黑一下的问题:)



Fucntion TDXBitmapTexture.GetPixels(x,y):integer;
var
  x1,y1:integer;
  cur16:PWord;
  cur32:PLongWord;
  ptr32:PRGBARec;
  d3dlr:TD3DLocked_Rect;
begin
if Loaded then
  begin
    IDirect3DTexture9(FTexture).LockRect(0, d3dlr, nil, 0);

    if FBitDepth = ad32Bit then
    begin
      Cur32 := d3dlr.pBits;
      ptr32 := ABmp.Scanline;
      for y1 := 0 to FBaseHeight-1 do
      begin
        for x1 := 0 to FWidth-1 do
        begin
          if (x1 = x) and (y1=y) then
          begin
            ptr32^.a := Cur32^ shr 24;
            ptr32^.b := Cur32^ shr 16;
            ptr32^.g := Cur32^ shr 8;
            ptr32^.r := Cur32^;
           
          end
          else
          begin
          inc(ptr32);
          end
          inc(Cur32);
        end;
      end;
    end else
    if FBitDepth = ad32Bit then
    begin
      Cur16 := d3dlr.pBits;
      ptr32 := ABmp.Scanline;
      for y := 0 to FBaseHeight-1 do
      begin
        for x := 0 to FWidth-1 do
        begin
          if x < ABmp.Width then
          begin
            ptr32^.a := ($000F and (Cur16^ shr 12))*16;
            ptr32^.b := ($000F and (Cur16^ shr 8))*16;
            ptr32^.g := ($000F and (Cur16^ shr 4))*16;
            ptr32^.r := ($000F and Cur16^)*16;
            inc(ptr32);
          end;
          inc(Cur16);
        end;
      end;
    end;

    IDirect3DTexture9(FTexture).UnlockRect(0)
  end;
end;
原文地址:https://www.cnblogs.com/zerovirs/p/1730881.html