pnGL ""

pnGL Windws . , .

,
26.06.2011
747,0 K

. ,

, , , , .

http://www.allbest.ru/

53

- һ

pnGL

2011

++ pnGL MF. Visul Studi 6.0. . , : , , , ./. , , . , . . , Windws - , .

1. PNGL

1.1 PNGL

1.2 PNGL

1.3

1.4

1.5

2. ʻ

2.1

2.2

2.3

3.

3.1

3.2

3.3

3.4

3.5

pnGL . 250 ( 200 pnGL 50 pnGL), , , .

pnGL , - , . , pnGL ; , . pnGL . , , , , . pnGL - , .

, , , pnGL. pnGL (GLU - pnGL Utility Librry) , NURBS- (NURBS - Nn-Unifrm, Rtinl B-Splin - -). GLU pnGL. , FSG (Fhrnhit Sn Grph), pnGL, .

1.

PNGL

1.1 pnGL

pnGL , pnGL- . : , , , pnGL , , .

pnGL, . , , , . , , , - , , - .

, ; , .

(, ) . , ; , , , , , . , , , , , .

1. , 1.

1

1. pnGL

finlud <whtvrYuNd.h>,

min () {

InitilizWindwPls();

gllrlr(0.0, 0.0, 0.0, 0.0); gllr(GL_LR_BUFFR_BIT); gllr3f(1.0, 1.0, 1.0);

glrth(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); glBgin(GL_PLYGN);

glVrtx3f(0.25, 0.25, 0.0);

glVrtx3f (0.75, 0.25, 0.0);

glVrtx3f(0.75, 0.75, 0.0);

glVrtx3f(0.25, 0.75, 0.0); glnd() ; glFlush () ;

UpdtThWindwndhkFrvnts(); }

min() : InitilizWindwPls() -"" , pnGL. pnGL, : glIrIr() , , gllr() . , , gllr(). gllrlr(). gllr3f() , - . , , , .

pnGL, , glrth(), , pnGL , , . , glBgin() glnd(), , , . "" glVrtx3f(). , , , , (, , z), , z(z - 0).

, gIFlush() , , , pnGL. -"" Updt Th Windw nd hk Fr vnts() .

1.2 pnGL

, , , , pnGL gl. , , (, , gllrlr()). , pnGL, GL_, , (, GL__LR_BUFFR_BIT).

, , , , (, 3f gllr3f() glVrtx3f()). , lr gllr3f() , , . , . , 3 , ; lr . f , . pnGL .

pnGL 8 . , , IS pnGL, 1.1; pnGL. pnGL, , ; , ++ d, .

1.1 -

pnGL

8-

signd hr

GLbyt

16-

shrt

GLshrt

32-

Int lng

GLint, GLsizi

32-

flt

GLflt, GLlmpf

64-

dubl

GLdubl, GLlmpd

8-

unsignd hr

GLubyt, GLbln

16-

unsignd shrt

GLushrt

32-

unsigndint unsignd lng

GLuint, GLnum, GLbitfild

, glVrtx2i (1,3); glVrtx2f (1.0, 3.0); , , 32- , .

pnGL v, , ( ) , . , , , , , , . , , :

gllr3f (1.0, 0.0, 0.0);

gLflt lr_rry [] = {1.0, 0.0, 0.0); gllr3fv (lr_rry);

, pnGL GLvid. pnGL, .

1.3

pnGL , : , , . , : glSl*(), . , , glnbl(GL_NRMLIZ).

vid glLightMdl[i, f](GLnum pnm, GLnum prm) vid glLightMdl[i f]v(GLnum pnm, nst GLtyp *prms).

pnm , : GL_LIGHT_MDL_LL_VIWR, prm . GL_FLS, z, . GL_TRU, . , . - GL_FLS.

GL_LIGHT_MDL_TW_SID prm , , . GL_FLS, . GL_TRU, . - GL_FLS.

GL_LIGHT_MDL_MBINT prms , . - (0.2, 0.2, 0.2,1.0).

1.4

vid glMtril[i f](GLnum f, GLnum pnm, GLtyp prm) vid glMtril[i f]v(GLnum f, GLnum pnm, GLtyp *prms).

, , , . prm, pnm:

GL_MBINT prms RGB, ( ). - (0.2, 0.2, 0.2, 1.0);

GL_DIFFUS prms RGB, . - (0.8, 0.8, 0.8, 1.0);

GL_SPULR prms RGB, . - (0.0, 0.0, 0.0, 1.0);

GL_SHININSS prms 0 128, . - 0;

GL_MISSIN prms RGB, . : (0.0, 0.0, 0.0, 1.0);

GL_MBINT_ND_DIFFUS : glMtril*() pnm GL_MBINT GL_DIFFUS prms.

, : glMtril[i f]() . glMtril[i f]v() .

f , GL_FRNT, GL_BK GL_FRNT_ND_BK.

, , glnbl() GL_LR_MTRIL, vid gllrMtril(GLnum f, GLnum pnm), f , pnm . pnm ( ) gllr*(), glMtril*() .

1.5

pnGL - . , , , .

pnGL , .. . , pnGL. .

glnbl(GL_FG).

vid glFg[if](num pnm, T prm); vid glFg[if]v(num pnm, T prms);

pnm :

GL_FG_MD prm , . prm :

GL_XP f=xp(-d*z);

GL_XP2 f=xp(-(d*z)2);

GL_LINR f=-z/-s,

z - , , .

d, , s pnm:

GL_FG_DNSITY prm d;

GL_FG_STRT prm s;

GL_FG_ND prm .

pnm, GL_FG_LR prms - 4- .

2.

ʻ

2.1

vid Lb1Viw::nDrw(D* pD), usr_RndrSn (). , . , , , , ...

3D BL Lb1Viw::usr_stuppixlfrmt() vid Lb1Viw::usr_Rsiz(int x, int y, int width, int hidht) . usr_RndrSn (), . .

, - glBgin(GL_PLYGN) - glVrtx3d. (uxSlidBx), gluylindr. - uxSlidSphr. - gluylindr, gluDisk. - glPlygnMd, uxSlidBx, uxSlidTrus. - glPlygnMd, gluylindr. - glPlygnMd, gluylindr. - gluylindr. - glTrnsltf, - glRttf. !

usr_RndrSn() .

2.2

, :

- ;

- ;

- ;

- ;

- ;

- / ;

- ;

- ;

- ;

- ;

- .

, , , .

, .

2.3

: , - . : , ; , , , . , . , , , , .

, . , , :

- WM_DSTRY - ;

- WM_SIZ - ;

- WM_RSBKGND - ;

- WM_TIMR - ;

- WM_MUSWHL - ;

- WM_KYDWN - ;

- MMND(ID_PRSP, KrksViw::nPrsp ()) - ;

- MMND(ID_PTINS, KrksViw::nptins ()) - ;

- MMND(ID_VIW_1, KrksViw::nViw1())- ;

- MMND(ID_VIW_SBRS, KrksViw:: nVwSbrs()) - ;

- MMND (ID_VIW_MV, KrksViw::nMv ()) - .

3.

3.1

. . , , , , , , , , , . , - Mirsft Visul ++ 6.0 pnGL.

3.2

:

- ;

- ;

- ;

- ;

- ;

- / ;

- ;

- ;

- ;

- ;

- ;

- .

3.3

pnGL .

1. . , . PIXLFRMTDSRIPTR. , . , , , . , , hsPixlFrmt(). StPixlFrmt() .

2. pnGL. wglrtntxt(), wglMkurrnt() . wglGturrntD() , wglGturrntD() - .

usr_RSiz(), .

usr_RndrSn(), .

, usr_RndrSn() 2.1 , 2.3 .

- 3.1.

3.1 -

1

PrrtWindw (RTSTRUT& s)

s - RTSTRUT.

, - RTSTRUT .

2

usr_bStupPixlFrmt ()

3

usr_bInitpnGL()

pnGL

4

usr_DstrypnGL()

(- pnGL)

5

usr_RSiz (int x, int y, int width, int hight)

x y , width hight -

6

usr_RndrSn()

3.2 -

Minfrm

.

Krkspp

. . , .

KrksD

.

KrksViw

. 3D .

butDlg

DlgPrs

.

Dlgptins

. .

3.4

: Intl Pntium 800 , - 64 , - 500 , -, Supr VG ( - 256). : WINDWS 2000/XP .

3.5

, Krks.x . .

, Windws - . , . , , .

. , , ( .2).

.

Windws pnGL.

, :

- pnGL Windws;

- pnGL;

- ;

- .

:

- ;

- ;

- ;

- ;

- .

3D , , pnGL, .

1. .. . ., BHV, 2002.

2. .., .. . . , -, 2001.

3. . . , BHV, 1998.

4. Prfrmn pnGL: Pltfrm Indpndnt Thniqus.

5. SIGGRPH 2001 urs.

6. pnGL prfrmn ptimiztin, Siggrph'97 urs.

7. Visul Intrdutin in pnGL, SIGGRPH'98.

8. Th pnGL grphis systm: spifitin (vrsin 1.1).

9. GLUT: . Migul ngl Spulvd, LinuxFus.

10. Th pnGL Utility Tlkit (GLUT) Prgrmming Intrf, PI vrsin 3, spifitin.

.1 -

// KrksViw.pp : implmnttin f th KrksViw lss

//

#inlud "stdfx.h"

#inlud "Krks.h"

#inlud "KrksD.h"

#inlud "KrksViw.h"

#inlud "DlgPrs.h"

#inlud "dlgptins.h"

#inlud "mth.h"

#ifdf _DBUG

#dfin nw DBUG_NW

#undf THIS_FIL

sttihr THIS_FIL[] = __FIL__;

#ndif

/////////////////////////////////////////////////////////////////////////////

// KrksViw

IMPLMNT_DYNRT(KrksViw, Viw)

BGIN_MSSG_MP(KrksViw, Viw)

//{{FX_MSG_MP(KrksViw)

N_WM_RT()

N_WM_DSTRY()

N_WM_SIZ()

N_WM_RSBKGND()

N_MMND(ID_PRSP, nPrsp)

N_WM_HR()

N_WM_MUSWHL()

N_MMND(ID_PTINS, nptins)

N_WM_TIMR()

N_MMND(ID_BUM, nBum)

//}}FX_MSG_MP

// Stndrd printing mmnds

N_MMND(ID_FIL_PRINT, Viw::nFilPrint)

N_MMND(ID_FIL_PRINT_DIRT, Viw::nFilPrint)

N_MMND(ID_FIL_PRINT_PRVIW, Viw::nFilPrintPrviw)

ND_MSSG_MP()

/////////////////////////////////////////////////////////////////////////////

// KrksViw nstrutin/dstrutin

KrksViw::KrksViw()

{

rtts[0]=0;

rtts[1]=0;

rtts[2]=0;

StrtPs[0]=0;

StrtPs[1]=0;

urDpth=70;

TrnsX=0;

TrnsY=0;

FirstTimr=0;

SndTimr=0;

XSnRt=0;

YSnRt=0;

sn_rtt_spd=0;

BumX=0;

BumY=0;

BumTim=0;

Bumngl=45;

BumStrtSpd=10;

lud_nbl=0;

1[0]=2[0]=3[0]=0.8;

1[1]=2[1]=3[1]=0.7;

1[2]=2[2]=3[2]=0.5;

PlygnMd=GL_FILL;

}

KrksViw::~KrksViw()

{

}

BL KrksViw::PrrtWindw(RTSTRUT& s)

{

s.styl|=(WS_LIPHILDRN|WS_LIPSIBLINGS);

rturn Viw::PrrtWindw(s);

}

/////////////////////////////////////////////////////////////////////////////

// KrksViw drwing

vid KrksViw::nDrw(D* pD)

{

KrksD* pD= GtDumnt();

SSRT_VLID(pD);

usr_RndrSn();

}

/////////////////////////////////////////////////////////////////////////////

// KrksViw printing

BL KrksViw::nPrprPrinting(PrintInf* pInf)

{

rturn DPrprPrinting(pInf);

}

vid KrksViw::nBginPrinting(D* /*pD*/, PrintInf* /*pInf*/)

{

}

vid KrksViw::nndPrinting(D* /*pD*/, PrintInf* /*pInf*/)

{

}

/////////////////////////////////////////////////////////////////////////////

// KrksViw dignstis

#ifdf _DBUG

vid KrksViw::ssrtVlid() nst

{

Viw::ssrtVlid();

}

vid KrksViw::Dump(Dumpntxt& d) nst

{

Viw::Dump(d);

}

KrksD* KrksViw::GtDumnt()

{

SSRT(m_pDumnt->IsKindf(RUNTIM_LSS(KrksD)));

rturn (KrksD*)m_pDumnt;

}

#ndif //_DBUG

/////////////////////////////////////////////////////////////////////////////

// KrksViw mssg hndlrs

BL KrksViw::usr_bStupPixlFrmt()

{

int iPixlTyp=PFD_TYP_RGB;

DWRD dwFlgs=PFD_DUBLBUFFR|

PFD_SUPPRT_PNGL|

PFD_DRW_T_WINDW;

PIXLFRMTDSRIPTR pfd ={0};

pfd.nSiz=sizf (PIXLFRMTDSRIPTR);

pfd.nVrsin=1;

pfd.dwFlgs=dwFlgs;

pfd.iPixlTyp=iPixlTyp;

pfd.lrBits=64;

pfd.lphBits =64;

pfd.umBits=64;

pfd.DpthBits=64;

pfd.StnilBits=64;

pfd.uxBuffrs=64;

pfd.iLyrTyp= PFD_MIN_PLN;

lintD* lD= nw lintD(this);

int pixlfrmt;

if ((pixlfrmt=hsPixlFrmt(lD->GtSfHd(),&pfd))==0)

{

MssgBx("usr_bStupPixlFrmt: hsPixlFrmt fild BUM BUM BUM");

lD->DltD();

rturn FLS;

}

if (StPixlFrmt(lD->GtSfHd(),pixlfrmt, &pfd)==FLS)

{

MssgBx("usr_bStupPixlFrmt: StPixlFrmt fild BUM BUM BUM");

lD->DltD();

rturn FLS;

}

lD->DltD();

rturn TRU;

}

BL KrksViw::usr_bInitpnGL()

{

HGLRhr;

tmpD= nw lintD(this);

if (!usr_bStupPixlFrmt()) rturn FLS;

hr= wglrtntxt (tmpD->GtSfHd());

if (!wglMkurrnt(tmpD->GtSfHd(),hr)) rturn FLS;

usr_PrInit();

rturn TRU;

}

vid KrksViw::usr_DstrypnGL()

{

HGLRhr;

hr=::wglGturrntntxt();

::wglMkurrnt(NULL,NULL);

if (hr)

::wglDltntxt(hr);

if (tmpD)

tmpD->DltD();

}

int KrksViw::nrt(LPRTSTRUT lprtStrut)

{

if (Viw::nrt(lprtStrut) == -1)

rturn -1;

if(!this->usr_bInitpnGL())

{

fxMssgBx("rrr with rting prjt! PIU!");

rturn -1;

}

rturn 0;

}

vid KrksViw::nDstry()

{

Viw::nDstry();

this->usr_DstrypnGL();

}

vid KrksViw::nSiz(UINT nTyp, int x, int y)

{

Viw::nSiz(nTyp, x, y);

int x = x, y = y;

usr_RSiz (0,0,x,y);

}

vid KrksViw::usr_RSiz(int x, int y, int width, int hight)

{

glViwprt(0,0,(GLint)width,(GLint)hight);

glMtrixMd(GL_PRJTIN);

glLdIdntity();

if (hight == 0) sp = 1;

ls

sp = (GLflt)width/hight;

gluPrsptiv(urDpth,sp,1,20);

glMtrixMd(GL_MDLVIW);

}

vid KrksViw::usr_RndrSn()

{

gllrlr(0.2f,0.6f,0.5f,1);

gllr(GL_LR_BUFFR_BIT | GL_DPTH_BUFFR_BIT);

glLdIdntity();

glTrnsltf (0,0,-4);

glTrnsltf(TrnsX,TrnsY,0);

glRttf(XSnRt,0,1,0);

glRttf(YSnRt,1,0,0);

glRttf (rtts[0],1,0,0);

glRttf (rtts[1],0,1,0);

glRttf (90,1,0,0);

GLUqudribj * qudri= gluNwQudri();

gluQudriDrwStyl(qudri, GLU_FILL);

if (lud_nbl==1)

{

glnbl(GL_TXTUR_2D);

glnbl(GL_TXTUR_GN_S);

glnbl(GL_TXTUR_GN_T);

glPushMtrix();

gllr3f(1,1,1);

glTrnsltf(0,0,0.45);

glTxGni(GL_S, GL_TXTUR_GN_MD, GL_SPHR_MP);

glTxGni(GL_T, GL_TXTUR_GN_MD, GL_SPHR_MP);

uxSlidSphr(10);

glPpMtrix();

glDisbl(GL_TXTUR_GN_S);

glDisbl(GL_TXTUR_GN_T);

glDisbl(GL_TXTUR_2D);

}

glPushMtrix();

glPlygnMd(GL_FRNT_ND_BK, GL_FILL);

glBgin(GL_PLYGN);

gllr3f(1,0,0);

glVrtx3d(-0.6,0.0,-1.3);

gllr3f(0,1,0);

glVrtx3d(-0.6,0.0,-0.2);

gllr3f(0,0,1);

glVrtx3d(0.83,-1.2,-0.2);

glnd();

glBgin(GL_PLYGN);

glVrtx3d(0.6,0.0,-1.3);

glVrtx3d(0.6,0.0,-0.2);

glVrtx3d(1.55,-0.8,-0.2);

glnd();

gllr3f(1,0,0);

glBgin(GL_PLYGN);

glVrtx3d(-0.6,0.0,-0.75);

glVrtx3d(-1.5,0.0,-0.0);

glVrtx3d(-0.8,-0.4,-0.2);

glnd();

gllr3f(0,1,0);

glBgin(GL_PLYGN);

glVrtx3d(-0.7,0.0,-0.78);

glVrtx3d(-1.7,0.0,-0.08);

glVrtx3d(-1.0,-0.3,-0.4);

glnd();

gllr3f(0,0,1);

glBgin(GL_PLYGN);

glVrtx3d(-0.8,0.0,-0.86);

glVrtx3d(-2.0,0.0,-0.25);

glVrtx3d(-1.3,-0.25,-0.4);

glnd();

gllr3f(1,1,1);

glBgin(GL_PLYGN);

glVrtx3d(-0.6,0.0,-1.32);

glVrtx3d(-1.4,0.0,-0.725);

glVrtx3d(-0.9,-0.25,-0.8);

glnd();

glPpMtrix();

glPushMtrix();

glPlygnMd(GL_FRNT_ND_BK, PlygnMd);

gllr3dv(3);

glTrnsltf(1.0,0,0.05);

uxSlidBx(0.3,0.3,0.1);

glTrnsltf(0,0,-0.1);

uxSlidBx(0.15,0.2,0.2);

glRttf(90+Bumngl,0,1,0);

gluylindr (qudri, 0.1, 0.05, 0.3, 8,20);

glRttf(-90-Bumngl,0,1,0);

glTrnsltf(BumX,0,-BumY);

gllr3d(0.8,0.7,0.5);

uxSlidSphr(0.03);

glPpMtrix();

glPushMtrix();

glPlygnMd(GL_FRNT_ND_BK, PlygnMd);

gllr3dv(1);

glSlf(3,1,1);

gluylindr (qudri, 0.5, 0.25, 0.4, 16,40);

glTrnsltf (0,0,0.1);

gluDisk (qudri, 0,0.42,16,1);

glTrnsltf (0,0,0.3);

gluDisk (qudri, 0,0.25,16,1);

glPpMtrix();

glPushMtrix();

gllr3dv(2);

glTrnsltf (0.13,0.0,-0.05);

glPlygnMd(GL_FRNT_ND_BK, PlygnMd);

uxSlidBx(0.75,0.4,0.28);

gllr3f(1.0,1.0,1.0);

glTrnsltf (0.,0.18,-0.1625);

glRttf (-90,1,0,0);

glRttf (180,0,1,0);

uxSlidTpt(0.03);

glTrnsltf (0.0,-0.15,-0.03);

uxSlidTrus(0.01,0.08);

glRttf (-180,0,1,0);

glRttf (90,1,0,0);

glPpMtrix();

glPushMtrix();

gllr3dv(1);

glPlygnMd(GL_FRNT_ND_BK, PlygnMd);

glTrnsltf (-0.6,0,-1.3);

gluylindr (qudri, 0.025, 0.045, 1.4, 8,40);

glTrnsltf (0.,0.,-0.03);

glTrnsltf(1.2,0,0);

gluylindr (qudri, 0.025, 0.045, 1.4, 8,40);

glPpMtrix();

glPushMtrix();

glPlygnMd(GL_FRNT_ND_BK, PlygnMd);

glTrnsltf(-0.6,0,-0.2);

glRttf(90,1,0,0);

glRttf(50,0,1,0);

gluylindr (qudri, 0.005, 0.005, 1.87, 8,20);

glRttf(-50,0,1,0);

glTrnsltf(1.2,0,0);

glRttf(50,0,1,0);

gluylindr (qudri, 0.005, 0.005, 1.25, 8,20);

glRttf(-50,0,1,0);

glTrnsltf(-2.1,0.2,0);

glRttf(-90,0,1,0);

glRttf(23,1,0,0);

gluylindr (qudri, 0.005, 0.005, 0.6, 8,20);

glPpMtrix();

glPushMtrix();

glPlygnMd(GL_FRNT_ND_BK, PlygnMd);

glRttf(90,0,1,0);

glTrnsltf(1.3,0,-0.6);

gluylindr (qudri, 0.001, 0.001, 1.2, 8,20);

glTrnsltf(-1.3,0,0.6);

glRttf(-90,0,1,0);

glTrnsltf(-2.05,0,-0.23);

glRttf(127,0,1,0);

gluylindr (qudri, 0.001, 0.001, 1.8, 8,20);

glRttf(-10,0,1,0);

gluylindr (qudri, 0.001, 0.001, 1.6, 8,20);

glRttf(-117,0,1,0);

glTrnsltf(0.35,0,0.15);

glRttf(125,0,1,0);

gluylindr (qudri, 0.001, 0.001, 1.4, 8,20);

glRttf(-125,0,1,0);

glTrnsltf(0.2,0,0.08);

glRttf(130,0,1,0);

gluylindr (qudri, 0.001, 0.001, 1.2, 8,20);

glPpMtrix();

glPushMtrix();

glTrnsltf (0.83,-1.2,-0.2);

glRttf(-75,1,0,0);

gluylindr (qudri, 0.001, 0.001, 0.83, 8,20);

glRttf(75,1,0,0);

glTrnsltf (0.72,0.4,0.0);

glRttf(-70,1,0,0);

glRttf(-20,0,1,0);

gluylindr (qudri, 0.001, 0.001, 0.68, 8,20);

glRttf(20,0,1,0);

glRttf(70,1,0,0);

glTrnsltd (-2.55,0.5,-0.2);

glRttf(20,0,1,0);

glRttf(13,1,0,0);

gluylindr (qudri, 0.001, 0.001, 0.445, 8,20);

glPpMtrix();

glPushMtrix();

glTrnsltd(-0.8,-0.4,-0.2);

glRttf(20,0,1,0);

glRttf(8,1,0,0);

gluylindr (qudri, 0.001, 0.001, 0.22, 8,20);

glPpMtrix();

glPushMtrix();

glTrnsltf(-1.3,-0.25,-0.4);

glRttf(20,0,1,0);

glRttf(8,1,0,0);

gluylindr (qudri, 0.001, 0.001, 0.44, 8,20);

glPpMtrix();

glPushMtrix();

glTrnsltf(-0.9,-0.25,-0.8);

glRttf(35,0,1,0);

glRttf(13,1,0,0);

gluylindr (qudri, 0.001, 0.001, 1.02, 8,20);

glPpMtrix();

gluDltQudri(qudri);

glFinish();

SwpBuffrs(::wglGturrntD());

}

BL KrksViw::nrsBkgnd(D* pD)

{

rturn TRU;

}

vid KrksViw::usr_PrInit()

{

glnbl(GL_DPTH_TST);

glnbl(GL_LR_MTRIL);

glShdMdl (GL_SMTH);

glnbl(GL_LIGHTING);

glnbl(GL_NRMLIZ);

glnbl(GL_UT_NRML);

pht_img = uxDIBImgLd("lud2.bmp");

glPixlStri(GL_UNPK_LIGNMNT, 1);

gluBuild2DMipmps(GL_TXTUR_2D, 3,

pht_img->sizX,

pht_img->sizY,

GL_RGB, GL_UNSIGND_BYT,

pht_img->dt);

glLightMdli(GL_LIGHT_MDL_LL_VIWR, GL_TRU);

GLflt light_psitin[] = { 1.0, 0.0, 0.0, 1.0 };

glLightfv(GL_LIGHT0, GL_PSITIN, light_psitin);

glnbl(GL_LIGHT0);

GLflt light1_mbint[] = { 0.2, 0.2, 0.2, 1.0 };

GLflt light1_diffus[] = { 1.0, 1.0, 1.0, 1.0 };

GLflt light1_spulr[] = { 1.0, 1.0, 1.0, 1.0 };

GLflt light1_psitin[] = { -2.0, 2.0, 1.0, 1.0 };

GLflt spt_dirtin[] = { 1.0, 1.0, 1.0 };

glLightfv(GL_LIGHT1, GL_MBINT, light1_mbint);

glLightfv(GL_LIGHT1, GL_DIFFUS, light1_diffus);

glLightfv(GL_LIGHT1, GL_SPULR, light1_spulr);

glLightfv(GL_LIGHT1, GL_PSITIN, light1_psitin);

glLightf(GL_LIGHT1, GL_NSTNT_TTNUTIN, 1.5);

glLightf(GL_LIGHT1, GL_LINR_TTNUTIN, 0.5);

glLightf(GL_LIGHT1, GL_QUDRTI_TTNUTIN, 0.2);

glLightf(GL_LIGHT1, GL_SPT_UTFF, 45.0);

glLightfv(GL_LIGHT1, GL_SPT_DIRTIN, spt_dirtin);

glLightf(GL_LIGHT1, GL_SPT_XPNNT, 2.0);

glnbl(GL_LIGHT1);

GLflt light5_diffus[] = {1.0, 0.0, 0.0};

GLflt light5_psitin[] = {1,0,1, 1.0};

glnbl(GL_LIGHT5);

glLightfv(GL_LIGHT5, GL_DIFFUS, light5_diffus);

glLightfv(GL_LIGHT5, GL_PSITIN, light5_psitin);

glLightf(GL_LIGHT5, GL_NSTNT_TTNUTIN, 0.0);

glLightf(GL_LIGHT5, GL_LINR_TTNUTIN, 0.4);

glLightf(GL_LIGHT5, GL_QUDRTI_TTNUTIN, 0.8);

GLflt light6_diffus[] = {0.0, 1.0, 0.0};

GLflt light6_psitin[] = {1, 1, 1.0};

glnbl(GL_LIGHT6);

glLightfv(GL_LIGHT6, GL_DIFFUS, light6_diffus);

glLightfv(GL_LIGHT6, GL_PSITIN, light6_psitin);

glLightf(GL_LIGHT6, GL_NSTNT_TTNUTIN, 0.0);

glLightf(GL_LIGHT6, GL_LINR_TTNUTIN, 0.4);

glLightf(GL_LIGHT6, GL_QUDRTI_TTNUTIN, 0.8);

GLflt light7_diffus[] = {0.0, 0.0, 1.0};

GLflt light7_psitin[] = {1, 1.0, 1.0};

glnbl(GL_LIGHT7);

glLightfv(GL_LIGHT7, GL_DIFFUS, light7_diffus);

glLightfv(GL_LIGHT7, GL_PSITIN, light7_psitin);

glLightf(GL_LIGHT7, GL_NSTNT_TTNUTIN, 0.0);

glLightf(GL_LIGHT7, GL_LINR_TTNUTIN, 0.4);

glLightf(GL_LIGHT7, GL_QUDRTI_TTNUTIN, 0.8);

}

vid KrksViw::nPrsp()

{

DlgPrs bjt;

int rsult = bjt.DMdl();

int rry[3]={0,0,0};

if (rsult==IDK)

{

swith (bjt.hkd_p)

{

s 1:

{

glMtrixMd(GL_PRJTIN);

glLdIdntity();

glrth(bjt.m_1,bjt.m_2,bjt.m_3,bjt.m_4,bjt.m_5,bjt.m_6);

glMtrixMd(GL_MDLVIW);

KrksViw::usr_RndrSn();

fxMssgBx("hngd t glrth");

brk;

}

s 2:

{

glMtrixMd(GL_PRJTIN);

glLdIdntity();

glFrustum(bjt.m_1,bjt.m_2,bjt.m_3,bjt.m_4,bjt.m_5,bjt.m_6);

glMtrixMd(GL_MDLVIW);

KrksViw::usr_RndrSn();

fxMssgBx("hngd t glFrustum");

brk;

}

s 3:

{

glMtrixMd(GL_PRJTIN);

glLdIdntity();

gluPrsptiv(bjt.m_1,bjt.m_2,bjt.m_3,bjt.m_4);

glMtrixMd(GL_MDLVIW);

KrksViw::usr_RndrSn();

fxMssgBx("hngd t gluPrsptiv");

brk;

}

s 4:

{

glMtrixMd(GL_PRJTIN);

glLdIdntity();

gluLkt(bjt.m_1,bjt.m_2,bjt.m_3,bjt.m_4,bjt.m_5,bjt.m_6,bjt.m_7,bjt.m_8,bjt.m_9);

glMtrixMd(GL_MDLVIW);

KrksViw::usr_RndrSn();

fxMssgBx("hngd t gluLkt");

brk;

}

dfult:

glMtrixMd(GL_PRJTIN);

glLdIdntity();

gluPrsptiv(urDpth,sp,1,20);

glMtrixMd(GL_MDLVIW);

KrksViw::usr_RndrSn();

fxMssgBx("Md nt sltd - st t dfult");

}

}

ls fxMssgBx("nld");

}

vid KrksViw::nhr(UINT nhr, UINT nRpnt, UINT nFlgs)

{

swith (nhr) {

s 119:

rtts[0]+=1;

brk;

s 115:

rtts[0]-=1;

brk;

s 100:

rtts[1]-=1;

brk;

s 97:

rtts[1]+=1;

brk;

s 56:

TrnsY-=0.05;

brk;

s 50:

TrnsY+=0.05;

brk;

s 52:

TrnsX+=0.05;

brk;

s 54:

TrnsX-=0.05;

brk;

s 113:

if(Bumngl<90)Bumngl+=1;

brk;

s 122:

if(Bumngl>1)Bumngl-=1;

brk;

}

usr_RndrSn();

Viw::nhr(nhr, nRpnt, nFlgs);

}

BL KrksViw::nMusWhl(UINT nFlgs, shrt zDlt, Pint pt)

{

if (zDlt>0)

urDpth++;

ls urDpth--;

glMtrixMd(GL_PRJTIN);

glLdIdntity();

gluPrsptiv(urDpth,sp,1,20);

glMtrixMd(GL_MDLVIW);

KrksViw::usr_RndrSn();

rturn Viw::nMusWhl(nFlgs, zDlt, pt);

}

vid KrksViw::nptins()

{

Dlgptins ptbj;

int rsult = ptbj.DMdl();

if (rsult==IDK)

{

if((ptbj.m_rtt==tru)/*&&(ptbj.m_rtt!=0)*/)

{

if(ptbj.m_spd!=0)

sn_rtt_spd=ptbj.m_spd;

ls sn_rtt_spd=1;

if (ptbj.m_XRG==tru)

{

if(ptbj.m_XGrup==1) XSnRt=-1;

ls XSnRt=1;

}

ls XSnRt=0;

if (ptbj.m_YRG==tru)

{

if(ptbj.m_YGrup==1) YSnRt=-1;

ls YSnRt=1;

}

ls YSnRt=0;

if(FirstTimr==0)

{

FirstTimr=1;

StTimr(1,sn_rtt_spd,NULL);

}

ls

{

KillTimr(1);

StTimr(1,sn_rtt_spd,NULL);

}

}

ls

{

if(FirstTimr==1)

{

KillTimr(1);

FirstTimr=0;

}

XSnRt=0;

YSnRt=0;

}

if ((ptbj.m_Bumngl!=0)&&(ptbj.m_Bumngl>=1)&&(ptbj.m_Bumngl<=90))

Bumngl=ptbj.m_Bumngl;

if (ptbj.m_BumSpd!=0)

BumStrtSpd=ptbj.m_BumSpd;

if (ptbj.m_Tx==1) lud_nbl=1;

ls lud_nbl=0;

if(ptbj.lr1[0]!=-1)

{

1[0]=ptbj.lr1[0];

1[1]=ptbj.lr1[1];

1[2]=ptbj.lr1[2];

}

if(ptbj.lr2[0]!=-1)

{

2[0]=ptbj.lr2[0];

2[1]=ptbj.lr2[1];

2[2]=ptbj.lr2[2];

}

if(ptbj.lr3[0]!=-1)

{

3[0]=ptbj.lr3[0];

3[1]=ptbj.lr3[1];

3[2]=ptbj.lr3[2];

}

swith(ptbj.m_Plygn)

{

s 0:

PlygnMd=GL_FILL;

brk;

s 1:

PlygnMd=GL_LIN;

brk;

s 2:

PlygnMd=GL_PINT;

brk;

}

if(ptbj.m_L1==TRU) glnbl(GL_LIGHT0); ls glDisbl(GL_LIGHT0);

if(ptbj.m_L2==TRU) glnbl(GL_LIGHT1); ls glDisbl(GL_LIGHT1);

if(ptbj.m_L3==TRU) glnbl(GL_LIGHT5); ls glDisbl(GL_LIGHT5);

if(ptbj.m_L4==TRU) glnbl(GL_LIGHT6); ls glDisbl(GL_LIGHT6);

if(ptbj.m_L5==TRU) glnbl(GL_LIGHT7); ls glDisbl(GL_LIGHT7);

if(ptbj.m_FG==TRU)

{

glnbl(GL_FG);

swith (ptbj.m_FgMd)

{

s 0:

glFgf(GL_FG_MD,GL_XP2);

brk;

s 1:

glFgf(GL_FG_MD,GL_XP);

brk;

s 2:

glFgf(GL_FG_MD,GL_LINR);

brk;

}

glFgfv (GL_FG_LR,ptbj.Fglr);

glFgf(GL_FG_DNSITY,0.2);

}

ls glDisbl(GL_FG);

}

KrksViw::usr_RndrSn();

}

vid KrksViw::nTimr(UINT nIDvnt)

{

swith(nIDvnt)

{

s 1:

{

if (XSnRt>0)XSnRt++;

if (XSnRt<0)XSnRt--;

if (YSnRt>0)YSnRt++;

if (YSnRt<0)YSnRt--;

} brk;

s 2:

{

BumTim+=0.01;

BumX=0+BumStrtSpd*BumTim*s((dubl)Bumngl*3.14/180);

BumY=0+BumStrtSpd*BumTim*sin((dubl)(Bumngl*3.14/180)-9.8*BumTim*BumTim/2);

if (BumY<=-0.7)

{

KillTimr(2);

SndTimr=0;

BumTim=0;

BumX=0;

BumY=0;

}

} brk;

}

KrksViw::usr_RndrSn();

Viw::nTimr(nIDvnt);

}

vid KrksViw::nBum()

{

if(SndTimr==0)

{

StTimr(2,20,NULL);

SndTimr=1;

}

ls

{

KillTimr(2);

SndTimr=0;

}

}

.1 -

.1 -

.2 -

.1 -

Allbest.ru


  • pnGL . , . .

    [261,3 K], 02.07.2011

  • OpenGL. , 3D- "".

    [1,7 M], 28.06.2011

  • OpenGL. "": , .

    [1,4 M], 26.06.2011

  • OpenGL, . "", . .

    [507,2 K], 02.07.2011

  • OnG1, , . , .

    [1,0 M], 26.06.2011

  • OpenGL . . .

    [1,1 M], 23.06.2011

  • " " ++ OpenGL MFC, Visual Studio 6.0. , .

    [3,9 M], 29.06.2011

  • C++ OpenGL Microsoft Visual Studio. " ". .

    [1,8 M], 23.06.2011

  • OnGL , , . " " .

    [42,5 K], 26.06.2011

  • nGl: , , , , , . . .

    [39,2 K], 23.06.2011

, , ..
PPT, PPTX PDF- .
.