Update of /cvsroot/pythianproject/Prototypes/BasicGLapp
In directory slayer.i.sourceforge.net:/tmp/cvs-serv6734/BasicGLapp
Modified Files:
frmMain.pas
Log Message:
no message
Index: frmMain.pas
===================================================================
RCS file: /cvsroot/pythianproject/Prototypes/BasicGLapp/frmMain.pas,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** frmMain.pas 2000/10/24 17:21:24 1.3
--- frmMain.pas 2000/10/26 17:08:15 1.4
***************
*** 1,5 ****
unit frmMain;
! { Shows texture fonts loaded from a grid.
(C) Michael Hearn 2000
mh...@su... }
--- 1,5 ----
unit frmMain;
! { Basic 3D application
(C) Michael Hearn 2000
mh...@su... }
***************
*** 30,35 ****
{ Public declarations }
- TestTex :TTexture;
-
// Animation trackers can go here
animSquare: integer; // this var will be cycled through 1..360
--- 30,33 ----
***************
*** 38,55 ****
// a rotating square :)
- GridSquareWidth,GridSquareHeight :integer; // size of grid square
- GridCharSpacing:integer; // spacing between letters.
-
- txtfile :TStringList;
- counter1 :integer;
-
- txtList:integer;
procedure SetProjection(Sender: TObject);
-
- procedure DrawGridChar(C:Char);
- function DrawGridSquare(X,Y:integer):integer;
- procedure DrawGridString(s:String);
-
- procedure MakeList;
end;
--- 36,40 ----
***************
*** 102,120 ****
// uncomment this line to enable alpha blending
- TestTex := TTexture.Create;
- TestTex.UseMipmaps := true;
- TestTex.UseAlpha := true;
- TestTex.LoadFromFile('CourierNew Grid.bmp');
-
- GridSquareWidth := 20;
- GridSquareHeight := 20;
- GridCharSpacing := 15;
-
- txtFile := TStringList.Create;
- txtFile.LoadFromFile('movies.txt');
-
- txtList := glGenLists(1);
- Counter1 := 0;
- MakeList;
end;
--- 87,90 ----
***************
*** 203,243 ****
glVertex3f(-1.0, -1.0, 1.0);
glEnd;
-
- glLoadIdentity;
-
- glClear(GL_DEPTH_BUFFER_BIT);
- glEnable(GL_TEXTURE_2D);
- glEnable(GL_BLEND);
-
- // change co-ordinate system to 1:1 pixel mapping
- glScalef(2.0 / GLPanel.Width, -2.0 / GLPanel.Height, 1.0);
- glTranslatef(-(GLPanel.Width / 2), -(GLPanel.Height / 2), 0);
-
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity;
- glScalef(1/256,1/256,1);
-
- TestTex.Draw;
- // left = 256 right = 0
- // top = 0 bottom = 256
- //
- // left = 256 - (20 * (x-1))
-
- glMatrixMode(GL_MODELVIEW);
-
- glEnable(GL_SCISSOR_TEST);
-
- inc(Counter1);
- if Counter1 >= 100 then
- begin
- MakeList;
- Counter1 := 0;
- end;
- glScissor(10,10,630,470);
- gltranslatef(0,animSquare-500,0);
- glCallList(txtList);
- glDisable(GL_SCISSOR_TEST);
-
- glDisable(GL_TEXTURE_2D);
end;
--- 173,176 ----
***************
*** 245,325 ****
begin
Close;
- end;
-
- function TMainForm.DrawGridSquare(X,Y: integer):integer;
- var l,t:integer;
- begin
- Result := -1;
- if (l <= 0) or (t <= 0) then
- exit;
-
- l := 256 - (GridSquareWidth * (x-1));
- t := (Y - 1) * GridSquareHeight;
-
- glBegin(GL_QUADS);
- glTexCoord2f(l,t);
- glVertex2f(0,0);
- glTexCoord2f(l,t+GridSquareHeight);
- glVertex2f(0,GridSquareHeight);
- glTexCoord2f(l-GridSquareWidth,t+GridSquareHeight);
- glVertex2f(GridSquareWidth,GridSquareHeight);
- glTexCoord2f(l-GridSquareWidth,t);
- glVertex2f(GridSquareWidth,0);
- glEnd;
-
- result := 0;
- end;
-
- procedure TMainForm.DrawGridChar(C: Char);
- var
- AlphaOffset :integer;
- x,y:integer;
- begin
- C := UpCase(C);
- if (Ord(C) >= Ord('A')) or (Ord(C) <= Ord('Z')) then
- begin
- AlphaOffset := Ord(C) - Ord('A') + 1;
- // AlphaOffset contains the grid offset of the character now
- // in this test grid there are 12 per line
- Y := (AlphaOffset div 12);
- if AlphaOffset mod 12 <> 0 then // need this in case letter is last on grid line
- inc(y);
- X := AlphaOffset - ((Y-1)*12);
- TraceString(IntToStr(X)+','+IntToStr(Y));
- DrawGridSquare(x,y);
- end;
- end;
-
- procedure TMainForm.DrawGridString(s: String);
- var a:integer;
- begin
- for a := 1 to Length(s) do
- begin
- if s[a] = #13 then
- begin
- glTranslatef(-GLPanel.Width-GridCharSpacing,20,0)
- end else begin
- DrawGridChar(s[a]);
- glTranslatef(GridCharSpacing,0,0);
- end;
- end;
- end;
-
- procedure TMainForm.MakeList;
- var x,y:integer;
- begin
- glNewList(txtList,GL_COMPILE);
- for y := 1 to 800 div 20 do
- begin
- glPushMatrix;
- for x := 1 to (640 div GridCharSpacing) do
- begin
- DrawGridChar(Chr(Trunc(Random(Ord('Z') - Ord('A')) + Ord('A'))));
- glTranslatef(GridCharSpacing,0,0);
- end;
- glPopMatrix;
- glTranslatef(0,20,0);
- end;
- glEndList;
end;
--- 178,181 ----
|