This is the code i just write to handle the files. The error i recive is that the path variable gets an AnsiString and the parameter for the IMG_LoadTexture is a pChar. How do i convert them?
Code:
program grafica;
uses SysUtils,crt,SDL2,SDL2_image;
type Textures=array[1..100] of pSDL_Texture;
var Window:pSDL_Window; var Tex:Textures; Ren:pSDL_Renderer;
procedure Graphic_Initialisation(var Window:pSDL_Window);
begin
if SDL_INIT(SDL_INIT_VIDEO)<0 then
writeln('An error ocurred, the program will now quit')
else
begin
writeln('Graphic mode succesfully initialisated');
Window:=SDL_CreateWindow('Test',50,50,600,400,SDL_WINDOW_SHOWN);
end;
end;
procedure Texture_Loading;
var path:pChar;
begin
Ren:=SDL_CreateRenderer(window,-1,0);
path:=ExtractFilePath('grafica.exe');
Tex[1]:=IMG_LoadTexture(Ren,path+'\monster.bmp');
Tex[2]:=IMG_LoadTexture(Ren,path+'\monster1.bmp');;
end;
procedure Graphic_Composer;
var i:byte;
begin
Texture_Loading;
for i:=1 to 100 do
begin
if (i mod 2)=1 then
begin
SDL_RenderCopy(Ren,Tex[1],nil,nil);
SDL_RenderPresent(Ren);
SDL_DELAY(50);
end
else
begin
SDL_RenderCopy(Ren,Tex[2],nil,nil);
SDL_RenderPresent(Ren);
SDL_Delay(50);
end;
end;
end;
procedure Graphic_Destroy;
var i:byte;
begin
for i:=1 to 100 do
SDL_DestroyTexture(Tex[i]);
SDL_DestroyRenderer(Ren);
SDL_DestroyWindow(Window);
SDL_QUIT;
end;
begin
clrscr;
Graphic_Initialisation(Window);
Graphic_Composer;
Graphic_Destroy;
end.
Bookmarks