From: Michael H. <mh...@us...> - 2000-12-12 20:40:40
|
Update of /cvsroot/pythianproject/Prototypes/GLCanvas In directory slayer.i.sourceforge.net:/tmp/cvs-serv533/GLCanvas Modified Files: glCanvas.pas Log Message: can't remember exact changes, just got cooler that's all -mike Index: glCanvas.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/glCanvas.pas,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** glCanvas.pas 2000/12/11 19:15:12 1.10 --- glCanvas.pas 2000/12/12 20:40:36 1.11 *************** *** 214,219 **** procedure SetPrecache(const Value: boolean); ! procedure UpdateDisplayList; virtual ; ! procedure DrawInternal; virtual; function MatchFontName(name:string; tt:Integer):TGLCanvasFontData; --- 214,219 ---- procedure SetPrecache(const Value: boolean); ! procedure UpdateDisplayList(line:integer); virtual ; ! procedure DrawInternal(line:integer); virtual; function MatchFontName(name:string; tt:Integer):TGLCanvasFontData; *************** *** 233,237 **** property Lines:TStringList read FLines; property Text:string read GetText write SetText; - property Width[index:integer]:integer read GetWidth; --- 233,236 ---- *************** *** 249,253 **** constructor Create(aFontName:string); overload; // auto creates with no text, and quadtext selected destructor Destroy; override ; ! procedure Draw; virtual ; procedure SetColor(const Value: TColor); end; --- 248,252 ---- constructor Create(aFontName:string); overload; // auto creates with no text, and quadtext selected destructor Destroy; override ; ! procedure Draw(Line:integer); virtual ; procedure SetColor(const Value: TColor); end; *************** *** 294,297 **** --- 293,297 ---- // text routines here procedure DrawText(X,Y:Integer; text:TGLText); virtual ; + procedure DrawTextLine(X,Y,Line:integer; Text:TGLText); virtual ; procedure DrawString(X,Y:integer; str:String; FontName:string; aFontType:integer); virtual ; // WARNING: inefficient, don't use except for testing *************** *** 559,585 **** procedure TGLCanvas.DrawText(X, Y: Integer; text: TGLText); begin ! if text.TextType = GLCANVAS_TEXT_GLF then ! begin ! glPushAttrib(GL_TEXTURE_2D); ! glDisable(GL_TEXTURE_2d); ! glMatrixMode(GL_MODELVIEW); ! glLoadIdentity; ! // change co-ordinate system to 1:1 pixel mapping ! glScalef(2.0 / Width, 2.0 / Height, 1.0); ! glTranslatef(-(Width / 2), (Height / 2), 0); ! glTranslatef(X,-Y,0); ! glPopAttrib; ! end else if text.TextType = GLCANVAS_TEXT_QUADTEXT then ! begin ! glMatrixMode(GL_MODELVIEW); ! glLoadIdentity; ! // change co-ordinate system to 1:1 pixel mapping ! glScalef(2.0 / Width, -2.0 / Height, 1.0); ! glTranslatef(-(Width / 2), -(Height / 2), 0); ! ! glTranslatef(X,Y,0); ! end; ! ! text.Draw; end; --- 559,563 ---- procedure TGLCanvas.DrawText(X, Y: Integer; text: TGLText); begin ! DrawTextLine(X,Y,-1,text); end; *************** *** 668,671 **** --- 646,677 ---- end; + procedure TGLCanvas.DrawTextLine(X, Y, Line: integer; Text: TGLText); + begin + // line = -1 means all lines + if text.TextType = GLCANVAS_TEXT_GLF then + begin + glPushAttrib(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_2d); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity; + // change co-ordinate system to 1:1 pixel mapping + glScalef(2.0 / Width, 2.0 / Height, 1.0); + glTranslatef(-(Width / 2), (Height / 2), 0); + glTranslatef(X,-Y,0); + glPopAttrib; + end else if text.TextType = GLCANVAS_TEXT_QUADTEXT then + begin + glMatrixMode(GL_MODELVIEW); + glLoadIdentity; + // change co-ordinate system to 1:1 pixel mapping + glScalef(2.0 / Width, -2.0 / Height, 1.0); + glTranslatef(-(Width / 2), -(Height / 2), 0); + + glTranslatef(X,Y,0); + end; + + text.Draw(Line); + end; + { TGLText } *************** *** 685,689 **** LoadFont; if Precache then ! UpdateDisplayList; SetColor(clWhite); end; --- 691,695 ---- LoadFont; if Precache then ! UpdateDisplayList(-1); SetColor(clWhite); end; *************** *** 703,714 **** end; ! procedure TGLText.Draw; begin if Precache then glCallList(FDisplayList) ! else DrawInternal; end; ! procedure TGLText.DrawInternal; var a:integer; minx,miny,maxx,maxy:single; --- 709,720 ---- end; ! procedure TGLText.Draw(Line:integer); begin if Precache then glCallList(FDisplayList) ! else DrawInternal(Line); end; ! procedure TGLText.DrawInternal(line:integer); var a:integer; minx,miny,maxx,maxy:single; *************** *** 720,731 **** glPushMatrix; glScalef(Size,Size,1); ! for a := 0 to FLines.Count-1 do ! begin ! glPushMatrix; ! glfGetStringBoundsF(glfFontHandle,FLines[a],minx,miny,maxx,maxy); ! glfDrawSolidStringF(GLFFontHandle,FLines[a]); ! glPopMatrix; ! glTranslatef(0,-2,0); // move down a line ! end; glPopMatrix; end else if TextType = GLCANVAS_TEXT_QUADTEXT then --- 726,739 ---- glPushMatrix; glScalef(Size,Size,1); ! if line = -1 then ! for a := 0 to FLines.Count-1 do ! begin ! glPushMatrix; ! glfGetStringBoundsF(glfFontHandle,FLines[a],minx,miny,maxx,maxy); ! glfDrawSolidStringF(GLFFontHandle,FLines[a]); ! glPopMatrix; ! glTranslatef(0,-2,0); // move down a line ! end ! else glfDrawSolidStringF(GLFFontHandle,FLines[line]); // UNTESTED!!!! glPopMatrix; end else if TextType = GLCANVAS_TEXT_QUADTEXT then *************** *** 734,738 **** qtStart; glPushMatrix; ! qtDrawGridString(QT,FLines.Text); glPopMatrix; qtStop; --- 742,748 ---- qtStart; glPushMatrix; ! if Line = -1 then ! qtDrawGridString(QT,FLines.Text) ! else qtDrawGridString(QT,FLines.Strings[Line]); glPopMatrix; qtStop; *************** *** 752,756 **** procedure TGLText.LinesOnChange(Sender: TObject); begin ! if Precache then UpdateDisplayList; end; --- 762,766 ---- procedure TGLText.LinesOnChange(Sender: TObject); begin ! if Precache then UpdateDisplayList(-1); end; *************** *** 812,816 **** begin FBlue := Value; ! UpdateDisplayList; end; --- 822,826 ---- begin FBlue := Value; ! UpdateDisplayList(-1); end; *************** *** 820,824 **** FGreen := (Value and $00FF00) SHR 8; FBlue := (Value and $FF0000) SHR 16; ! UpdateDisplayList; end; --- 830,834 ---- FGreen := (Value and $00FF00) SHR 8; FBlue := (Value and $FF0000) SHR 16; ! UpdateDisplayList(-1); end; *************** *** 827,831 **** FFontName := Value; LoadFont; ! UpdateDisplayList; end; --- 837,841 ---- FFontName := Value; LoadFont; ! UpdateDisplayList(-1); end; *************** *** 833,837 **** begin FGreen := Value; ! UpdateDisplayList; end; --- 843,847 ---- begin FGreen := Value; ! UpdateDisplayList(-1); end; *************** *** 839,843 **** begin FPrecache := Value; ! UpdateDisplayList; end; --- 849,853 ---- begin FPrecache := Value; ! UpdateDisplayList(-1); end; *************** *** 845,849 **** begin FRed := Value; ! UpdateDisplayList; end; --- 855,859 ---- begin FRed := Value; ! UpdateDisplayList(-1); end; *************** *** 851,855 **** begin FSize := Value; ! UpdateDisplayList; end; --- 861,865 ---- begin FSize := Value; ! UpdateDisplayList(-1); end; *************** *** 857,864 **** begin FLines.Text := Value; ! UpdateDisplayList; end; ! procedure TGLText.UpdateDisplayList; begin if Precache then --- 867,874 ---- begin FLines.Text := Value; ! UpdateDisplayList(-1); end; ! procedure TGLText.UpdateDisplayList(line:integer); begin if Precache then *************** *** 867,871 **** FDisplayList := glGenLists(1); glNewList(FDisplayList,GL_COMPILE); ! DrawInternal; glEndList; end; --- 877,881 ---- FDisplayList := glGenLists(1); glNewList(FDisplayList,GL_COMPILE); ! DrawInternal(line); glEndList; end; |