From: Michael H. <mh...@us...> - 2000-12-09 19:52:06
|
Update of /cvsroot/pythianproject/Prototypes/GLCanvas In directory slayer.i.sourceforge.net:/tmp/cvs-serv18050/GLCanvas Modified Files: QuadTextUnit.pas glCanvas.pas glcanvas.htm Log Message: GUI system update -mike Index: QuadTextUnit.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/QuadTextUnit.pas,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** QuadTextUnit.pas 2000/12/03 22:57:21 1.3 --- QuadTextUnit.pas 2000/12/09 19:52:04 1.4 *************** *** 12,15 **** --- 12,18 ---- Todo - antialiasing + + Changed - + 5th December 2000: changed blending algorithm selected to fix bug. } *************** *** 46,50 **** 8, 2, 12, 8, 8, 8, 8, 5, 8, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, ! 12, 8, 4, 6, 7, 2, 2, 3, 3, 2, 13, 14, 12, 5, 7, 2, 8, 8, 2, 2, 4, 4, 12, 15, 15); --- 49,53 ---- 8, 2, 12, 8, 8, 8, 8, 5, 8, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, ! 8, 8, 4, 6, 7, 2, 2, 3, 3, 2, 13, 14, 12, 5, 7, 2, 8, 8, 2, 2, 4, 4, 12, 15, 15); *************** *** 65,68 **** --- 68,72 ---- function qtDrawGridSquare(QT:TQuadText; X,Y:integer):integer; procedure qtDrawGridString(QT:TQuadText; s:String); + function qtGetStringWidth(QT:TQuadText; s:string):integer; // in pixels implementation *************** *** 74,77 **** --- 78,98 ---- txStore :TGLBoolean; + function qtGetStringWidth(QT:TQuadText; s:string):integer; // in pixels + var total,offset,i,j:integer; + begin + total := 0; + for i := 1 to Length(s) do + begin + offset := -1; + for j := 1 to NUMCHARS do + if TEX_CHARS[j] = s[i] then + offset := j; + if offset <> -1 then + total := total + QT.TexWidths[offset] + QT.GridCharSpacing + else total := total + QT.SpaceWidth; + end; + result := total; + end; + function qtDrawGridChar(QT:TQuadText; C:Char):integer; var *************** *** 166,170 **** glGetBooleanv(GL_BLEND,@blStore); glEnable(GL_BLEND); ! glBlendFunc(GL_SRC_ALPHA,GL_ONE); end; --- 187,192 ---- glGetBooleanv(GL_BLEND,@blStore); glEnable(GL_BLEND); ! // glBlendFunc(GL_SRC_ALPHA,GL_ONE); ! glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); end; Index: glCanvas.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/glCanvas.pas,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** glCanvas.pas 2000/12/03 22:57:21 1.8 --- glCanvas.pas 2000/12/09 19:52:04 1.9 *************** *** 32,40 **** Michael Hearn (mh...@su...) Darryl Long (d_...@sy...) To do- - Add GLF bitmap fonts code - later - Add shapes code - QuadText fonts - cell widths are specified in a different part of the program to the rest of the data. messy. fix it. --- 32,39 ---- Michael Hearn (mh...@su...) Darryl Long (d_...@sy...) + Kamil Krauspe + Ilkka Tuomioja To do- QuadText fonts - cell widths are specified in a different part of the program to the rest of the data. messy. fix it. *************** *** 42,48 **** --- 41,54 ---- Texbmp drawing - add alpha blending, scissor box combining + Bugs- + Doesn't like not being created from a form + Bitmaps don't work with UseTransparency = false :( + Fixed- Color bug all better (darryl) + New- + TRGB, ColorToRGB + Notes- To add a new QuadText font *************** *** 64,68 **** up, where 22 is the height of a titlebar. I have no idea why this should be so, probably a bug in Microsofts code, but ! you have been warned. } --- 70,75 ---- up, where 22 is the height of a titlebar. I have no idea why this should be so, probably a bug in Microsofts code, but ! you have been warned. (fixed: only problem with engine template ! code, GLForms works fine :) } *************** *** 122,125 **** --- 129,136 ---- type + TRGB = record + r,g,b:byte; + end; + // we use this to store the pixel data from a bitmap TPixelData = TByteArray; *************** *** 141,144 **** --- 152,159 ---- FTexData :TTexBMPData; + FRed: byte; + FGreen: byte; + FBlue: byte; + procedure SetIntensity(const Value: byte); public UseTransparency :boolean; *************** *** 155,158 **** --- 170,178 ---- property TexData :TTexBMPData read FTexData; + property Red:byte read FRed write FRed; + property Green:byte read FGreen write FGreen; + property Blue:byte read FBlue write FBlue; + property Intensity:byte write SetIntensity; + constructor Create(aType:integer); overload ; constructor Create; overload; *************** *** 164,169 **** end; - - TGLText = class private --- 184,187 ---- *************** *** 173,177 **** FLines :TStringList; FFontName :string; ! FRed, FGreen, FBlue: Single; FSize :real; --- 191,195 ---- FLines :TStringList; FFontName :string; ! FRed, FGreen, FBlue: byte; FSize :real; *************** *** 186,192 **** procedure LoadFont; virtual ; ! procedure SetBlue(const Value: Single); ! procedure SetGreen(const Value: Single); ! procedure SetRed(const Value: Single); procedure SetSize(const Value: Real); procedure SetPrecache(const Value: boolean); --- 204,210 ---- procedure LoadFont; virtual ; ! procedure SetBlue(const Value: byte); ! procedure SetGreen(const Value: byte); ! procedure SetRed(const Value: byte); procedure SetSize(const Value: Real); procedure SetPrecache(const Value: boolean); *************** *** 199,202 **** --- 217,221 ---- procedure LinesOnChange(Sender:TObject); + function GetWidth(index: integer): integer; public *************** *** 211,218 **** property Text:string read GetText write SetText; ! property Red: Single read FRed write SetRed; ! property Green: Single read FGreen write SetGreen; ! property Blue: Single read FBlue write SetBlue; property Size :Real read FSize write SetSize; --- 230,239 ---- property Text:string read GetText write SetText; ! property Width[index:integer]:integer read GetWidth; + property Red: byte read FRed write SetRed; + property Green: byte read FGreen write SetGreen; + property Blue: byte read FBlue write SetBlue; + property Size :Real read FSize write SetSize; *************** *** 233,236 **** --- 254,258 ---- FFillR,FFillG,FFillB :Single; FFillAlpha: Single; + FClipRect:TRect; function GetColor: TColor; procedure SetColor(const Value: TColor); *************** *** 244,247 **** --- 266,270 ---- property CurrentColor :TColor read GetColor write SetColor; property FillAlpha:Single read FFillAlpha write FFillAlpha; + property ClipRect :TRect read FClipRect; // misc. object routines *************** *** 258,264 **** procedure DrawBitmapEx(X,Y,aWidth,aHeight,OffsetX,OffsetY:integer; bmp:TGLBitmap); virtual ; procedure DrawBitmap(X,Y:integer; bmp:TGLBitmap); virtual ; // other ! procedure SetClipping(Left,Top,Right,Bottom:integer); procedure CancelClipping; --- 281,289 ---- procedure DrawBitmapEx(X,Y,aWidth,aHeight,OffsetX,OffsetY:integer; bmp:TGLBitmap); virtual ; procedure DrawBitmap(X,Y:integer; bmp:TGLBitmap); virtual ; + procedure DrawBitmapSubRect(X,Y:integer; SubRect:TRect; bmp:TGLBitmap); virtual ; // other ! procedure SetClipping(Left,Top,Right,Bottom:integer); overload; ! procedure SetClipping(R:TRect); overload ; procedure CancelClipping; *************** *** 270,275 **** --- 295,305 ---- // shape routines here - will standardise on the american spelling of colo(u)r procedure Rectangle(Left, Top, Right, Bottom:integer); virtual ; + + function ColorToRGB(c:TColor):TRGB; end; + var + FontsDirectory :string; + function MakeTexturesFromBmp(var aBMP:TFastDIB; useTransparency:boolean; transparentColor:TFColor):TTexBMPData; // returns display list procedure DeleteTexBMP(bmp:TTexBMPData); *************** *** 279,284 **** --- 309,339 ---- procedure DrawTexBMP(offsetx,offsety,width,height:integer; bmp:TTexBMPData); + function PointInRect(r:TRect; X,Y:integer):boolean; + function CompareRect(r1,r2:TRect):boolean; + // returns a rect that is src resized so it fits insides dest + function FitRectToRect(src,dest:TRect):TRect; + implementation + function CompareRect(r1,r2:TRect):boolean; + begin + Result := (r1.Left = r2.Left) and (r1.Top = r2.Top) and (r1.Right = r2.Right) and (r1.Bottom = r2.Bottom); + end; + + function PointInRect(r:TRect; X,Y:integer):boolean; + begin + Result := (X >= r.Left) and (X <= r.Right) and (Y >= r.Top) and (Y <= r.Bottom); + end; + + function FitRectToRect(src,dest:TRect):TRect; + var t,l,r,b:integer; + begin + if src.top >= dest.top then t := src.top else t := dest.top; + if src.left >= dest.left then l := src.left else l := dest.left; + if src.right <= dest.right then r := src.right else r := dest.right; + if src.Bottom <= dest.bottom then b := src.bottom else b := dest.bottom; + result := rect(l,t,r,b); + end; + { TGLBitmap } *************** *** 292,297 **** FWidth := -1; FHeight := -1; FBMPType := aType; ! UseTransparency:=false; TransparentColor := FRGB(0,0,0); end; --- 347,353 ---- FWidth := -1; FHeight := -1; FBMPType := aType; ! UseTransparency:=true; TransparentColor := FRGB(0,0,0); + Intensity := 255; end; *************** *** 406,409 **** --- 462,470 ---- end; + procedure TGLBitmap.SetIntensity(const Value: byte); + begin + Red := Value; Green := Value; Blue := Value; + end; + { TGLCanvas } *************** *** 426,430 **** glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); FillAlpha := 1.0; ! CurrentColor := clWhite; end; --- 487,492 ---- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); FillAlpha := 1.0; ! CurrentColor := clWhite; ! FClipRect := Rect(0,0,0,0); end; *************** *** 435,438 **** --- 497,501 ---- procedure TGLCanvas.DrawBitmapEx(X,Y,aWidth,aHeight,OffsetX,OffsetY:integer;bmp: TGLBitmap); + var r:TRect; begin glPushAttrib(GL_DEPTH_TEST); *************** *** 454,462 **** glTranslatef(x,y,0); ! glEnable(GL_SCISSOR_TEST); ! // @@todo - add scissor box saving/combining ! glScissor(x,Height-y-aHeight,aWidth-1,aHeight); ! DrawTexBmp(offsetx,offsety,aWidth,aHeight,bmp.TexData); ! glDisable(GL_SCISSOR_TEST); end; --- 517,537 ---- glTranslatef(x,y,0); ! if CompareRect(FClipRect,Rect(0,0,0,0)) then ! begin ! glEnable(GL_SCISSOR_TEST); ! glColor3ub(bmp.Red,bmp.Green,bmp.Blue); ! glScissor(x,Height-y-aHeight,aWidth-1,aHeight); ! DrawTexBmp(offsetx,offsety,aWidth,aHeight,bmp.TexData); ! glDisable(GL_SCISSOR_TEST); ! end else ! begin ! // we already have a clipping rectangle so combine them ! r := FitRectToRect(Rect(x,y,x+aWidth,y+aHeight),FClipRect); ! glPushAttrib(GL_SCISSOR_TEST); ! glColor3ub(bmp.Red,bmp.Green,bmp.Blue); ! glScissor(r.left,Height-r.bottom,r.right-r.left-1,r.bottom-r.top); ! DrawTexBmp(offsetx,offsety,aWidth,aHeight,bmp.TexData); ! glPopAttrib; ! end; end; *************** *** 567,570 **** --- 642,665 ---- glEnable(GL_SCISSOR_TEST); glScissor(Left,Height-Bottom,Right-Left,Bottom-Top); + FClipRect := Rect(Left,Top,Right,Bottom); + end; + + function TGLCanvas.ColorToRGB(c: TColor): TRGB; + begin + result.r := (c and $0000FF); + result.g := (c and $00FF00) SHR 8; + result.b := (c and $FF0000) SHR 16; + end; + + procedure TGLCanvas.SetClipping(R: TRect); + begin + SetClipping(r.left,r.top,r.right,r.bottom); + FClipRect := r; + end; + + procedure TGLCanvas.DrawBitmapSubRect(X, Y: integer; SubRect: TRect; + bmp: TGLBitmap); + begin + DrawBitmapEx(X,Y,SubRect.Right-SubRect.Left,subRect.Bottom-SubRect.Top,SubRect.Left,SubRect.Top,bmp); end; *************** *** 618,622 **** if TextType = GLCANVAS_TEXT_GLF then begin ! glColor3f(FRed, FGreen, FBlue); glPushMatrix; glScalef(Size,Size,1); --- 713,717 ---- if TextType = GLCANVAS_TEXT_GLF then begin ! glColor3ub(FRed, FGreen, FBlue); glPushMatrix; glScalef(Size,Size,1); *************** *** 632,636 **** end else if TextType = GLCANVAS_TEXT_QUADTEXT then begin ! glColor3f(FRed, FGreen, FBlue); qtStart; glPushMatrix; --- 727,731 ---- end else if TextType = GLCANVAS_TEXT_QUADTEXT then begin ! glColor3ub(FRed, FGreen, FBlue); qtStart; glPushMatrix; *************** *** 646,649 **** --- 741,749 ---- end; + function TGLText.GetWidth(index: integer): integer; + begin + Result := qtGetStringWidth(QT,Lines[index]); + end; + procedure TGLText.LinesOnChange(Sender: TObject); begin *************** *** 659,671 **** if ExtractFileExt(f.FileName) = '.glf' then begin ! GLFFontHandle := glfLoadFont(f.FileName); if GLFFontHandle = GLF_ERROR then raise Exception.Create('Could not load font'); end else if ExtractFileExt(f.FileName) = '.bmf' then ! glfLoadBMFFont(f.FileName); end else if TextType = GLCANVAS_TEXT_QUADTEXT then begin if assigned(FTexture) then FTexture.Free; FTexture := TTexture.Create; ! FTexture.LoadFromFile(f.FileName); QT.TextureID := FTexture.TexID; QT.GridSquareWidth := 20; --- 759,771 ---- if ExtractFileExt(f.FileName) = '.glf' then begin ! GLFFontHandle := glfLoadFont(FontsDirectory + f.FileName); if GLFFontHandle = GLF_ERROR then raise Exception.Create('Could not load font'); end else if ExtractFileExt(f.FileName) = '.bmf' then ! glfLoadBMFFont(FontsDirectory + f.FileName); end else if TextType = GLCANVAS_TEXT_QUADTEXT then begin if assigned(FTexture) then FTexture.Free; FTexture := TTexture.Create; ! FTexture.LoadFromFile(FontsDirectory + f.FileName); QT.TextureID := FTexture.TexID; QT.GridSquareWidth := 20; *************** *** 703,707 **** end; ! procedure TGLText.SetBlue(const Value: Single); begin FBlue := Value; --- 803,807 ---- end; ! procedure TGLText.SetBlue(const Value: byte); begin FBlue := Value; *************** *** 724,728 **** end; ! procedure TGLText.SetGreen(const Value: Single); begin FGreen := Value; --- 824,828 ---- end; ! procedure TGLText.SetGreen(const Value: byte); begin FGreen := Value; *************** *** 736,740 **** end; ! procedure TGLText.SetRed(const Value: Single); begin FRed := Value; --- 836,840 ---- end; ! procedure TGLText.SetRed(const Value: byte); begin FRed := Value; *************** *** 959,963 **** glBegin(GL_QUADS); ! glColor4f(1.0,1.0,1.0,1.0); // going anti-clockwise // top left --- 1059,1063 ---- glBegin(GL_QUADS); ! // (so we can control colour earlier) glColor4f(1.0,1.0,1.0,1.0); // going anti-clockwise // top left *************** *** 977,980 **** --- 1077,1082 ---- end; + initialization + FontsDirectory := ''; // is appended to font file name end. Index: glcanvas.htm =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/glcanvas.htm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** glcanvas.htm 2000/12/03 22:57:21 1.1 --- glcanvas.htm 2000/12/09 19:52:04 1.2 *************** *** 9,12 **** --- 9,14 ---- <hr align="Left" width="100%" size="2"><a href="mailto:mh...@su...">Michael + + Hearn</a><br> <a href="mailto:d_...@sy...">Darryl Long</a><br> *************** *** 14,25 **** --- 16,39 ---- <br> <hr align="Left" width="100%" size="2"><br> + Change Log:<br> + <br> + - 4th December 2000: Add info about InitMatrix (doh!)<br> + <hr align="Left" width="100%" size="2"><br> This file describes the GLCanvas objects suite and how to use it to make + + drawing 2D graphics onto an OpenGL canvas much easier than it would otherwise + + be. The algorithms used in the canvas have been designed for speed and ease + + of use, not necessarily simplicity. This is why some operations with it + + may seem a strange way of doing things. Anyway, let's go.<br> <br> *************** *** 36,39 **** --- 50,55 ---- All this is done using simple commands like Rectangle(), DrawBitmap() and + + DrawText().<br> <br> *************** *** 41,74 **** --- 57,116 ---- <br> Images in OpenGL are not directly supported unless you use the glDrawPixels() + command which directly copies pixel data from system memory to the pixel + buffer. This would be ideal but unfortunately this is a <b>very</b>slow + operation, and I mean slow. Drawing a 640x480 image in this way on my machine + takes almost half a second :(<br> Nevertheless, the Canvas supports this method for when performance is not + + the be all and end all for your app.<br> <br> However, there is a better, although significantly more complex way of doing + + things that results in much better framerates (ie. about 120fps on my machine + + for a 640x480 image :) This system breaks the image you want to draw into + + multiple textures and then uses polygons to display them. Because these + + images are hardware accellerated things move along much better. Why multiple + + textures? Well, most hardware cards have a limit of 256x256 pixels for textures + + due to the internals of their engines. So the canvas breaks an image into + + multiple textures when the image is loaded.<br> <br> So how do you use this then? Well, all bitmaps in the GLCanvas are represented + + by objects, in this case the TGLBitmap class is used. To use a bitmap it + + must be loaded into one of these objects, which can then be passed to the + + DrawBitmap() method of the GLCanvas. Here's an example:<br> <br> *************** *** 77,82 **** <br> <code>begin</code><br> ! <code> GLC := TGLCanvas.Create;</code><br> ! <code> </code><br> <code> Picture := TGLBitmap.Create;</code><br> <code> Picture.LoadFromFile("logo.png");</code><br> --- 119,126 ---- <br> <code>begin</code><br> ! <code> GLC := TGLCanvas.Create;<br> ! <br> ! GLC.InitMatrix;</code><br> ! <br> <code> Picture := TGLBitmap.Create;</code><br> <code> Picture.LoadFromFile("logo.png");</code><br> *************** *** 85,99 **** <code>end;</code><br> <br> ! This example would display "logo.png"at location 50,50 from the top left ! of the window. As you can see, there is nothing to it. However, we can do ! more than this! The GLBitmap class supports transparency using a transparent ! colour: if we set the transparent colour to black then any black pixels ! in the picture will be see-through, meaning you can draw non-rectangular ! bitmaps. This is done by setting the <code>UseTransparency</code>property ! to true and setting the TransparentColor property to the colour you want ! (it defaults to black). Because the GLCanvas is based partly on the FastDIB ! library you must specify the colour as RGB data, not a Delphi colour constant. ! Although in some places you can use constants like clBlack or clAqua in ! this instance that's not allowed. You create a colour for this property using the FRGB function:<br> <br> --- 129,144 ---- <code>end;</code><br> <br> ! Note that before any GLCanvas methods can be called you must call InitMatrix, ! this initializes the co-ordinate systems. This example would display "logo.png"at ! location 50,50 from the top left of the window. As you can see, there is ! nothing to it. However, we can do more than this! The GLBitmap class supports ! transparency using a transparent colour: if we set the transparent colour ! to black then any black pixels in the picture will be see-through, meaning ! you can draw non-rectangular bitmaps. This is done by setting the <code>UseTransparency</code>property ! to true and setting the TransparentColor property to the colour you want ! (it defaults to black). Because the GLCanvas is based partly on the FastDIB ! library you must specify the colour as RGB data, not a Delphi colour constant. ! Although in some places you can use constants like clBlack or clAqua in ! this instance that's not allowed. You create a colour for this property using the FRGB function:<br> <br> *************** *** 101,108 **** --- 146,155 ---- Picture.UseTransparency := true;<br> Picture.TransparentColor := FRGB(0,0,255); // blue is our transparent + colour<br> Picture.LoadFromFile("logo.png");</code><br> <br> Notice that you <i>must</i>set the transparency properties before loading + the file. If you want you can use direct drawing by using a different constructor:<br> <br> *************** *** 110,113 **** --- 157,161 ---- <br> However, this isn't really supported very well - for instance transparency + doesn't work with this method. Also, it's slow so it's best to avoid this.<br> <br> *************** *** 115,138 **** --- 163,203 ---- <br> Again, OpenGL has no direct support for drawing text. There are many, many + different ways of drawing text (for more information on this subject check + out NeHe's excellent <a href="http://nehe.gamedev.net/opengl/">tutorial pages</a>) and the Canvas + offers you two which should combine the best of both worlds - bitmapped + text which looks nice at small sizes, and vector text which can be resized + to any area needed without losing resolution. Vector fonts are drawn using + the <a href="http://romka.demonews.com">GLF library</a>written by Romka, who is a seriously + cool guy. You can get more fonts from his website.<br> <br> Bitmapped fonts are drawn using my own system that uses a 256x256 bitmap + with letters arranged in a grid formation. Textured polygons are drawn that + use this and this means <i>fast fast fast!</i><br> <br> This also means that fonts are very easy to make, although it does take some + time. You can use the included "20x20grid.bmp" file to help you create new + fonts. To use the text facility you can use the TGLText object. The reason + that text is represented by objects too is for performance reasons, when + you use an object something called pre-caching becomes available which stores + the commands for drawing the text in the hardware accellerator itself, meaning + - yep, you've guessed it, faster execution! Of course, if this isn't important + to you it's possible to use the DrawString() command for simplicity but + it's really designed to use an object. Here's a simple example of it:<br> <br> *************** *** 150,156 **** --- 215,225 ---- <br> As you can see, this is quite easy, but you can do more :) Text objects can + have multiple lines (accessed through the Lines property), and of course + this can be used to load text files. The demo program shows this in action. + This uses textured quads to draw bitmapped text. To use the GLF vector based + text:<br> <br> *************** *** 160,165 **** --- 229,236 ---- Text2 := TGLText.Create("Hello World","Arial",GLCANVAS_TEXT_GLF,GLC_DEFAULT_FONT_DATA);<br> // here we have used the other overloaded constructor to select GLF text. + you can ignore<br> // the last parameter, it selects a font data array, the default one will + do for now.<br> Text2.Size := 20;<br> *************** *** 167,175 **** --- 238,260 ---- end;</code><br> <br> + If you want to change the directory fonts are loaded from (the default is + for the current directory) you can set the FontsDirectory variable in the + unit. This is a string that is appended to the start of the font filenames + before they are loaded, and therefore they <b>must</b>have a / at the end. + For instance:<br> + <br> + <code>FontsDirectory := "..\Data\Fonts\" // is OK<br> + FontsDirectory := "..\Data\Fonts" // is not!</code><br> + <br> How you add new fonts depends on the system you use. If you're drawing vector + text you can simply download more GLF fonts from Romkas website but I'm + not sure how you can make your own. Then you add the entry for it to the + GLC_DEFAULT_FONT_DATA array as shown below. For bitmap text it's more complex + (i'm afraid the canvas only comes with Arial and Courier New) but everything + can be done using Paint Shop Pro or a similar program.<br> <br> *************** *** 178,198 **** --- 263,295 ---- <li>Create a new 256x256 bitmap with a black background</li> <li>Paste the "20x20 Grid.bmp" file over the top. This will show you where + to place characters. If you want you can place the grid over the fonts that + come with the canvas to see how it's done.</li> <li>For each character place the letter (in white) in each square aligned + to the left of each grid square.</li> <li>Once this is done for every character (well, every character that is + in the font set, you can see them in the other font grids) save it and change + the GLCanvas.pas file in the following way:</li> <li>Add a new entry to the GLC_DEFAULT_FONT_DATA array. The fields are + fairly self-explanatory, just make sure you set FontType to be GLCANVAS_TEXT_QUADTEXT.</li> <li>You also need to add a widths array to the QuadTextUnit.pas file. This + array specifies the width of each character and is how the system support + variable width fonts. See the code for examples of how to do this.</li> <li>Finally, you need to add an entry to the MatchFontWidths method of + the TGLText class. This just returns the array given a font name.</li> <li>That's it! I know it's long winded, some time I may automate it but + for now that's the way to do it. If you want to add some sort of exotic + character not already in the font set add it to the array and set the rest + of the widths in the other arrays to 0.</li> </ol> *************** *** 201,204 **** --- 298,302 ---- <br> You can draw rectangles using the Rectangle() method. This takes 4 coordinates, + X1, X2, Y1 and Y2. It draws a rectangle based on the:<br> <br> *************** *** 208,212 **** --- 306,312 ---- <br> properties. If solid is true then the rectangle will be filled with the colour + and at the opacity specified with FillAlpha. If solid is false then the + outline is all that is drawn.<br> <br> |