T
TrustMe
Unregistered / Unconfirmed
GUEST, unregistred user!
// trGLBase.inc 文件<br>{$IFDEF trGLBase}<br>uses Windows, trCtrl, OpenGL, OpenGLX;<br>{$ENDIF}<br>type<br> trGLBaseObj = class<br> private<br> {$IFDEF trGLBase}<br> FSelected: boolean;<br> FOnAfterDraw: trNotifyEvent;<br> FOnBeforeDraw: trNotifyEvent;<br> procedure Draw;virtual;abstract;<br> procedure DrawSelected;virtual;abstract;<br> {$ENDIF}<br> function GetSelected: boolean;virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> procedure SetSelected(const value: boolean);virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> function GetOnAfterDraw: trNotifyEvent;virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> procedure SetOnAfterDraw(const value: trNotifyEvent);virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> function GetOnBeforeDraw: trNotifyEvent;virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> procedure SetOnBeforeDraw(const value: trNotifyEvent);virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> public<br> {$IFDEF trGLBase}<br> constructor Create;<br> {$ENDIF}<br> procedure ReDraw;virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> published<br> property Selected: boolean read GetSelected Write SetSelected;<br> <br> property OnAfterDraw: trNotifyEvent read GetOnAfterDraw write SetOnAfterDraw;<br> property OnBeforeDraw: trNotifyEvent read GetOnBeforeDraw write SetOnBeforeDraw;<br> end;<br>// trGLBase.pas 文件<br>unit trGLBase;<br>{$DEFINE trGLBase}<br>interface<br>{$I trGLBase.inc}<br>implementation<br><br>function trGLPtNew: trGLPointObj;<br>begin<br> result:= trGLPointObj.Create;<br>end;<br><br>{trGLBaseObj}<br><br>constructor trGLBaseObj.Create;<br>begin<br> FSelected:= False;<br> FOnAfterDraw:= nil;<br> FOnBeforeDraw:= nil;<br>end;<br><br>function trGLBaseObj.GetSelected: boolean;<br>begin<br> result:= FSelected;<br>end;<br><br>procedure trGLBaseObj.SetSelected(const value: boolean);<br>begin<br> if value <> FSelected then begin<br> FSelected:= value;<br> ReDraw;<br> end;<br>end;<br><br>function trGLBaseObj.GetOnAfterDraw: trNotifyEvent;<br>begin<br> result:= FOnAfterDraw;<br>end;<br><br>procedure trGLBaseObj.SetOnAfterDraw(const value: trNotifyEvent);<br>begin<br> FOnAfterDraw:= value;<br>end;<br><br>function trGLBaseObj.GetOnBeforeDraw: trNotifyEvent;<br>begin<br> result:= FOnBeforeDraw;<br>end;<br><br>procedure trGLBaseObj.SetOnBeforeDraw(const value: trNotifyEvent);<br>begin<br> FOnBeforeDraw:= value;<br>end;<br><br>procedure trGLBaseObj.ReDraw;<br>begin<br> if Assigned(FOnBeforeDraw) then FOnBeforeDraw(Self); // 注:代码执行到此处时,出错<br> Draw;<br> if FSelected then DrawSelected;<br> if Assigned(FOnAfterDraw) then FOnAfterDraw(Self);<br>end;<br>另,本人初学OpenGL,哪位富翁对此感兴趣或已有造诣者,欢迎QQ:22627167(身份验证时,请注明:大富翁,OpenGL字样,谢谢!)交流!