nGL ""

OpenGL. , 3D- "".

,
28.06.2011
1,7 M

. ,

, , , , .

htt://www.llbst.ru/

"- "

y

" "

y " nGL """

. .

230201 " "

y -081

y . .

, 2011

++ nGL MF. Visul Studi 6.0. . , : , y, , ./. y, , . , y y. y . y , y Windws-, y y.

    • 1. NGL
    • 1.1.
    • 1.2
    • 1.3.
    • 1.4
    • 1.5
    • 1.6 y
  • 2. "˨"
    • 2.1 y y
    • 2.2
    • 2.3 y
  • 3.
    • 3.1
    • 3.2 y
    • 3.3 yy y
    • 3.4 y y
    • 3.5 y
  • 4.

, . , y, y . "y" , . y . y - y - , , y . , yy nGL.

nGL - . y . 1982. y , Silin Grhis Silin IRIS . IRIS GL. IRIS GL, 1992 y y nGL. nGL - y y : Silin Grhis, In., Mirsft, IBM rrtin, Sun Mirsystms, In., Digitl quimnt rrtin (D), vns & Suthrlnd, Hwltt-krd rrtin, Intl rrtin Intrgrh rrtin.

nGL (n Grhis Librry), , nGL - . , nGL , y y, y y. nGL y. y y- y, y , , .

nGL? nGL - y, y. 150 , . , , , y (, , ...), (, y, , ...), , nGL . y , nGL (Rndring), 3D , y (y, ). . nGL yy y yyy y . nGL , y . nGL ( Windws) y , . , nGL , , y y - . , , .

1. NGL

1.1.

nGL y . y .

y y (), . nGL y , , y ..

y y , .

y y. y , yy . y , , , y . y nGL , , y, . y y y , . , , , . y y - , , .

nGL , , y , y ..

1.2

nGL y , : -, y. 44. , , . , yy ( ), y y .

y nGL, y ( , glVrt*.

, y y , y : vid glMtriMd(GLnum md), , "md" GL_MDLVIW, GL_RJTIN, GL_TTUR - , , y . , , y y .

y vid glLdMtri[f d](GLty *m), "m" y 16 flt dubl , , , . y , "m" .

vid glLdIdntity(vid) yy y y.

1.3

nGL yy () . vid glrth(GLdubl lft, GLdubl right, GLdubl bttm, GLdubl t, GLdubl nr, GLdubl fr) vid glurth2D(GLdubl lft, GLdubl right, GLdubl bttm, GLdubl t).

y y ( ) . (lft, bttm, znr) (right, t, zfr), y y y y y . "nr" "fr" y (0,0,0) y .

y 1 -

vid glurstiv(GLdubl ngly, GLdubl st, GLdubl znr, GLdubl zfr), y y . "ngly" y y y 0 180. Y "st", ( , ). "zfr" "znr" y . zfr/znr, y y y yy , y y "" y 0 1.

, y y glMtriMd(GL_RJTIN) yy, glLdIdntity().[5]

y 2 -

1.4

nGL y , : y, , . , : glSl*(), y y . y, y , glnbl(GL_NRMLIZ) .

y vid glLightMdl[i, f](GLnum nm, GLnum rm) vid glLightMdl[i f]v(GLnum nm, nst GLty *rms).

y "nm" , y y : GL_LIGHT_MDL_LL_VIWR, "rm" y . GL_FLS, z, . GL_TRU, . yy , y . y - GL_FLS.

GL_LIGHT_MDL_TW_SID "rm" y y , , . GL_FLS, . GL_TRU, . y - GL_FLS.

GL_LIGHT_MDL_MBINT "rms" , y y . y - (0.2, 0.2, 0.2,1.0).

1.5

y y vid glMtril[i f](GLnum f, GLnum nm, GLty rm) vid glMtril[i f]v(GLnum f, GLnum nm, GLty *rms).

, y , y , . y "rm", nm:

- GL_MBINT rms RGB, ( ). y - (0.2, 0.2, 0.2, 1.0);

- GL_DIFFUS "rms" RGB, y . y - (0.8, 0.8, 0.8, 1.0);

- GL_SULR "rms" RGB, . y - (0.0, 0.0, 0.0, 1.0);

- GL_SHININSS rms 0 128, . y - 0;

- GL_MISSIN rms RGB, y . y: (0.0, 0.0, 0.0, 1.0);

- GL_MBINT_ND_DIFFUS y : glMtril*() "nm" GL_MBINT GL_DIFFUS "rms".

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

"f" , GL_FRNT, GL_BK GL_FRNT_ND_BK.

, y y y , glnbl() GL_LR_MTRIL, y vid gllrMtril(GLnum f, GLnum nm), "f" , "nm" . "nm" ( ) y gllr*(), y glMtril*() .

1.6 y

y nGL - y. y , , , yy .

y nGL y y y, .. . , nGL. y.

y y glnbl(GL_FG).

y vid glFg[if](num nm, T rm); vid glFg[if]v(num nm, T rms);

y "nm" y :

GL_FG_MDy "rm" yy, y y . y "rm" :

- GL_ y f=(-d*z);

- GL_2 y f=(-(d*z)2);

- GL_LINR y f=-z/-s,

z - , y, .

d, , s y y nm:

- GL_FG_DNSITYrm d;

- GL_FG_STRTrm s;

- GL_FG_NDrm .

y y nm, GL_FG_LR y rms - y 4- .

2. "˨".

2.1 y y

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

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

. y y - 0.5, 0.5, 3.25, 16,40 , gluylindr (qudri, 0.5, 0.5, 3.25, 16,40) y - gluylindr (qudri, 0.5, 0.2, 0.55, 16,40) uSlidShr y 0.23, - gluylindr (qudri, 0.1, 0.5, 0.9, 16,40). y, y glTrnsltf. y : - y gluylindr (qudri, 0.15, 0.15, 0.45, 16,40), gluylindr (qudri, 0.02, 0.15, 0.25, 16,40), y . : y y y, y - glBgin (GL_LYGN) y glVrt3f(0.0,0.0,0.8), glVrt3f(0.8,0.0,-0.2), glVrt3f(0.8,-0.06,-0.4), glVrt3f(-0.05,-0.06,-0.8), y . y .

usr_RndrSn() .

2.2

, :

y;

y;

y;

;

;

/ yy;

;

;

y ;

;

y y;

y .

y:

"" - ( y y y ).

"" - (y .2).

y , y .

2.3 y

Windws- , y y . Windws-, , , . , y, , y:

WM_DSTRY - y;

WM_SIZ - ;

WM_RSBKGND - ;

WM_TIMR - y ;

WM_MUSWHL - ;

WM_KYDWN - ;

MMND(ID_RS, KrksViw::nrs ()) - ;

MMND(ID_TINS, KrksViw::ntins ()) - ;

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

MMND(ID_VIW_SBRS, KrksViw:: nVwSbrs()) - "Y y";

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

3.

3.1

"". y y . , y, y, , , y , y, y y , y , y . , - Mirsft Visul ++ 6.0.

3.2 y

. y :

;

y;

y;

y;

;

;

./. yy;

;

;

y ;

;

y y;

y .

3.3 yy y

nGL .

1. y . y y , . yy yy ILFRMTDSRITR. , . , , , y. y, y y, hsilFrmt(). y StilFrmt() y y.

2. nGL. y wglrtntt(), y wglMkurrnt() y y . y wglGturrntD() , wglGturrntD() - y .

usr_RSiz(), y y .

usr_RndrSn(), y .

y, usr_RndrSn() "2.1 y y ", yy "2.3 y ".

y - 3.1.

3.1 - y

1

rrtWindw (RTSTRUT& s)

s - yy RTSTRUT.

, - yy RTSTRUT .

2

usr_bStuilFrmt ()

Y

3

usr_bInitnGL()

nGL

4

usr_DstrynGL()

y (- nGL)

5

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

y

y y , width hight - y y

6

usr_RndrSn()

y

3.2 .

3.2 -

Minfrm

. y y

Krks

. Y . , y .

KrksD

y .

KrksViw

y. y y y 3D .

butDlg

Dlgrs

. y

Dlgtins

. y .

3.4 y y

y y y y : Intl ntium 800 , - 64 , - 200 , y -, Sur VG ( - 256). : WINDWS 2000/ .

3.5 y

y y y , "Krks." y . y y y y . y , y Windws-. y , y y (8 - , 2 - , 4 - , 6 - , 7 9 - , 1 3 - y ). y , , .

yy . y , , y y (y .2).

, y y .

4.

y Windws nGL.

, y y :

y nGL Windws;

y nGL;

y ;

y .

:

y;

;

;

y y;

.

1. .. . ., BHV, 2002.

2. , nGL, 3- .: . . - .: "", 2005. - 1168 .

3. .., .. . . , -, 2001.

4. . . , BHV, 1998.

5. nGL rfrmn timiztin, Siggrh'97 urs.

6. Visul Intrdutin in nGL, SIGGRH'98.

7. Th nGL grhis systm: sifitin (vrsin 1.1).

8. GLUT: . Migul ngl Sulvd, LinuFus.

9. Th nGL Utility Tlkit (GLUT) rgrmming Intrf, I vrsin 3, sifitin.

10. , . nGL. . / ., - .: "", 2004. - 1088.

.

htt://www.llbst.ru/

y .1 - ""

.

#inludd"stdf.h"

#inludd"Krks.h"

#inludd"KrksD.h"

#inludd"KrksViw.h"

#inludd"Dlgrs.h"

#inludd"dlgtins.h"

#inludd"mth.h"

#ifdfd_DBUG

#dfindnwdDBUG_NW

#undfdTHIS_FIL

sttidhrdTHIS_FIL[]d=d__FIL__;

#ndif

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

//dKrksViw

IMLMNT_DYNRT(KrksViw,dViw)

BGIN_MSSG_M(KrksViw,dViw)

//{{F_MSG_M(KrksViw)

N_WM_RT()

N_WM_DSTRY()

N_WM_SIZ()

N_WM_RSBKGND()

N_MMND(ID_RS,dnrs)

N_WM_HR()

N_WM_MUSWHL()

N_MMND(ID_TINS,dntins)

N_WM_TIMR()

N_MMND(ID_BUM,dnBum)

//}}F_MSG_M

//dStndrddrintingdmmnds

N_MMND(ID_FIL_RINT,dViw::nFilrint)

N_MMND(ID_FIL_RINT_DIRT,dViw::nFilrint)

N_MMND(ID_FIL_RINT_RVIW,dViw::nFilrintrviw)

ND_MSSG_M()

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

//dKrksViwdnstrutin/dstrutin

KrksViw::KrksViw()

{

Strts[0]=0;

Strts[1]=0;

urDth=70;

Trns=0;

TrnsY=0;

7d=d0;

y1d=d0;

9d=d0;

y3d=d0;

FirstTimr=0;

SndTimr=0;

SnRt=0;

YSnRt=0;

sn_rtt_sd=0;

=0;

Y=0;

BumTim=0;

Bumngl=0;

BumStrtSd=0;

lud_nbl=0;

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

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

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

lygnMd=GL_FILL;

}

KrksViw::~KrksViw()

{

}

BLdKrksViw::rrtWindw(RTSTRUT&ds)

{

s.styl|=(WS_LIHILDRN|WS_LISIBLINGS);

rturndViw::rrtWindw(s);

}

viddKrksViw::nDrw(D*dD)

{

KrksD*dDd=dGtDumnt();

SSRT_VLID(D);

usr_RndrSn();

}

BLdKrksViw::nrrrinting(rintInf*dInf)

{

rturndDrrrinting(Inf);

}

viddKrksViw::nBginrinting(D*d/*D*/,drintInf*d/*Inf*/)

{

}

viddKrksViw::nndrinting(D*d/*D*/,drintInf*d/*Inf*/)

{

}

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

#ifdfd_DBUG

viddKrksViw::ssrtVlid()dnst

{

Viw::ssrtVlid();

}

viddKrksViw::Dum(Dumntt&dd)dnst

{

Viw::Dum(d);

}

KrksD*dKrksViw::GtDumnt()d

{

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

rturnd(KrksD*)m_Dumnt;

}

#ndifd//_DBUG

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

//dKrksViwdmssgdhndlrs

BLdKrksViw::usr_bStuilFrmt()

{

intdiilTy=FD_TY_RGB;

DWRDddwFlgs=FD_DUBLBUFFR|

FD_SURT_NGL|

FD_DRW_T_WINDW;

ILFRMTDSRITRdfdd={0};

fd.nSiz=sizfd(ILFRMTDSRITR);

fd.nVrsin=1;

fd.dwFlgs=dwFlgs;

fd.iilTy=iilTy;

fd.lrBits=64;

fd.lhBitsd=64;

fd.umBits=64;

fd.DthBits=64;

fd.StnilBits=64;

fd.uBuffrs=64;

fd.iLyrTy=dFD_MIN_LN;

lintD*dlDd=dnwdlintD(this);

intdilfrmt;

ifd((ilfrmt=hsilFrmt(lD->GtSfHd(),&fd))==0)

{

MssgB("usr_bStuilFrmt:dhsilFrmtdfilddBUMdBUMdBUM");

lD->DltD();

rturndFLS;

}

ifd(StilFrmt(lD->GtSfHd(),ilfrmt,d&fd)==FLS)

{

MssgB("usr_bStuilFrmt:dStilFrmtdfilddBUMdBUMdBUM");

lD->DltD();

rturndFLS;

}

lD->DltD();

rturndTRU;d

}

BLdKrksViw::usr_bInitnGL()

{

HGLRdhr;

tmDd=dnwdlintD(this);

ifd(!usr_bStuilFrmt())drturndFLS;

hrd=dwglrtnttd(tmD->GtSfHd());

ifd(!wglMkurrnt(tmD->GtSfHd(),hr))drturndFLS;

usr_rInit();

rturndTRU;

}

viddKrksViw::usr_DstrynGL()

{

HGLRdhr;

hr=::wglGturrntntt();

::wglMkurrnt(NULL,NULL);

ifd(hr)

::wglDltntt(hr);

ifd(tmD)

tmD->DltD();

}

intdKrksViw::nrt(LRTSTRUTdlrtStrut)d

{

ifd(Viw::nrt(lrtStrut)d==d-1)

rturnd-1;

if(!this->usr_bInitnGL())

{

fMssgB("rrrdwithdrtingdrjt!dIU!");

rturnd-1;

}

rturnd0;

}

viddKrksViw::nDstry()d

{

Viw::nDstry();

this->usr_DstrynGL();

}

viddKrksViw::nSiz(UINTdnTy,dintd,dintdy)d

{

Viw::nSiz(nTy,d,dy);

intdd=d,dyd=dy;

usr_RSizd(0,0,,y);

}

viddKrksViw::usr_RSiz(intd,dintdy,dintdwidth,dintdhight)

{

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

glMtriMd(GL_RJTIN);

glLdIdntity();

ifd(hightd==d0)dsd=d1;

ls

sd=d(GLflt)width/hight;

glurstiv(urDth,s,1,20);

glMtriMd(GL_MDLVIW);

}

viddKrksViw::usr_RndrSn()d

{

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

gllr(GL_LR_BUFFR_BITd|dGL_DTH_BUFFR_BIT);

glLdIdntity();

glTrnsltfd(0,0,-4);

glTrnsltf(Trns,TrnsY,0);d

glRttf(SnRt,0,1,0);

glRttf(YSnRt,1,0,0);

glRttf(7,d1,d0,d0);

glRttf(y1,d0,d1,d0);

glRttf(y3,d0,d-1,d0);

glRttf(9,d-1,d0,d0);

glRttf(90,d0,d-1,d0);

GLUqudribjd*dqudrid=dgluNwQudri();

gluQudriDrwStyl(qudri,dGLU_FILL);

ifd(lud_nbl==1)

{

glnbl(GL_TTUR_2D);

glnbl(GL_TTUR_GN_S);

glnbl(GL_TTUR_GN_T);

glushMtri();

gllr3f(1,1,1);

glTrnsltf(0,0,0.45);

glTGni(GL_S,dGL_TTUR_GN_MD,dGL_SHR_M);

ddddglTGni(GL_T,dGL_TTUR_GN_MD,dGL_SHR_M);

uSlidShr(10);

glMtri();

glDisbl(GL_TTUR_GN_S);

glDisbl(GL_TTUR_GN_T);

glDisbl(GL_TTUR_2D);

}

gllygnMd(GL_FRNT_ND_BK,dlygnMd);

glSlf(3,1,1);

glTrnsltfd(0.0,0.0+Y,0.0+);

glushMtri();

gllr3dv(1);

glTrnsltfd(0.0,0.0,-1.5);

glSlf(0.42,1,1);

gluylindrd(qudri,d0.5,d0.5,d3.25,d16,40);

glTrnsltfd(0.0,0.0,3.25);

gluylindrd(qudri,d0.5,d0.2,d0.55,d16,40);

glTrnsltfd(0.0,0.0,0.45);

uSlidShr(0.23);

glTrnsltfd(0.0,0.0,-4.58);

gluylindrd(qudri,d0.1,d0.5,d0.9,d16,40);

glMtri();

glushMtri();

gllr3dv(3);

glTrnsltfd(0.0,0.6,-1.5);

glSlf(0.35,1,1);

gluylindrd(qudri,d0.15,d0.15,d0.45,d16,40);

glTrnsltfd(0.0,0.0,-0.25);

gluylindrd(qudri,d0.02,d0.15,d0.25,d16,40);

glMtri();

glushMtri();

gllr3dv(3);

glTrnsltfd(0.24,0.2,-1.3);

glSlf(0.35,1,1);

gluylindrd(qudri,d0.15,d0.15,d0.45,d16,40);

glTrnsltfd(0.0,0.0,-0.35);

gluylindrd(qudri,d0.06,d0.15,d0.35,d16,40);

glMtri();

glushMtri();

gllr3dv(3);

glTrnsltfd(-0.24,0.2,-1.3);

glSlf(0.35,1,1);

gluylindrd(qudri,d0.15,d0.15,d0.45,d16,40);

glTrnsltfd(0.0,0.0,-0.35);

gluylindrd(qudri,d0.06,d0.15,d0.35,d16,40);

glMtri();

glushMtri();

glBgind(GL_LYGN);

gllr3dv(2);

glVrt3f(0.0,0.0,0.8);

glVrt3f(0.8,0.0,-0.2);

glVrt3f(0.8,-0.06,-0.4);

glVrt3f(-0.05,-0.06,-0.8);

glVrt3f(0.0,0.0,0.8);

glVrt3f(0.8,-0.05,-0.2);

glVrt3f(0.8,-0.10,-0.4);

glVrt3f(-0.05,-0.18,-0.8);

glVrt3f(0.0,0.0,0.8);

glVrt3f(0.8,0.0,-0.2);

glVrt3f(0.8,-0.05,-0.2);

glVrt3f(0.8,0.0,-0.2);

glVrt3f(0.8,-0.06,-0.4);

glVrt3f(0.8,-0.10,-0.4);

glVrt3f(0.8,-0.05,-0.2);

glnd();

glushMtri();

glBgind(GL_LYGN);

glVrt3f(0.8,-0.06,-0.4);

glVrt3f(-0.05,-0.06,-0.8);

glVrt3f(-0.05,-0.18,-0.8);

glVrt3f(0.8,-0.10,-0.4);

glnd();

glushMtri();

glBgind(GL_LYGN);

gllr3dv(2);

glVrt3f(-0.0,0.0,0.8);

glVrt3f(-0.8,0.0,-0.2);

glVrt3f(-0.8,-0.06,-0.4);

glVrt3f(0.05,-0.06,-0.8);

glVrt3f(-0.0,0.0,0.8);

glVrt3f(-0.8,-0.05,-0.2);

glVrt3f(-0.8,-0.10,-0.4);

glVrt3f(0.05,-0.18,-0.8);

glVrt3f(-0.0,0.0,0.8);

glVrt3f(-0.8,0.0,-0.2);

glVrt3f(-0.8,-0.05,-0.2);

glVrt3f(-0.8,0.0,-0.2);

glVrt3f(-0.8,-0.06,-0.4);

glVrt3f(-0.8,-0.10,-0.4);

glVrt3f(-0.8,-0.05,-0.2);

glnd();

glushMtri();

glBgind(GL_LYGN);

glVrt3f(-0.8,-0.06,-0.4);

glVrt3f(0.05,-0.06,-0.8);

glVrt3f(0.05,-0.18,-0.8);

glVrt3f(-0.8,-0.10,-0.4);

glnd();

glushMtri();

glBgind(GL_LYGN);

gllr3dv(2);

glVrt3f(0.0,0.5,-1.3);

glVrt3f(0.0,1.2,-2.3);

glVrt3f(0.015,1.2,-2.6);

glVrt3f(0.015,-0.2,-1.85);

glVrt3f(0.0,0.5,-1.3);

glVrt3f(0.0,1.2,-2.3);

glVrt3f(-0.015,1.2,-2.6);

glVrt3f(-0.015,-0.2,-1.85);

glnd();

glushMtri();

glBgind(GL_LYGN);

glVrt3f(0.015,1.2,-2.6);

glVrt3f(0.015,-0.2,-1.85);

glVrt3f(-0.015,-0.2,-1.85);

glVrt3f(-0.015,1.2,-2.6);

glnd();

glushMtri();

glBgind(GL_LYGN);

glVrt3f(0.0,1.2,-2.3);

glVrt3f(0.015,1.2,-2.6);

glVrt3f(-0.015,1.2,-2.6);

glVrt3f(0.0,1.2,-2.3);

glnd();

glushMtri();

gllr3dv(2);

glBgind(GL_LYGN);

glVrt3f(0.0,0.7,-1.7);

glVrt3f(0.3,0.7,-1.9);

glVrt3f(0.3,0.65,-2.1);

glVrt3f(0.0,0.65,-2.1);

glVrt3f(0.0,0.7,-1.7);

glVrt3f(0.3,0.7,-1.9);

glVrt3f(0.3,0.6,-2.1);

glVrt3f(0.0,0.6,-2.1);

glnd();

glushMtri();

gllr3f(1,1,1);

glBgind(GL_LYGN);

glVrt3f(0.3,0.7,-1.9);

glVrt3f(0.3,0.65,-2.1);

glVrt3f(0.3,0.6,-2.1);

glVrt3f(0.3,0.7,-1.9);

glVrt3f(0.3,0.65,-2.1);

glVrt3f(0.0,0.65,-2.1);

glVrt3f(0.0,0.6,-2.1);

glVrt3f(0.3,0.6,-2.1);

glnd();

glushMtri();

gllr3dv(2);

glBgind(GL_LYGN);

glVrt3f(-0.0,0.7,-1.7);

glVrt3f(-0.3,0.7,-1.9);

glVrt3f(-0.3,0.65,-2.1);

glVrt3f(-0.0,0.65,-2.1);

glVrt3f(-0.0,0.7,-1.7);

glVrt3f(-0.3,0.7,-1.9);

glVrt3f(-0.3,0.6,-2.1);

glVrt3f(-0.0,0.6,-2.1);

glnd();

glushMtri();

gllr3f(1,1,1);

glBgind(GL_LYGN);

glVrt3f(-0.3,0.7,-1.9);

glVrt3f(-0.3,0.65,-2.1);

glVrt3f(-0.3,0.6,-2.1);

glVrt3f(-0.3,0.7,-1.9);

glVrt3f(-0.3,0.65,-2.1);

glVrt3f(-0.0,0.65,-2.1);

glVrt3f(-0.0,0.6,-2.1);

glVrt3f(-0.3,0.6,-2.1);

glnd();

glMtri();

glFinish();

ddgluDltQudrid(qudri);

glFinish();

SwBuffrs(::wglGturrntD());

}

BLdKrksViw::nrsBkgnd(D*dD)d

{

rturndTRU;

}

viddKrksViw::usr_rInit()

{

glnbl(GL_DTH_TST);

glnbl(GL_LR_MTRIL);

ddddglShdMdld(GL_SMTH);d

glnbl(GL_LIGHTING);

glnbl(GL_NRMLIZ);

glnbl(GL_UT_NRML);

ddddht_imgd=duDIBImgLd("1.bm");

ddddglilStri(GL_UNK_LIGNMNT,d1);

gluBuild2DMims(GL_TTUR_2D,d3,

ddddddddddddddddddht_img->siz,

ddddddddddddddddddht_img->sizY,

ddddddddddddddddddGL_RGB,dGL_UNSIGND_BYT,

ddddddddddddddddddht_img->dt);

ddd

glLightMdli(GL_LIGHT_MDL_LL_VIWR,dGL_TRU);

GLfltdlight_sitin[]d=d{d1.0,d0.0,d0.0,d1.0d};d

glLightfv(GL_LIGHT0,dGL_SITIN,dlight_sitin);

glnbl(GL_LIGHT0);

GLfltdlight1_mbint[]d=d{d0.2,d0.2,d0.2,d1.0d};

GLfltdlight1_diffus[]d=d{d1.0,d1.0,d1.0,d1.0d};

GLfltdlight1_sulr[]d=d{d1.0,d1.0,d1.0,d1.0d};

GLfltdlight1_sitin[]d=d{d-2.0,d2.0,d1.0,d1.0d};

GLfltdst_dirtin[]d=d{d1.0,d1.0,d1.0d};

glLightfv(GL_LIGHT1,dGL_MBINT,dlight1_mbint);

glLightfv(GL_LIGHT1,dGL_DIFFUS,dlight1_diffus);

glLightfv(GL_LIGHT1,dGL_SULR,dlight1_sulr);

glLightfv(GL_LIGHT1,dGL_SITIN,dlight1_sitin);

glLightf(GL_LIGHT1,dGL_NSTNT_TTNUTIN,d1.5);

glLightf(GL_LIGHT1,dGL_LINR_TTNUTIN,d0.5);

glLightf(GL_LIGHT1,dGL_QUDRTI_TTNUTIN,d0.2);

glLightf(GL_LIGHT1,dGL_ST_UTFF,d45.0);

glLightfv(GL_LIGHT1,dGL_ST_DIRTIN,dst_dirtin);

glLightf(GL_LIGHT1,dGL_ST_NNT,d2.0);

glnbl(GL_LIGHT1);

GLfltdlight5_diffus[]d=d{1.0,d0.0,d0.0};

GLfltdlight5_sitin[]d=d{1,0,1,d1.0};

glnbl(GL_LIGHT5);

glLightfv(GL_LIGHT5,dGL_DIFFUS,dlight5_diffus);

glLightfv(GL_LIGHT5,dGL_SITIN,dlight5_sitin);

glLightf(GL_LIGHT5,dGL_NSTNT_TTNUTIN,d0.0);

glLightf(GL_LIGHT5,dGL_LINR_TTNUTIN,d0.4);

glLightf(GL_LIGHT5,dGL_QUDRTI_TTNUTIN,d0.8);

GLfltdlight6_diffus[]d=d{0.0,d1.0,d0.0};

GLfltdlight6_sitin[]d=d{1,d1,d1.0};

glnbl(GL_LIGHT6);

glLightfv(GL_LIGHT6,dGL_DIFFUS,dlight6_diffus);

glLightfv(GL_LIGHT6,dGL_SITIN,dlight6_sitin);d

glLightf(GL_LIGHT6,dGL_NSTNT_TTNUTIN,d0.0);

glLightf(GL_LIGHT6,dGL_LINR_TTNUTIN,d0.4);

glLightf(GL_LIGHT6,dGL_QUDRTI_TTNUTIN,d0.8);

GLfltdlight7_diffus[]d=d{0.0,d0.0,d1.0};

GLfltdlight7_sitin[]d=d{1,d1.0,d1.0};

glnbl(GL_LIGHT7);

glLightfv(GL_LIGHT7,dGL_DIFFUS,dlight7_diffus);

glLightfv(GL_LIGHT7,dGL_SITIN,dlight7_sitin);d

glLightf(GL_LIGHT7,dGL_NSTNT_TTNUTIN,d0.0);

glLightf(GL_LIGHT7,dGL_LINR_TTNUTIN,d0.4);

glLightf(GL_LIGHT7,dGL_QUDRTI_TTNUTIN,d0.8);

}

viddKrksViw::nrs()d

{

Dlgrsdbjt;

intdrsultd=dbjt.DMdl();

intdrry[3]={0,0,0};

ifd(rsult==IDK)

{

swithd(bjt.hkd_)

{

sd1:d{

glMtriMd(GL_RJTIN);

glLdIdntity();

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

glMtriMd(GL_MDLVIW);

KrksViw::usr_RndrSn();

fMssgB("hngddtdglrth");

brk;}

sd2:d{

glMtriMd(GL_RJTIN);

glLdIdntity();

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

glMtriMd(GL_MDLVIW);

KrksViw::usr_RndrSn();

fMssgB("hngddtdglFrustum");

brk;}

sd3:d{

glMtriMd(GL_RJTIN);

glLdIdntity();

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

glMtriMd(GL_MDLVIW);

KrksViw::usr_RndrSn();

fMssgB("hngddtdglurstiv");

brk;}

sd4:d{

glMtriMd(GL_RJTIN);

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);

glMtriMd(GL_MDLVIW);

KrksViw::usr_RndrSn();

fMssgB("hngddtdgluLkt");

brk;}

dfult:d

glMtriMd(GL_RJTIN);

glLdIdntity();

glurstiv(urDth,s,1,20);

glMtriMd(GL_MDLVIW);

KrksViw::usr_RndrSn();

fMssgB("Mddntdsltdd-dstdtddfult");

}

}

lsfMssgB("");

}

viddKrksViw::nhr(UINTdnhr,dUINTdnRnt,dUINTdnFlgs)d

{

ddswithd(nhr)d{d

dddsd56:dTrnsY-=0.05;dbrk;

dddsd50:dTrnsY+=0.05;dbrk;

dddsd52:dTrns+=0.05;dbrk;

dddsd54:dTrns-=0.05;dbrk;

dddsd55:d7d+=d2;dif(7==360)7=0;brk;

dddsd49:dy1d+=d2;if(y1==360)y1=0;dbrk;

dddsd57:d9d+=d2;dif(9==360)9=0;brk;

dddsd51:dy3d+=d2;dif(y3==360)y3=0;brk;

ddd}

dddusr_RndrSn();

Viw::nhr(nhr,dnRnt,dnFlgs);

}

BLdKrksViw::nMusWhl(UINTdnFlgs,dshrtdzDlt,dintdt)

{

ifd(zDlt>0)

urDth++;

lsdurDth--;

glMtriMd(GL_RJTIN);

glLdIdntity();

glurstiv(urDth,s,1,20);

glMtriMd(GL_MDLVIW);

KrksViw::usr_RndrSn();

rturndViw::nMusWhl(nFlgs,dzDlt,dt);

}

viddKrksViw::ntins()d

{

Dlgtinsdtbj;

intdrsultd=dtbj.DMdl();

ifd(rsult==IDK)

{

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

{

if(tbj.m_sd!=0)

sn_rtt_sd=tbj.m_sd;

lsdsn_rtt_sd=1;

ifd(tbj.m_RG==tru)

{

if(tbj.m_Gru==1)dSnRt=-1;

lsdSnRt=1;

}

lsdSnRt=0;

ifd(tbj.m_YRG==tru)d

{

if(tbj.m_YGru==1)dYSnRt=-1;

lsdYSnRt=1;

}

lsdYSnRt=0;

if(FirstTimr==0)d

{

FirstTimr=1;

StTimr(1,sn_rtt_sd,NULL);

}

ls

{

KillTimr(1);

StTimr(1,sn_rtt_sd,NULL);

}

}

lsd

{

if(FirstTimr==1)

{

KillTimr(1);

FirstTimr=0;

}

SnRt=0;

YSnRt=0;

}

ifd((tbj.m_Bumngl!=0)&&(tbj.m_Bumngl>=1)&&(tbj.m_Bumngl<=90))d

Bumngl=tbj.m_Bumngl;

ifd(tbj.m_BumSd!=0)

BumStrtSd=tbj.m_BumSd;

ifd(tbj.m_T==1)dlud_nbl=1;

lsdlud_nbl=0;

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

{

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

1[1]=tbj.lr1[1];

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

}

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

{

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

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

2[2]=tbj.lr2[2];

}

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

{

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

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

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

}

swith(tbj.m_lygn)

{

sd0:dlygnMd=GL_FILL;dbrk;

sd1:lygnMd=GL_LIN;dbrk;

sd2:dlygnMd=GL_INT;dbrk;

}

if(tbj.m_L1==TRU)dglnbl(GL_LIGHT0);dls glDisbl(GL_LIGHT0);

if(tbj.m_L2==TRU)dglnbl(GL_LIGHT1);dls glDisbl(GL_LIGHT1);

if(tbj.m_L3==TRU)dglnbl(GL_LIGHT5);dls glDisbl(GL_LIGHT5);

if(tbj.m_L4==TRU)dglnbl(GL_LIGHT6);dls glDisbl(GL_LIGHT6);

if(tbj.m_L5==TRU)dglnbl(GL_LIGHT7);dls glDisbl(GL_LIGHT7);

if(tbj.m_FG==TRU)

{

glnbl(GL_FG);

swithd(tbj.m_FgMd)

{

sd0:glFgf(GL_FG_MD,GL_2);brk;

sd1:glFgf(GL_FG_MD,GL_);brk;

sd2:glFgf(GL_FG_MD,GL_LINR);brk;

}

glFgfvd(GL_FG_LR,tbj.Fglr);

glFgf(GL_FG_DNSITY,0.2);

}

lsdglDisbl(GL_FG);

}

KrksViw::usr_RndrSn();

}

viddKrksViw::nTimr(UINTdnIDvnt)d

{

swith(nIDvnt)

{

sd1:

{

ifd(SnRt>0)SnRt++;

ifd(SnRt<0)SnRt--;

ifd(YSnRt>0)YSnRt++;

ifd(YSnRt<0)YSnRt--;

}brk;

sd2:

{

+=0.1*Bumngl*3.14/100;

Y+=0.1*BumStrtSd*3.14/100;

if(>=5)

{

KillTimr(2);

=0;

Y=0;

}

}brk;

sd3:

{d-=0.07;

if(<=0.01)

{dKillTimr(3);}

}brk;}

KrksViw::usr_RndrSn();

Viw::nTimr(nIDvnt);

}

viddKrksViw::nBum()d

{

if(d<=d0.5)

{

StTimr(2,100,NULL);

usr_RndrSn();

}ls

{

StTimr(3,100,NULL);

usr_RndrSn();

}

}

.

y .1 -

. ""

y .1 - ""

y .2 -

.

y .1 -

llbst.ru


  • OpenGL. "": , .

    [1,4 M], 26.06.2011

  • OpenGL . . .

    [1,1 M], 23.06.2011

  • nGl: , , , , , . . .

    [39,2 K], 23.06.2011

  • pnGL Windws . , .

    [747,0 K], 26.06.2011

  • OnG1, , . , .

    [1,0 M], 26.06.2011

  • OpenGL, , , . "", .

    [866,8 K], 22.06.2011

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

    [1,8 M], 23.06.2011

, , ..
PPT, PPTX PDF- .
.