Class interface-------------------------------------------------------------------
TGraphics=Class
private
_W,_H,_BPP:integer;
_Rate,_Channels,_Buffers:integer;
_Flags:UInt32;
_Title,_IconPath:string;
_Screen:TPicture; //TPicture is defined somewhere else
_HWSurface,_HWAccel,_FullScreen,_NoFrame,_DoubleBuf,_Cursor:boolean;
function GetW:integer;
function GetH:integer;
function GetBPP:integer;
function GetRate:integer;
function GetChannels:integer;
function GetBuffers:integer;
function GetTitle:string;
function GetIconPath:string;
function GetHWSurface:boolean;
function GetHWAccel:boolean;
function GetFullScreen:boolean;
function GetNoFrame:boolean;
function GetDoubleBuf:boolean;
function GetCursor:boolean;
procedure SetW(const val:integer);
procedure SetH(const val:integer);
procedure SetBPP(const val:integer);
procedure SetRate(const val:integer);
procedure SetChannels(const val:integer);
procedure SetBuffers(const val:integer);
procedure SetTitle(const val:string);
procedure SetIconPath(const val:string);
procedure SetHWSurface(const val:boolean);
procedure SetHWAccel(const val:boolean);
procedure SetFullScreen(const val:boolean);
procedure SetNoFrame(const val:boolean);
procedure SetDoubleBuf(const val:boolean);
procedure SetCursor(const val:boolean);
public
constructor Create;
destructor Destroy;override;
procedure Initialize;
procedure Refresh;
property W:integer read GetW write SetW;
property H:integer read GetH write SetH;
property BPP:integer read GetBPP write SetBPP;
property Rate:integer read GetRate write SetRate;
property Channels:integer read GetChannels write SetChannels;
property Buffers:integer read GetBuffers write SetBuffers;
property Title:string read GetTitle write SetTitle;
property IconPath:string read GetIconPath write SetIconPath;
property HWSurface:boolean read GetHWSurface write SetHWSurface;
property HWAccel:boolean read GetHWAccel write SetHWAccel;
property FullScreen:boolean read GetFullScreen write SetFullScreen;
property NoFrame:boolean read GetNoFrame write SetNoFrame;
property DoubleBuf:boolean read GetDoubleBuf write SetDoubleBuf;
property CursorEnabled:boolean read GetCursor write SetCursor;
end;
Example of property function Get and procedure Set, all of them are the same--------------
function TGraphics.GetW:integer;
begin
GetW:=_W;//ERROR LINE
end;
procedure TGraphics.SetW(const val:integer);
begin
_W:=val; //ERROR LINE
end;
Initialize method-------------------------------------------------------------------------
procedure TGraphics.Initialize;
var
Icon:PSDL_Surface;
begin
SDL_Init( SDL_INIT_VIDEO or SDL_INIT_AUDIO );
SDL_WM_SetCaption( PChar(_Title), PChar(_Title));//ERROR LINE
if FileExists(_IconPath) then begin//ERROR LINE...and every other which contains private variables
Icon:=LoadImage(_IconPath);
if Icon=nil then Raise Exception.Create('Failed to load icon image.')
else begin
SDL_WM_SetIcon( Icon, nil );
SDL_FreeSurface(Icon);
end;
end;
_Flags:=0;
if _HWSurface then _Flags:=_Flags or SDL_HWSURFACE;
if _HWAccel then _Flags:=_Flags or SDL_HWACCEL;
if _FullScreen then _Flags:=_Flags or SDL_FULLSCREEN;
if _NoFrame then _Flags:=_Flags or SDL_NOFRAME;
if _DoubleBuf then _Flags:=_Flags or SDL_DOUBLEBUF;
{_Screen:=TMainScreen.Create;
_Screen.SetVideoMode(_W,_H,_BPP,_Flags);}
_Screen.Create(_W,_H);
SDL_FreeSurface(_Screen._Picture);
_Screen._Picture:=SDL_SetVideoMode(_W,_H,_BPP,_Flags);
if _Screen._Picture=nil then Raise Exception.Create('Failed to setup video');
if _Cursor then SDL_ShowCursor(SDL_DISABLE)
else SDL_ShowCursor(SDL_ENABLE);
if Mix_OpenAudio(_Rate,MIX_DEFAULT_FORMAT,_Channels,_Buffers)<>0 then
Raise Exception.Create('Failed to setup audio');
if TTF_INIT=-1 then Raise Exception.Create('Failed to setup fonts');
end;
-------------------------------------------------------
Error is: " Project raised exception class 'External: SIGSEV' "
and it is reported for every line that contains private variables, such as some lines marked above.
What is wrong here?

New Topic/Question
Reply



MultiQuote


|