From: Michael H. <mh...@us...> - 2000-10-23 20:55:13
|
Update of /cvsroot/pythianproject/Prototypes/BasicGLapp In directory slayer.i.sourceforge.net:/tmp/cvs-serv28155 Modified Files: frmMain.pas Added Files: CourierNew Grid.bmp texdemo.cfg texdemo.dof texdemo.dpr Removed Files: Basic3D.cfg Basic3D.dof Basic3D.dpr Basic3D.res Log Message: no message ***** Bogus filespec: CourierNew ***** Error reading new file: (2, 'No such file or directory') --- NEW FILE --- -$A+ -$B- -$C+ -$D+ -$E- -$F- -$G+ -$H+ -$I+ -$J+ -$K- -$L+ -$M- -$N+ -$O+ -$P+ -$Q- -$R- -$S- -$T- -$U- -$V+ -$W- -$X+ -$YD -$Z1 -cg -AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; -H+ -W+ -M -$M16384,1048576 -K$00400000 -U"..\..\PythianProject\Source\Units\" -O"..\..\PythianProject\Source\Units\" -I"..\..\PythianProject\Source\Units\" -R"..\..\PythianProject\Source\Units\" --- NEW FILE --- [Compiler] A=1 B=0 C=1 D=1 E=0 F=0 G=1 H=1 I=1 J=1 K=0 L=1 M=0 N=1 O=1 P=1 Q=0 R=0 S=0 T=0 U=0 V=1 W=0 X=1 Y=1 Z=1 ShowHints=1 ShowWarnings=1 UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; [Linker] MapFile=0 OutputObjs=0 ConsoleApp=1 DebugInfo=0 RemoteSymbols=0 MinStackSize=16384 MaxStackSize=1048576 ImageBase=4194304 ExeDescription= [Directories] OutputDir= UnitOutputDir= PackageDLLOutputDir= PackageDCPOutputDir= SearchPath=..\..\PythianProject\Source\Units\ Packages=VCL40;VCLX40;VCLDB40;VCLDBX40;VCLSMP40;QRPT40;TEEUI40;TEEDB40;TEE40;ibevnt40;nmfast40;Python_d4;PythonVCL_d4;NtfyIcon;glPanelPkg Conditionals= DebugSourceDirs= UsePackages=0 [Parameters] RunParams= HostApplication= [Version Info] IncludeVerInfo=0 AutoIncBuild=0 MajorVer=1 MinorVer=0 Release=0 Build=0 Debug=0 PreRelease=0 Special=0 Private=0 DLL=0 Locale=2057 CodePage=1252 [Version Info Keys] CompanyName= FileDescription= FileVersion=1.0.0.0 InternalName= LegalCopyright= LegalTrademarks= OriginalFilename= ProductName= ProductVersion=1.0.0.0 Comments= [Excluded Packages] $(DELPHI)\Components\Indy\dclIndy40.bpl=Internet Direct "Indy" for D4 Property and Component Editors [HistoryLists\hlUnitAliases] Count=1 Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; [HistoryLists\hlSearchPath] Count=1 Item0=..\..\PythianProject\Source\Units\ [HistoryLists\hlOutputDirectorry] Count=1 Item0=. --- NEW FILE --- program texdemo; uses Forms, frmMain in 'frmMain.pas' {MainForm}; {$R *.RES} begin Application.Initialize; Application.Title := 'Texure Demo app'; Application.CreateForm(TMainForm, MainForm); Application.Run; end. Index: frmMain.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/BasicGLapp/frmMain.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** frmMain.pas 2000/10/21 12:26:23 1.1 --- frmMain.pas 2000/10/23 20:55:11 1.2 *************** *** 1,13 **** unit frmMain; ! { Basic 3D OpenGL application that uses the GLPanel component ! by Michael Hearn 2000 for the Pythian Project } interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ! Menus, ExtCtrls, GLPanel, OpenGL, glfd; type --- 1,15 ---- unit frmMain; ! { Shows texture fonts loaded from a grid. ! (C) Michael Hearn 2000 ! mh...@su... } + interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ! Menus, ExtCtrls, GLPanel, OpenGL, Textures, Trace; type *************** *** 28,31 **** --- 30,35 ---- { Public declarations } + TestTex :TTexture; + // Animation trackers can go here animSquare: integer; // this var will be cycled through 1..360 *************** *** 34,38 **** --- 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; *************** *** 82,87 **** glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); ! //glBlendFunc(GL_SRC_ALPHA,GL_ONE); // uncomment this line to enable alpha blending end; --- 99,120 ---- glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); ! glBlendFunc(GL_SRC_ALPHA,GL_ONE); // 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; *************** *** 116,120 **** // Draw the six faces of the cube. // ! glColor4f(1.0,0.0,0.0,0.75); glBegin(GL_POLYGON); glNormal3f(0.0, 0.0, 1.0); --- 149,154 ---- // Draw the six faces of the cube. // ! glDisable(GL_BLEND); ! glColor4f(1.0,0.0,0.0,1.0); glBegin(GL_POLYGON); glNormal3f(0.0, 0.0, 1.0); *************** *** 125,129 **** glEnd; ! glColor4f(0.0,1.0,0.0,0.75); glBegin(GL_POLYGON); glNormal3f(0.0, 0.0, -1.0); --- 159,163 ---- glEnd; ! glColor4f(0.0,1.0,0.0,1.0); glBegin(GL_POLYGON); glNormal3f(0.0, 0.0, -1.0); *************** *** 134,138 **** glEnd; ! glColor4f(0.0,0.0,1.0,0.75); glBegin(GL_POLYGON); glNormal3f(-1.0, 0.0, 0.0); --- 168,172 ---- glEnd; ! glColor4f(0.0,0.0,1.0,1.0); glBegin(GL_POLYGON); glNormal3f(-1.0, 0.0, 0.0); *************** *** 143,147 **** glEnd; ! glColor4f(0.0,1.0,1.0,0.75); glBegin(GL_POLYGON); glNormal3f(1.0, 0.0, 0.0); --- 177,181 ---- glEnd; ! glColor4f(0.0,1.0,1.0,1.0); glBegin(GL_POLYGON); glNormal3f(1.0, 0.0, 0.0); *************** *** 152,156 **** glEnd; ! glColor4f(1.0,1.0,0.0,0.75); glBegin(GL_POLYGON); glNormal3f(0.0, 1.0, 0.0); --- 186,190 ---- glEnd; ! glColor4f(1.0,1.0,0.0,1.0); glBegin(GL_POLYGON); glNormal3f(0.0, 1.0, 0.0); *************** *** 169,172 **** --- 203,238 ---- 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); + + inc(Counter1); + if Counter1 >= 10 then + begin + MakeList; + Counter1 := 0; + end; + glCallList(txtList); + + glDisable(GL_TEXTURE_2D); end; *************** *** 174,177 **** --- 240,320 ---- 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; --- Basic3D.cfg DELETED --- --- Basic3D.dof DELETED --- --- Basic3D.dpr DELETED --- --- Basic3D.res DELETED --- |