From: Michael H. <mh...@us...> - 2000-10-21 12:26:27
|
Update of /cvsroot/pythianproject/Prototypes/BasicGLapp In directory slayer.i.sourceforge.net:/tmp/cvs-serv13420/BasicGLapp Added Files: Basic3D.cfg Basic3D.dof Basic3D.dpr Basic3D.res frmMain.dfm frmMain.pas Log Message: added basic GL app and Console demo --- 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 Basic3D; uses Forms, frmMain in 'frmMain.pas' {MainForm}; {$R *.RES} begin Application.Initialize; Application.Title := 'Basic 3D application'; Application.CreateForm(TMainForm, MainForm); Application.Run; end. --- NEW FILE --- --- NEW FILE --- ÿ Font.ColorclWindowTextFont.Heightõ Font.Name MS Sans Serif Font.Style TextHeight Exit1Click FrameTimerIntervalOnTimerFrameTimerTimerLeft --- NEW FILE --- 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 TMainForm = class(TForm) GLPanel: TGLPanel; MainMenu: TMainMenu; File1: TMenuItem; Exit1: TMenuItem; FrameTimer: TTimer; procedure FrameTimerTimer(Sender: TObject); procedure GLPanelGLInit(Sender: TObject); procedure GLPanelResize(Sender: TObject); procedure GLPanelGLDraw(Sender: TObject); procedure Exit1Click(Sender: TObject); private { Private declarations } public { Public declarations } // Animation trackers can go here animSquare: integer; // this var will be cycled through 1..360 // which states the angle of the square. By // incrementing this every frame we can create // a rotating square :) procedure SetProjection(Sender: TObject); end; var MainForm: TMainForm; implementation {$R *.DFM} procedure TMainForm.FrameTimerTimer(Sender: TObject); begin { Add code to advance animations etc. here } inc(animSquare); if animSquare >= 360 then animSquare := 0; // now redraw the screen GLPanel.GLReDraw; end; procedure TMainForm.SetProjection(Sender: TObject); var gldAspect : TGLdouble; begin // Redefine the viewing volume and viewport when the window size changes. gldAspect := GLPanel.Width / GLPanel.Height; glMatrixMode(GL_PROJECTION); glLoadIdentity; gluPerspective(30.0, // Field-of-view angle gldAspect, // Aspect ratio of viewing volume 1.0, // Distance to near clipping plane 100.0); // Distance to far clipping plane glViewport(0, 0, GLPanel.Width, GLPanel.Height); InvalidateRect(Handle, nil, False); end; procedure TMainForm.GLPanelGLInit(Sender: TObject); begin // Add GL init code here // Any enable/disable commands that affect the entire app should go here // // Enable depth testing and alpha blending // glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); //glBlendFunc(GL_SRC_ALPHA,GL_ONE); // uncomment this line to enable alpha blending end; procedure TMainForm.GLPanelResize(Sender: TObject); begin SetProjection(Sender); // this sets up the view // init any variables here animSquare := 0; end; procedure TMainForm.GLPanelGLDraw(Sender: TObject); begin // // Clear the color and depth buffers. // glClearColor(0.0,0.0,0.0,1.0); // clear to black glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); // reset the matrix to it's identity (original, unmodified) matrix glMatrixMode(GL_PROJECTION); glLoadIdentity; glMatrixMode(GL_MODELVIEW); glLoadIdentity; { ADD YOUR DRAWING CODE HERE } // scale and rotate glScalef(0.5,0.5,0.5); glRotatef(animSquare,0.0,1.0,0.5); // // 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); glVertex3f(1.0, 1.0, 1.0); glVertex3f(-1.0, 1.0, 1.0); glVertex3f(-1.0, -1.0, 1.0); glVertex3f(1.0, -1.0, 1.0); glEnd; glColor4f(0.0,1.0,0.0,0.75); glBegin(GL_POLYGON); glNormal3f(0.0, 0.0, -1.0); glVertex3f(1.0, 1.0, -1.0); glVertex3f(1.0, -1.0, -1.0); glVertex3f(-1.0, -1.0, -1.0); glVertex3f(-1.0, 1.0, -1.0); glEnd; glColor4f(0.0,0.0,1.0,0.75); glBegin(GL_POLYGON); glNormal3f(-1.0, 0.0, 0.0); glVertex3f(-1.0, 1.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); glVertex3f(-1.0, -1.0, -1.0); glVertex3f(-1.0, -1.0, 1.0); glEnd; glColor4f(0.0,1.0,1.0,0.75); glBegin(GL_POLYGON); glNormal3f(1.0, 0.0, 0.0); glVertex3f(1.0, 1.0, 1.0); glVertex3f(1.0, -1.0, 1.0); glVertex3f(1.0, -1.0, -1.0); glVertex3f(1.0, 1.0, -1.0); glEnd; glColor4f(1.0,1.0,0.0,0.75); glBegin(GL_POLYGON); glNormal3f(0.0, 1.0, 0.0); glVertex3f(-1.0, 1.0, -1.0); glVertex3f(-1.0, 1.0, 1.0); glVertex3f(1.0, 1.0, 1.0); glVertex3f(1.0, 1.0, -1.0); glEnd; glColor4f(1.0,1.0,1.0,0.75); glBegin(GL_POLYGON); glNormal3f(0.0, -1.0, 0.0); glVertex3f(-1.0, -1.0, -1.0); glVertex3f(1.0, -1.0, -1.0); glVertex3f(1.0, -1.0, 1.0); glVertex3f(-1.0, -1.0, 1.0); glEnd; end; procedure TMainForm.Exit1Click(Sender: TObject); begin Close; end; end. |