Привет Denis,
Wednesday, February 23, 2005, 2:02:42 PM, вы писали:
DK> Что-то с кодом ты намудрил. Показывай, а то мы тут гадаем на кофейной гуще.
На ATI 9600Pro на пустом поле 10х10 в окне 640х480 - 60FPS
При полном заполнении - 50 крестиков и 50 ноликов - FPS падает до 10-20
Прорисовка происходит по таймеру (если есть предложения получше -
подскажите): Timer2.Interval = 1.
Ещё один вопрос:
При вращении фигур - свет вращается вмести с ними - как это исправить?
(Код в этом же модуле)
В том же 3DMark03 на первом тесте FPS скачет от 50 до 200 :), да и
полигонов там побольше будет!!!
//unit GameUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, Forms,
OpenGL, ExtCtrls, StdCtrls, Graphics, ShellAPI;
const
WM_NOTIFYTRAYICON=WM_USER+1;
type
TTicTacToe = record
Left, Right, Bottom, Top: integer;//eii?aeiaou eeaoee
Value: string//cia?aiea: e?anoee, iieee eee ionoay
end;
(*Iicaeinoaiaaii ec JEDI==============================*)
{ Auxiliary structure to support TColor manipulation }
TColorRec = packed record
case Integer of
0: (Value: Longint);
1: (Red, Green, Blue: Byte);
2: (R, G, B, Flag: Byte);
{$IFDEF MSWINDOWS}
3: (Index: Word); // GetSysColor, PaletteIndex
{$ENDIF MSWINDOWS}
end;
(*====================================================*)
TF_Game = class(TForm)
Timer1: TTimer;
Timer2: TTimer;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Timer2Timer(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
ghRC:HGLRC;
ghDC:HDC;
procedure WMSysCommand(var Msg: TWMSysCommand);
message WM_SYSCOMMAND;
procedure WMTRAYICONNOTIFY(var Msg: TMessage);
message WM_NOTIFYTRAYICON;
public
newCount, frameCount, lastCount : LongInt;
fpsRate : GLFloat;
name1,name2: string;
dmn,fld,gt: cardinal;
WRel,HRel: real;
snd,mus,chat,anim,speedup: boolean;
CallMenu: boolean;
angX,ang0: integer;
NextVal: char;
TTT: array of array of TTicTacToe;
function bSetupPixelFormat(DC:HDC):boolean;
procedure ResolRegen;
procedure Wine;
procedure OnWine(Winer: string);
procedure SetPoint(X, Y: Double);
procedure NewGame;
procedure WinColorToOpenGLColor(Color: TColor; var Red, Green, Blue: Extended);
end;
const
Field=1;
Cross=2;
Zero=3;
Cross2D=4;
Zero2D=5;
CrossWine=6;
ZeroWine=7;
var
F_Game: TF_Game;
tray: TNotifyIconData;
TrayIcon: TIcon;
implementation
uses MainUnit, Records, UDPServerUnit, UDPClientUnit, IniFiles;
{$R *.dfm}
{$R Cursors.res}
procedure TF_Game.WMSysCommand;
begin
if Msg.CmdType=SC_MINIMIZE then SendMessage(F_Game.Handle,WM_CHAR,VK_SPACE,0)
else inherited;
end;
procedure TF_Game.ResolRegen;
begin
if F_Main.CheckBox1.Checked=false then ChangeDisplaySettings(CurMode,CDS_FULLSCREEN);
end;
(*Oi?a ec JEDI========================================================================*)
procedure TF_Game.WinColorToOpenGLColor(Color: TColor; var Red, Green, Blue:
Extended);
var
Temp: TColorRec;
begin
Temp.Value := ColorToRGB(Color);
Red := (Temp.R / High(Temp.R));
Green := (Temp.G / High(Temp.G));
Blue := (Temp.B / High(Temp.B));
end;
(*====================================================================================*)
procedure TF_Game.WMTRAYICONNOTIFY(var Msg: TMessage);
begin
{ia?aaaouaaai niauoey ia eeiiea a o?aa}
case Msg.LParam of
WM_LBUTTONDOWN:
if Visible=false then
begin
if F_Main.CheckBox1.Checked=false then ChangeDisplaySettings(tmpDevMode,CDS_FULLSCREEN);
Show;
Timer1.Enabled:=True;
Timer2.Enabled:=True;
try
with tray do
begin
cbSize:=SizeOf(TNotifyIconData);
Wnd:=F_Game.Handle;
uID:=1;
end;
Shell_NotifyIcon(NIM_DELETE,Addr(tray));
finally
//Application.Terminate;
end;
end;
//WM_LBUTTONDBLCLK: {aao eia ia?aaioee niauoey aaieiiai ia?aoey ia eaao?
eiiieo iuoe}
//WM_LBUTTONUP: {aao eia ia?aaioee niauoey ioioneaiey eaaie eiiiee iuoe}
//WM_RBUTTONDOWN: {aao eia}
//WM_RBUTTONDBLCLK: {aao eia}
//WM_RBUTTONUP: {aao eia}
//WM_MOUSEMOVE: {aao eia}
end;
end;
function TF_Game.bSetupPixelFormat(DC:HDC):boolean;//onoaiiaea oi?iaoa ieenaeae
var
pfd: PIXELFORMATDESCRIPTOR;
ppfd: PPIXELFORMATDESCRIPTOR;
pixelformat: integer;
begin
(*
PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32,
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
24,
0,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};
*)
ppfd:=@pfd;
ppfd.nSize:=sizeof(PIXELFORMATDESCRIPTOR);
ppfd.nVersion:=1;
// ppfd.dwFlags:=PFD_DRAW_TO_WINDOW xor PFD_SUPPORT_OPENGL xor PFD_DOUBLEBUFFER;
ppfd.dwFlags:=PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER;
ppfd.iPixelType:=PFD_TYPE_RGBA;
ppfd.cColorBits:=32;
ppfd.cRedBits:=0; ppfd.cRedShift:=0;
ppfd.cGreenBits:=0; ppfd.cGreenShift:=0;
ppfd.cBlueBits:=0; ppfd.cBlueShift:=0;
ppfd.cAlphaBits:=0;
ppfd.cAlphaShift:=0;
ppfd.cAccumBits:=0;
ppfd.cAccumRedBits:=0; ppfd.cAccumGreenBits:=0;
ppfd.cAccumBlueBits:=0; ppfd.cAccumAlphaBits:=0;
ppfd.cDepthBits:=24;
ppfd.cStencilBits:=0;
ppfd.cAuxBuffers:=0;
ppfd.iLayerType:=PFD_MAIN_PLANE;
ppfd.bReserved:=0;
ppfd.dwLayerMask:=0; ppfd.dwVisibleMask:=0; ppfd.dwDamageMask:=0;
pixelformat:=ChoosePixelFormat(dc, ppfd);
if pixelformat=0 then
begin
MessageBox(0, 'ChoosePixelFormat failed', 'Ioeaea', MB_OK);
bSetupPixelFormat:=false;
exit;
end;
if SetPixelFormat(dc, pixelformat, ppfd)=false then
begin
MessageBox(0, 'SetPixelFormat failed', 'Ioeaea', MB_OK);
bSetupPixelFormat:=false;
exit;
end;
bSetupPixelFormat:=true;
end;
procedure TF_Game.FormCreate(Sender: TObject);
var
p: TGLArrayf4;
d: TGLArrayf3;
i,j,bc,fc,xc,zc: cardinal;
quadObj :GLUquadricObj;
bcr,bcg,bcb,fcr,fcg,fcb,xcr,xcg,xcb,zcr,zcg,zcb: extended;
begin
lastCount := GetTickCount;
frameCount := 0;
CallMenu:=false;
angX:=0;
ang0:=0;
NextVal:='X';
if F_Main.CheckBox1.Checked=false then
begin
BorderStyle:=bsNone;
WindowState:=wsMaximized;
end else
begin
Height:=DevModes[F_Main.ComboBox2.ItemIndex].dmPelsHeight;
Width:=DevModes[F_Main.ComboBox2.ItemIndex].dmPelsWidth;
end;
Screen.Cursors[1]:=LoadCursor(HInstance,'X03DCUR');
Cursor:=1;
name1:=IniFile.ReadString('Game','Name1','Player1');//eiaia ea?ieia
name2:=IniFile.ReadString('Game','Name2','Player2');
dmn:=IniFile.ReadInteger('Rule','Dimension',3);//?acia?iinou ea?iaiai iiey
fld:=IniFile.ReadInteger('Rule','Fields',3);//eiee?anoai eeaoie aey auea?uoa
gt:=IniFile.ReadInteger('Game','Type',1);//oei ea?u
bc:=IniFile.ReadInteger('View','BackColor',8404992);//oaao oiia
fc:=IniFile.ReadInteger('View','FieldColor',15707892);//oaao iiey
xc:=IniFile.ReadInteger('View','XColor',clSkyBlue);//oaao e?anoeea
zc:=IniFile.ReadInteger('View','ZeroColor',clMoneyGreen);//oaao iieeea
snd:=IniFile.ReadBool('Effects','Sounds',true);//caoee
mus:=IniFile.ReadBool('Effects','Music',true);//iocuea
chat:=IniFile.ReadBool('Effects','Chat',true);//?ao
anim:=IniFile.ReadBool('Effects','Animation',true);//aieiaoey
WRel:=(dmn+2)/ClientWidth;
HRel:=(dmn+2)/ClientHeight;
SetLength(TTT,dmn,dmn);//eieoeaeecaoey ianneaa
for i:=0 to dmn-1 do
for j:=0 to dmn-1 do
begin
TTT[i,j].Left:=j+1;
TTT[i,j].Right:=j+2;
TTT[i,j].Bottom:=i+1;
TTT[i,j].Top:=i+2;
TTT[i,j].Value:='';
end;
(*iioae OpenGL*)
ghDC:=GetDC(Handle);
if bSetupPixelFormat(ghDC)=false then Close;
ghRC := wglCreateContext(ghDC);
wglMakeCurrent(ghDC, ghRC);
WinColorToOpenGLColor(bc,bcr,bcg,bcb);
glClearColor(bcr,bcg,bcb,0.0);
FormResize(Sender);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
p[0]:=(dmn+2)/2;
p[1]:=(dmn+2)/2;
p[2]:=4;
p[3]:=1;
d[0]:=0;
d[1]:=0;
d[2]:=0;
glLightfv(GL_LIGHT0,GL_POSITION,@p);
glLightfv(GL_LIGHT0,GL_SPOT_DIRECTION,@d);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_POLYGON_SMOOTH);
(*?enoai*)
glNewList(Field,GL_COMPILE);//ea?iaia iiea
WinColorToOpenGLColor(fc,fcr,fcg,fcb);
glColor3f(fcr,fcg,fcb);
glLineWidth(2);
glBegin(GL_LINES);
for i:=1 to dmn+1 do
begin
glVertex2f(1,i);
glVertex2f(dmn+1,i);
end;
for i:=1 to dmn+1 do
begin
glVertex2f(i,1);
glVertex2f(i,dmn+1);
end;
glEnd;
glEndList;
glNewList(Cross2D,GL_COMPILE);//aaooia?iue e?anoee
WinColorToOpenGLColor(xc,xcr,xcg,xcb);
glColor3f(xcr,xcg,xcb);
glShadeModel(GL_FLAT);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glBegin(GL_POLYGON);//o?iioaeuiay noi?iia
glVertex3f(0,-0.15,0.05);
glVertex3f(-0.1,-0.3,0.05);
glVertex3f(-0.3,-0.3,0.05);
glVertex3f(-0.1,0,0.05);
glVertex3f(-0.3,0.3,0.05);
glVertex3f(-0.1,0.3,0.05);
glVertex3f(0,0.15,0.05);//eaaay iieiaeia o?iioaeuiie noi?iiu caeii?aia
glVertex3f(0.1,0.3,0.05);
glVertex3f(0.3,0.3,0.05);
glVertex3f(0.1,0,0.05);
glVertex3f(0.3,-0.3,0.05);
glVertex3f(0.1,-0.3,0.05);//i?aaay iieiaeia o?iioaeuiie noi?iiu caeii?aia
glEnd;
glEndList;
glNewList(Zero2D,GL_COMPILE);//aaooia?iue iieee
quadObj:=gluNewQuadric;
gluQuadricDrawStyle(quadObj, GLU_FILL);
WinColorToOpenGLColor(zc,zcr,zcg,zcb);
glColor3f(zcr,zcg,zcb);
gluDisk(quadObj,0.15,0.3,50,50);
gluDeleteQuadric(quadObj);
glEndList;
glNewList(Cross,GL_COMPILE);//e?anoee
WinColorToOpenGLColor(xc,xcr,xcg,xcb);
glColor3f(xcr,xcg,xcb);
glShadeModel(GL_FLAT);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glBegin(GL_POLYGON);//o?iioaeuiay noi?iia
glVertex3f(0,-0.15,0.05);
glVertex3f(-0.1,-0.3,0.05);
glVertex3f(-0.3,-0.3,0.05);
glVertex3f(-0.1,0,0.05);
glVertex3f(-0.3,0.3,0.05);
glVertex3f(-0.1,0.3,0.05);
glVertex3f(0,0.15,0.05);//eaaay iieiaeia o?iioaeuiie noi?iiu caeii?aia
glVertex3f(0.1,0.3,0.05);
glVertex3f(0.3,0.3,0.05);
glVertex3f(0.1,0,0.05);
glVertex3f(0.3,-0.3,0.05);
glVertex3f(0.1,-0.3,0.05);//i?aaay iieiaeia o?iioaeuiie noi?iiu caeii?aia
glEnd;
glBegin(GL_POLYGON);//caaieoa
glVertex3f(0,-0.15,-0.05);
glVertex3f(-0.1,-0.3,-0.05);
glVertex3f(-0.3,-0.3,-0.05);
glVertex3f(-0.1,0,-0.05);
glVertex3f(-0.3,0.3,-0.05);
glVertex3f(-0.1,0.3,-0.05);
glVertex3f(0,0.15,-0.05);//eaaay iieiaeia o?iioaeuiie noi?iiu caeii?aia
glVertex3f(0.1,0.3,-0.05);
glVertex3f(0.3,0.3,-0.05);
glVertex3f(0.1,0,-0.05);
glVertex3f(0.3,-0.3,-0.05);
glVertex3f(0.1,-0.3,-0.05);//i?aaay iieiaeia o?iioaeuiie noi?iiu caeii?aia
glEnd;
glBegin(GL_QUADS);//ie?iyy eaaay iiaioaa
glVertex3f(-0.1,-0.3,0.05);
glVertex3f(-0.3,-0.3,0.05);
glVertex3f(-0.3,-0.3,-0.05);
glVertex3f(-0.1,-0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//aa?oiyy eaaay iiaioaa
glVertex3f(-0.1,0.3,0.05);
glVertex3f(-0.3,0.3,0.05);
glVertex3f(-0.3,0.3,-0.05);
glVertex3f(-0.1,0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//ie?iyy i?aaay iiaioaa
glVertex3f(0.3,-0.3,0.05);
glVertex3f(0.1,-0.3,0.05);
glVertex3f(0.1,-0.3,-0.05);
glVertex3f(0.3,-0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//aa?oiyy i?aaay iiaioaa
glVertex3f(0.3,0.3,0.05);
glVertex3f(0.1,0.3,0.05);
glVertex3f(0.1,0.3,-0.05);
glVertex3f(0.3,0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//aioo?aiiyy ie?iyy eaaay a?aiu
glVertex3f(0,-0.15,0.05);
glVertex3f(-0.1,-0.3,0.05);
glVertex3f(-0.1,-0.3,-0.05);
glVertex3f(0,-0.15,-0.05);
glEnd;
glBegin(GL_QUADS);//aioo?aiiyy ie?iyy i?aaay a?aiu
glVertex3f(0.1,-0.3,0.05);
glVertex3f(0,-0.15,0.05);
glVertex3f(0,-0.15,-0.05);
glVertex3f(0.1,-0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//aioo?aiiyy aa?oiyy eaaay a?aiu
glVertex3f(0,0.15,0.05);
glVertex3f(-0.1,0.3,0.05);
glVertex3f(-0.1,0.3,-0.05);
glVertex3f(0,0.15,-0.05);
glEnd;
glBegin(GL_QUADS);//aioo?aiiyy aa?oiyy i?aaay a?aiu
glVertex3f(0.1,0.3,0.05);
glVertex3f(0,0.15,0.05);
glVertex3f(0,0.15,-0.05);
glVertex3f(0.1,0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//aiaoiyy ie?iyy eaaay a?aiu
glVertex3f(-0.1,0,0.05);
glVertex3f(-0.3,-0.3,0.05);
glVertex3f(-0.3,-0.3,-0.05);
glVertex3f(-0.1,0,-0.05);
glEnd;
glBegin(GL_QUADS);//aiaoiyy aa?oiyy eaaay a?aiu
glVertex3f(-0.3,0.3,0.05);
glVertex3f(-0.1,0,0.05);
glVertex3f(-0.1,0,-0.05);
glVertex3f(-0.3,0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//aiaoiyy ie?iyy i?aaay a?aiu
glVertex3f(0.3,-0.3,0.05);
glVertex3f(0.1,0,0.05);
glVertex3f(0.1,0,-0.05);
glVertex3f(0.3,-0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//aiaoiyy aa?oiyy i?aaay a?aiu
glVertex3f(0.1,0,0.05);
glVertex3f(0.3,0.3,0.05);
glVertex3f(0.3,0.3,-0.05);
glVertex3f(0.1,0,-0.05);
glEnd;
glDisable(GL_FOG);
glEndList;
glNewList(Zero,GL_COMPILE);//iieee
quadObj:=gluNewQuadric;
gluQuadricDrawStyle(quadObj, GLU_FILL);
WinColorToOpenGLColor(zc,zcr,zcg,zcb);
glColor3f(zcr,zcg,zcb);
gluDisk(quadObj,0.15,0.3,50,50);
gluCylinder(quadObj,0.15,0.15,0.1,50,50);
gluCylinder(quadObj,0.3,0.3,0.1,100,100);
glPushMatrix;
glTranslatef(0,0,0.1);
gluDisk(quadObj,0.15,0.3,50,50);
glPopMatrix;
gluDeleteQuadric(quadObj);
glEndList;
glNewList(CrossWine,GL_COMPILE);//auea?ae e?anoee
glColor3f(1,0,0);
glShadeModel(GL_FLAT);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glBegin(GL_POLYGON);//o?iioaeuiay noi?iia
glVertex3f(0,-0.15,0.05);
glVertex3f(-0.1,-0.3,0.05);
glVertex3f(-0.3,-0.3,0.05);
glVertex3f(-0.1,0,0.05);
glVertex3f(-0.3,0.3,0.05);
glVertex3f(-0.1,0.3,0.05);
glVertex3f(0,0.15,0.05);//eaaay iieiaeia o?iioaeuiie noi?iiu caeii?aia
glVertex3f(0.1,0.3,0.05);
glVertex3f(0.3,0.3,0.05);
glVertex3f(0.1,0,0.05);
glVertex3f(0.3,-0.3,0.05);
glVertex3f(0.1,-0.3,0.05);//i?aaay iieiaeia o?iioaeuiie noi?iiu caeii?aia
glEnd;
glBegin(GL_POLYGON);//caaieoa
glVertex3f(0,-0.15,-0.05);
glVertex3f(-0.1,-0.3,-0.05);
glVertex3f(-0.3,-0.3,-0.05);
glVertex3f(-0.1,0,-0.05);
glVertex3f(-0.3,0.3,-0.05);
glVertex3f(-0.1,0.3,-0.05);
glVertex3f(0,0.15,-0.05);//eaaay iieiaeia o?iioaeuiie noi?iiu caeii?aia
glVertex3f(0.1,0.3,-0.05);
glVertex3f(0.3,0.3,-0.05);
glVertex3f(0.1,0,-0.05);
glVertex3f(0.3,-0.3,-0.05);
glVertex3f(0.1,-0.3,-0.05);//i?aaay iieiaeia o?iioaeuiie noi?iiu caeii?aia
glEnd;
glBegin(GL_QUADS);//ie?iyy eaaay iiaioaa
glVertex3f(-0.1,-0.3,0.05);
glVertex3f(-0.3,-0.3,0.05);
glVertex3f(-0.3,-0.3,-0.05);
glVertex3f(-0.1,-0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//aa?oiyy eaaay iiaioaa
glVertex3f(-0.1,0.3,0.05);
glVertex3f(-0.3,0.3,0.05);
glVertex3f(-0.3,0.3,-0.05);
glVertex3f(-0.1,0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//ie?iyy i?aaay iiaioaa
glVertex3f(0.3,-0.3,0.05);
glVertex3f(0.1,-0.3,0.05);
glVertex3f(0.1,-0.3,-0.05);
glVertex3f(0.3,-0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//aa?oiyy i?aaay iiaioaa
glVertex3f(0.3,0.3,0.05);
glVertex3f(0.1,0.3,0.05);
glVertex3f(0.1,0.3,-0.05);
glVertex3f(0.3,0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//aioo?aiiyy ie?iyy eaaay a?aiu
glVertex3f(0,-0.15,0.05);
glVertex3f(-0.1,-0.3,0.05);
glVertex3f(-0.1,-0.3,-0.05);
glVertex3f(0,-0.15,-0.05);
glEnd;
glBegin(GL_QUADS);//aioo?aiiyy ie?iyy i?aaay a?aiu
glVertex3f(0.1,-0.3,0.05);
glVertex3f(0,-0.15,0.05);
glVertex3f(0,-0.15,-0.05);
glVertex3f(0.1,-0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//aioo?aiiyy aa?oiyy eaaay a?aiu
glVertex3f(0,0.15,0.05);
glVertex3f(-0.1,0.3,0.05);
glVertex3f(-0.1,0.3,-0.05);
glVertex3f(0,0.15,-0.05);
glEnd;
glBegin(GL_QUADS);//aioo?aiiyy aa?oiyy i?aaay a?aiu
glVertex3f(0.1,0.3,0.05);
glVertex3f(0,0.15,0.05);
glVertex3f(0,0.15,-0.05);
glVertex3f(0.1,0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//aiaoiyy ie?iyy eaaay a?aiu
glVertex3f(-0.1,0,0.05);
glVertex3f(-0.3,-0.3,0.05);
glVertex3f(-0.3,-0.3,-0.05);
glVertex3f(-0.1,0,-0.05);
glEnd;
glBegin(GL_QUADS);//aiaoiyy aa?oiyy eaaay a?aiu
glVertex3f(-0.3,0.3,0.05);
glVertex3f(-0.1,0,0.05);
glVertex3f(-0.1,0,-0.05);
glVertex3f(-0.3,0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//aiaoiyy ie?iyy i?aaay a?aiu
glVertex3f(0.3,-0.3,0.05);
glVertex3f(0.1,0,0.05);
glVertex3f(0.1,0,-0.05);
glVertex3f(0.3,-0.3,-0.05);
glEnd;
glBegin(GL_QUADS);//aiaoiyy aa?oiyy i?aaay a?aiu
glVertex3f(0.1,0,0.05);
glVertex3f(0.3,0.3,0.05);
glVertex3f(0.3,0.3,-0.05);
glVertex3f(0.1,0,-0.05);
glEnd;
glEndList;
glNewList(ZeroWine,GL_COMPILE);//auea?ae iieee
quadObj:=gluNewQuadric;
gluQuadricDrawStyle(quadObj, GLU_FILL);
glColor3f(1,0,0);
gluDisk(quadObj,0.15,0.3,50,50);
gluCylinder(quadObj,0.15,0.15,0.1,50,50);
gluCylinder(quadObj,0.3,0.3,0.1,100,100);
glPushMatrix;
glTranslatef(0,0,0.1);
gluDisk(quadObj,0.15,0.3,50,50);
glPopMatrix;
gluDeleteQuadric(quadObj);
glEndList;
end;
procedure TF_Game.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
//iai?
if Key=VK_F1 then
begin
CallMenu:=true;
Close;
ResolRegen;
F_Main.Show;
F_Main.WindowState:=wsNormal;
end;
//iiaay ea?a
if Key=VK_F2 then
begin
if gt=3 then
if ThisServer then Server.Cl_Tools:=UDP_NewGame else Client.Cl_Tools:=UDP_NewGame;
NewGame;
end;
//ni?yoaou
if (Key=VK_SPACE) and (Visible=true) then
begin
TrayIcon:=Application.Icon;
with tray do
begin
cbSize := SizeOf(TNotifyIconData);
Wnd:=F_Game.Handle;
uID:=1;
uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
uCallBackMessage:=WM_NOTIFYTRAYICON;
hIcon:=TrayIcon.Handle;
szTip:=('X03D');
end;
Shell_NotifyIcon(NIM_ADD, Addr(tray));
ResolRegen;
Hide;
Timer1.Enabled:=False;
Timer2.Enabled:=False;
end;
//auoia
if Key=VK_ESCAPE then
begin
Close;
ResolRegen;
end;
end;
procedure TF_Game.FormResize(Sender: TObject);
begin
WRel:=(dmn+2)/ClientWidth;
HRel:=(dmn+2)/ClientHeight;
glViewport( 0, 0, ClientWidth, ClientHeight );
glMatrixMode( GL_PROJECTION );
glLoadIdentity;
glOrtho(0,dmn+2, 0,dmn+2, 2,12);
gluLookAt(0,0,5, 0,0,0, 0,1,0);
glMatrixMode( GL_MODELVIEW );
end;
procedure TF_Game.Timer2Timer(Sender: TObject);
var
i,j: cardinal;
begin
Timer2.Enabled:=false;
glClear(GL_DEPTH_BUFFER_BIT xor GL_COLOR_BUFFER_BIT);
glCallList(Field);
for i:=0 to dmn-1 do
for j:=0 to dmn-1 do
begin
if TTT[i,j].Value='X' then
begin
glPushMatrix;
glTranslatef(TTT[i,j].Left+(TTT[i,j].Right-TTT[i,j].Left)/2, TTT[i,j].Bottom+(TTT[i,j].Top-TTT[i,j].Bottom)/2,
0);
if (anim) and (speedup) then
if angX<360 then inc(angX,1) else angX:=0;
if anim then
begin
glRotatef(angX,1.0,0.5,1);
glCallList(Cross);
end else glCallList(Cross2D);
glPopMatrix;
end;
if TTT[i,j].Value='0' then
begin
glPushMatrix;
glTranslatef(TTT[i,j].Left+(TTT[i,j].Right-TTT[i,j].Left)/2, TTT[i,j].Bottom+(TTT[i,j].Top-TTT[i,j].Bottom)/2,
-0.05);
if anim then
begin
glRotatef(ang0,1,-0.5,0.3);
glCallList(Zero);
end else glCallList(Zero2D);
glPopMatrix;
end;
end;
SwapBuffers(ghDC);
if BorderStyle<>bsNone then
begin// ii?aaaeyai e auaiaei eiee?anoai eaa?ia a naeoiao
newCount := GetTickCount;
Inc(frameCount);
if (newCount - lastCount) > 1000 then
begin // i?ioea naeoiaa
fpsRate := frameCount * 1000 / (newCount - lastCount);
Caption := 'E?anoeee - Iieeee 3D (FPS = ' + FloatToStr (fpsRate)+')';
lastCount := newCount;
frameCount := 0;
end;
end;
Timer2.Enabled:=true;
end;
procedure TF_Game.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if ghRC<>0 then
begin
wglMakeCurrent(ghDC,0);
wglDeleteContext(ghRC);
end;
if ghDC<>0 then ReleaseDC(Handle, ghDC);
if CallMenu=false then F_Main.Close;
end;
procedure TF_Game.SetPoint(X, Y: Double);
var
i,j: cardinal;
begin
for i:=0 to dmn-1 do
for j:=0 to dmn-1 do
begin
if (TTT[i,j].Left<=X) and (TTT[i,j].Right>=X) and (TTT[i,j].Bottom<=(ClientHeight*HRel-Y))
and (TTT[i,j].Top>=(ClientHeight*HRel-Y)) and (TTT[i,j].Value='') then
begin
TTT[i,j].Value:=NextVal;
if NextVal='X' then NextVal:='0' else NextVal:='X';
end;
end;
Wine;
end;
procedure TF_Game.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
Xi, Yi: Double;
begin
Xi:=X*WRel;
Yi:=Y*HRel;
if gt=3
then //Naoaaay ea?a
if (ThisServer and (NextVal='X')) or (not ThisServer and (NextVal='0')) then
begin
SetPoint(Xi, Yi);
if ThisServer
then begin
Server.Cl_Data.Item.X:=Xi;
Server.Cl_Data.Item.Y:=Yi;
Server.Cl_Tools:=UDP_SetPoint;
end
else begin
Client.Cl_Data.Item.X:=Xi;
Client.Cl_Data.Item.Y:=Yi;
Client.Cl_Tools:=UDP_SetPoint;
end
end else
else SetPoint(Xi, Yi);
end;
procedure TF_Game.Timer1Timer(Sender: TObject);
begin
if anim then
begin
if angX<360 then inc(angX) else angX:=0;
if ang0<360 then inc(ang0) else ang0:=0;
end;
end;
procedure TF_Game.Wine;
var
i,j: byte;
nwinex,nwine0: byte;
k: shortint;
begin
for i:=0 to dmn-1 do//i?iaa?ea no?ie
begin
nwinex:=0;
nwine0:=0;
for j:=0 to dmn-1 do
begin
if TTT[i,j].Value='X' then
begin
nwine0:=0;
inc(nwinex);
if nwinex=fld then
begin
OnWine(name1+' (X)');
Exit;
end;
end;
if TTT[i,j].Value='0' then
begin
nwinex:=0;
inc(nwine0);
if nwine0=fld then
begin
OnWine(name2+' (0)');
Exit;
end;
end;
if TTT[i,j].Value='' then
begin
nwinex:=0;
nwine0:=0;
end;
end;
end;
for j:=0 to dmn-1 do//i?iaa?ea noieaoia
begin
nwinex:=0;
nwine0:=0;
for i:=0 to dmn-1 do
begin
if TTT[i,j].Value='X' then
begin
nwine0:=0;
inc(nwinex);
if nwinex=fld then
begin
OnWine(name1+' (X)');
Exit;
end;
end;
if TTT[i,j].Value='0' then
begin
nwinex:=0;
inc(nwine0);
if nwine0=fld then
begin
OnWine(name2+' (0)');
Exit;
end;
end;
if TTT[i,j].Value='' then
begin
nwinex:=0;
nwine0:=0;
end;
end;
end;
for i:=0 to dmn-fld do//i?iaa?ea aeaaiie aeaaiiaee e auoa
begin
k:=-1;
nwinex:=0;
nwine0:=0;
for j:=i to dmn-1 do
begin
inc(k);
if TTT[k,j].Value='X' then
begin
nwine0:=0;
inc(nwinex);
if nwinex=fld then
begin
OnWine(name1+' (X)');
Exit;
end;
end;
if TTT[k,j].Value='0' then
begin
nwinex:=0;
inc(nwine0);
if nwine0=fld then
begin
OnWine(name2+' (0)');
Exit;
end;
end;
if TTT[i,j].Value='' then
begin
nwinex:=0;
nwine0:=0;
end;
end;
end;
end;
procedure TF_Game.OnWine(Winer: string);
begin
MessageBox(0,PAnsiChar('Auea?ae '+Winer),PAnsiChar('Iica?aaeyai e ni?onoaoai!!!'),MB_OK+MB_ICONINFORMATION);
NewGame;
end;
procedure TF_Game.NewGame;
var
i,j: byte;
begin
lastCount:=GetTickCount;
frameCount:=0;
CallMenu:=false;
angX:=0;
ang0:=0;
NextVal:='X';
for i:=0 to dmn-1 do
for j:=0 to dmn-1 do
begin
TTT[i,j].Left:=j+1;
TTT[i,j].Right:=j+2;
TTT[i,j].Bottom:=i+1;
TTT[i,j].Top:=i+2;
TTT[i,j].Value:='';
end;
end;
end.
//Афоризм напоследок: Если из положения нет выхода, надо поменять положение.
Winamp глаголит: Scorpions - Always Somewhere
27 февраля 2005 г. 12:05:23
Просто студент
Eugene mailto:rav***@o*****.ru
Номер выпуска : 4067
Возраст листа : 525 (дней)
Количество подписчиков : 529
Адрес в архиве : http://subscribe.ru/archive/comp.soft.prog.prog/msg/323609
Получить правила : mailto:comp.soft.prog.prog-rules@subscribe.ru
Формат "дайджест" : mailto:comp.soft.prog.prog-digest@subscribe.ru
Формат "каждое письмо" : mailto:comp.soft.prog.prog-normal@subscribe.ru
Формат "читать с веба" : mailto:comp.soft.prog.prog-webonly@subscribe.ru