aaoa oe c cooae OpenGL ocoe aecoo oae eeo oe oea "o"

OpenGL: coe oooc, aoa c aa, oe, ceee, ea aeao, oae ea aa. aaoa oe aa eeo ce occe ae co.

,
25.06.2011

CECO OAOA A OCCCO EEA

OCACEOE OAOAEOE EEE

CEO OECCOAOO OAOA

CEEO-AAC OCACE EEC ECEһ

aea oao cce eoo

ocea aca

coo aoe

o ce oea eoe aa

a e aaoa oe c cooae OpenGL ocoe aecoo oae eeo oe oea o컻

Ao oea . . ae

Ceaoc oaoe cce eoo

ooe oea E. . oae

Caoo, 2011

AOA

oee acao a e C++ c cooae oe OpenGL MFC. oaa coaa cee Visual Studio 6.0. aa ao oe ce ecaee aa. eec oooc oo ae aco, ae a: acoa o ece, o ea aa, o eco coo cea, /o ec, o ea ooa, eee ea oeo. oe aoaa, e oo a aa c aa. ae co oeco oo ac oac. oaa ee o o eec, oo co c Windows - oe, o aae a accooc oaoo oa.

Coeae

  • EEE
    • 1. OAOAE C COOAE OE OPENGL
    • 1.1. Ocoe oooc
    • 1.2 aoa c aa
    • 1.3 oe
    • 1.4 Oceee
    • 1.5 Cea aeao
    • 1.6 Coae ea aa
  • 2. AAOA OE OCOOE AECOO OAE EEO OE OEA O̻
    • 2.1 aaoa oe aa eeo ce
    • 2.2 aaoa eeca ooae
    • 2.3 aaoa occe ae co
  • 3. OAOOE OAOE OECEEE
    • 3.1 Oe cee o oae
    • 3.2 oaoe aaee
    • 3.3 oeca ca oaa eoo oea
    • 3.4 eoa eeco oao oecee
    • 3.5 ooco ooae
  • AEE O
  • CCO EA
    • OE
    • EEE
    • Ceac ee oae oo e ee, aa o oe aaa ccea oeoa eao ee. ae, oa ea aa cecoaa oo a ceoea, e cecoao eoo caaa oac a. ce oa cac c "" c cooae aoeoo oa, o ao oae eaoac co eo ooae aeco oa. C oo o oeccoo aec coee ea aa caa eaoc ecoa oeo. o oe e ooe oaoo oecee coc c ceo oeo - o occe a-o caao, ooe oo ca oa, eace o oooa oeaoo cce. O e a caao, cec o ce e ec OpenGL.
    • OpenGL (Open Graphics Library -- oa aeca oea, aecoe API) -- cea, oeea eac o a oaoa occ-aoe oa eec aca oe, co e e oe a.
    • a aoo oe, OpenGL -- o oco cea, o ec oe, oca ao ooe oeee. ooe oooa a ocoe o cea coa eaa -- oe , cooec ao cea. eaa coe oooc oooa a, e o ooo. Ec aaaa e ooe eaoa a-o oooc, oa oa oaa oao. ooe o o ceece ec (conformance tests -- ec a cooece) ee e eaa e accoaa a OpenGL eaa. a oao, aaoa oaoo oecee ocaoo ac cooa , ocae cea, oca e eaa oce aaoa aaaoo oecee.
    • ee eaa OpenGL cec Windows, Unix-ao, PlayStation 3 Mac OS. eaa oo eocac ooe eoaaeo ao co oooc oce. Cec ae co oae eaa cea OpenGL, oo oo ec oea Mesa. eo cooae Mesa ec eoao eaae OpenGL, o ooc c e coeca a oe oa.
    • Cea OpenGL eecaaec ocoo ARB (Architecture Review Board), oo cooa 1992 o. oco coco oa, aeecoa coa oo acocaoo ocoo API. Coaco oao ca OpenGL, ea ARB c ea ooco a o 2004 oa c ooe oeccoa aec aaa cec SGI, 3Dlabs, Matrox Evans & Sutherland (oee oe), ooe oeec aec aaa cec ATI NVIDIA, ooe oeccoo Intel, ooe oeo oeoo oooa IBM, Apple, Dell, Hewlett-Packard Sun Microsystems, a ae o eo oeo oo c id Software. Microsoft, o ocooooo ocoa, oa eo ae 2003 oa. oo oco eo, a o aaec ooe oeco oa, caoc ac OpenGL ARB eee ooo oa. aoe ooe co oa, oee aooa eeco, ooo OpenGL ca a eeco ooo aae c o oeco oooce.
    • (Kurt Akeley) a Ca (Mark Segal) c aoa oao cea OpenGL. c e (Chris Frazier) eaoa ec 1.1. o (Jon Leech) eaoa ec c 1.2 o ec 2.0.

OpenGL oeec a cee e aa:

C cooc aaa a 3D-coee, eoca aao e API.

C a oooc aaa ao, e eaa eocae oaoc c oo oao .

Oco o ao OpenGL ec oee aoo eo aec o e oe, oooo c ocee aeaeco oaoo oe a ocoee acoo a a ae / a. eoe acoa acea oc aec oeeo (graphics pipeline), oo o c ecae coo ce aoa. Acooe oco oa OpenGL oaa o : o o oa aece a o oee, o o oee a aoe coee acoa.

OpenGL ec ooe oe API, o ae oaca oa o oceoaeoc ao, o oco e aco a (ea oo). o ec oco oe o eco ooo, oa c cea eeaec e c a (ae ceo eea), oooe oaaaec coc a ae. C oo coo, ea oo ee o oaca ooo a aoo eo a aeaec oee, c o coo -- a coo ee a oa.

1. OAOAE C COOAE OE OPENGL

1.1 Ocoe oooc

oooc OpenGL oca ee eo oe. ce oo ae a aeo.

oca o oee oe eo o ea (), ooe cocoa ooaa aeca occea. OpenGL aece o ca o, , ooo ..

oca coo cea ca oca ooe aaeo coo cea, acooe eeo cee.

aa ao. C oo aa ao oac oeee, a e a ae ooaaee oe. coa, ec c oo o oeeec, o oc a ae, o a oee coco oa a a. aece ao OpenGL ooe aaa e, aaec aeaa, ec, aae ocee.

aa ooe aa ooee aae ao ocace, aae oea ae. a aae, ccea coe e oo ao oco oaee, o oce oe, oaaec e o e.

ao eoeec eoaoa oo oac o ae eoaoa oeo - ooo, eeoc, acaoae.

o OpenGL oe o ooee oea, ae a cooae cao ocoe oeoce, aee e aeo oae, aoa c oae a oe cee ..

1.2 aoa c aa

aa a eoaoa oeo ce OpenGL coc oea a aa, o aa a a: oeo-oa, aa oe aa ec. ce o e ae 4x4. oa aa oeee eoaoa oea o ooaa, ae a aae eeoc, eee acaa ooo. aa oe oeee, a oeoac eee oe a ococ aa ( ooe ooa), a aa ec oeee aoee ec a oe.

oee ooa a a oco oe oa cooece oa OpenGL, oeee ooa (a ao, o oaa glVertex*.

oo o a, a a ao e, coec oaa: void glMatrixMode(GLenum mode), o ooo, co aee aaea mode a GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE ae e ao c oeo-oo ae, ae oe, ae ec cooeceo. oa oa, aa a oo oo a, eooo caaa cao cooec e.

oeee eeo a eeo a aec oaa void glLoadMatrix[f d](GLtype *m), e m aae a acc 16 eeo a float double cooec c aae oa, o caaa e oe aca e coe a, ae oo, e ee. Ee a cee oa ae, acce m aa acaa o coa.

oaa void glLoadIdentity(void) aee e a a e.

1.3 oe

OpenGL cec caae oa aa ooaeco (aaeo) eceo oe. e oe oe aa oaa void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far) void gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top).

ea oaa coae a oe cee oe oc (aaeee oc) eocooe ccee ooa. aae oa aa o (left, bottom, znear) (right, top, zfar), ooe oea eo e ao ee a oa oa. aae near far aa accoe o e ae ococe ocee o ae o o (0,0,0) o oae.

co 1 - Ooaeca oe

ecea oe oeeec oao void gluPerspective(GLdouble angley, GLdouble aspect, GLdouble znear, GLdouble zfar), ooa aae cee oc oc eocooe ccee ooa. aae angley oeee o oc aca o oc oe aoc aaoe o 0 o 180. o oc o oc x aaec aaeo aspect, oo oo aaec a ooee coo oac oa (a ao, aeo oa). aae zfar znear aa accoe o aae o ococe ocee o e o ooe. e oe ooee zfar/znear, e e ee aac acooee o oeoc, a a o oa eo e acac caa a aaoe o 0 o 1.

ee e aaa a oe, o e ao c o ae oao glMatrixMode(GL_PROJECTION) coc e, a glLoadIdentity().[5]

co 2 - ecea oe

1.4 Oceee

OpenGL coec oe ocee, cooec c ooo e o oeeec eco aoa: coca aeaa ec, eo oa o oe, a ae ooee coa cea aae. oeoo acea oceeoc oe ao cooa ee oa, oao oa: a glScale*(), o e oae. o o a, o cooa e oaa eoo oae, oo aec oo oa glEnable(GL_NORMALIZE) .

aa oa aaeo ocee coc oa void glLightModel[i, f](GLenum pname, GLenum param) void glLightModel[i f]v(GLenum pname, const GLtype *params).

Ae pname oeee, ao aae oe ocee e acaac oe a cee ae: GL_LIGHT_MODEL_LOCAL_VIEWER, aae param oe e aae ooee aae. Ec o ae GL_FALSE, o aaee ooa caec aae oc z, e acoc o ooe o ooaa. Ec e o ae GL_TRUE, o aae aoc aae oo cce ooa. o oe aeco ocee, o coe eo ace. aee o oa - GL_FALSE.

GL_LIGHT_MODEL_TWO_SIDEaae param oe e ae eo acea oceeoc, a e, a oa ae. Ec o ae GL_FALSE, o oceeoc accaec oo e ae. Ec e o ae GL_TRUE, ace ooc oa ae. aee o oa - GL_FALSE.

GL_LIGHT_MODEL_AMBIENT aae params oe coea ee e eece ca, ooe oee e oooo ocee ae cae occ oeee coo cea. aee o oa - (0.2, 0.2, 0.2,1.0).

1.5 Cea aeao

aa aaeo eeo aeaa coc oa void glMaterial[i f](GLenum face, GLenum pname, GLtype param) void glMaterial[i f]v(GLenum face, GLenum pname, GLtype *params).

C oo oo oee acce, ea ea aeaa, a ae cee eaoo oae ecoc e cea, ec oe oe cec. ao eo aae e oeec aee param, ac o ae pname:

- GL_AMBIENTaae params oe coea ee e eece ae eo RGBA, ooe oee acce e aeaa (e aeaa e). aee o oa - (0.2, 0.2, 0.2, 1.0);

- GL_DIFFUSEaae params oe coea ee e eece ae eo RGBA, ooe oee e aeaa. aee o oa - (0.8, 0.8, 0.8, 1.0);

- GL_SPECULAR aae params oe coea ee e eece ae eo RGBA, ooe oee ea e aeaa. aee o oa - (0.0, 0.0, 0.0, 1.0);

- GL_SHININESS aae params oe coea oo eoe eeceoe aee aaoe o 0 o 128, oooe oeee cee eaoo oae aeaa. aee o oa - 0;

- GL_EMISSION aae params oe coea ee e eece ae eo RGBA, ooe oee ecoc aeoo cea aeaa. aee o oa: (0.0, 0.0, 0.0, 1.0);

- GL_AMBIENT_AND_DIFFUSE aeo oa oa: glMaterial*() co aee pname GL_AMBIENT GL_DIFFUSE oao ae params.

oo cee, o o oa: glMaterial[i f]() ooe oo cao cee eaoo oae aeaa. oaa glMaterial[i f]v() coec aa oca aaeo.

aae face oeee ae, oo aaec o aea oe a ae GL_FRONT, GL_BACK GL_FRONT_AND_BACK.

Ec cee aea oeo aac o aaeo, eoeec caaa cao e, a glEnable() c aaeo GL_COLOR_MATERIAL, a ae cooa oa void glColorMaterial(GLenum face, GLenum pname), e aae face ee aao cc, a aae pname oe a ce eecee ae. oce oo ae aoo c oo pname coca aeaa oeoo oea ( e) caaac oo oa glColor*(), o ooe ea oo oee eccoeo oa glMaterial*() oae eoc oa.

1.6 Coae ea aa

Oa eec aco coe oooc OpenGL - coae ea aa. eoe aaae ce coae eac e, a aceo oe c eooe aea, ooe oc, oa cee cc oaee oe.

a OpenGL eaec e ee ea oeo cee acoc o , .e. acco o o ae. eee ea oco o e o, o aoo ce a ae acea acoc o eaa OpenGL. oecco oo aco a.

e ea aaa eooo a oa glEnable(GL_FOG).

eo ce ecoc aa ee oo oee c oo oa void glFog[if](enum pname, T param); void glFog[if]v(enum pname, T params);

Ae pname oe a cee ae:

GL_FOG_MODEae param oeee o, o ooo e cc ecoc aa oe. o cae param oe a ae:

- GL_EXP ecoc cec o oe f=exp(-d*z);

- GL_EXP2 ecoc cec o oe f=exp(-(d*z)2);

- GL_LINEAR ecoc cec o oe f=e-z/e-s,

e z - accoe o e, ooo cec ecoc aa, o o ae.

oe d, e, s aac c oo ce ae aea pname:

- GL_FOG_DENSITYparam oeee oe d;

- GL_FOG_STARTparam oeee oe s;

- GL_FOG_ENDparam oeee oe e.

e aa aaec c oo aea pname, aoo GL_FOG_COLOR o cae params - aae a acc 4- ooe ea.

2. AAOA OE OCOOE AECOO OAE EEO OE OEA O̻

2.1 aaoa oe aa eeo ce

ocoa aoe oac aaec c eoa void CLab1View::OnDraw(CDC* pDC), ooo aec usr_RenderScene (). Oa oeae a oco oa ace a eooe ae ac, ooe ca c acooee eoo oe eae. oe coco eoeec o, a a , cea oc oooo.

coae 3D oea aaec c caoe oaa cee oac oa eoa BOOL CLab1View::usr_setuppixelformat() void CLab1View::usr_Resize(int x, int y, int width, int heidht) cooeceo. acco ooee eo usr_RenderScene (), o oooo ecae oe .

oeo oa o oeoac auxSolidCube auxSolidSphere. Ce oa cea 1 oeo - auxSolidCube. a ae a ceaa auxSolidCube, o o oeoo a 45 aco e glRotatef. ae, e a cea oo ae auxSolidCube. Oa cea a oeo, - ee a a 1 a ceo. ooe oo o ceao e ooa eoo eeeee eo a coo oa. ea a a ceaa auxSolidSphere. a oe eeee e o e glTranslatef , oe o c oo glScalef, eeae e glColor3f.

ec o eoa usr_RenderScene() ecae oe .

2.2 aaoa eeca ooae

ao oa aaoa eec, oo:

- a a e aa;

- a e aa;

- a aa;

- aa o;

- / ec;

- a ooo;

- a ecoo coo cea;

- aa ooaa ce oo aao;

- a a oe c oo .

ao e oae :

- aee oa - ae aco ce ce ac ae oa. (co .2).

oee ee o o eec, c oo oo aoa.

2.3 aaoa occe ae co

oe windows-ooee ocoao a co oaoe, coa oeee oa aec co. a oe oe ec windows oee, , ceoaeo, oaoa co aae aoe eco. oco co, a a, oeo ao oa, o oocc cee:

- WM_DESTROY - ocooee a ecco;

- WM_SIZE - ee ce ooceo aeo oa;

- WM_ERASEBKGND - eoae ea;

- WM_TIMER - coec coa aea;

- WM_MOUSEWHEEL - oaoa ae oeca ;

- WM_KEYDOWN - oaoa aa a;

- COMMAND(ID_PERSP, CKarkasView::OnPersp ()) - oaoa co oe oa aco ece;

- COMMAND(ID_OPTIONS, CKarkasView::OnOptions ()) - oaoa co oe oa aco a ae cooc e oea;

- COMMAND(ID_VIEW_1, CKarkasView::OnView1())- oaoa co oa a aa;

- COMMAND(ID_VIEW_SBROS, CKarkasView:: OnVewSbros()) - oaoa co aa o a a;

- COMMAND (ID_VIEW_MOVE, CKarkasView::OnMove ()) - oaoa aa o ee.

3. OAOOE OAOE OECEEE

3.1 Oe cee o oae

oaa aaec o. aoe c ao oao ooae ec oooc aoa c ao oe aoo oea. aa ee ooceo oce, a a e aa, a e aa, a ooo, a ecoo coo cea, ae aaa aa, a a ce c oo oeca , a a aee oe caaa cooc ae. oaoe oeceee, a ooo aaoaa oee - Microsoft Visual C++ 6.0.

3.2 oaoe aaee

aa oaa eaaaec ecae eeo oe oa. oee ae cee oooc:

- aa oe

- a a e aa;

- a e aa;

- a aa;

- aa o;

- / ec;

- a ooo;

- a ecoo coo cea;

- a aaa aae ece;

- aa ooaa ce oo aao;

- a a oe c oo .

3.3 oeca ca oaa eoo oea

aa OpenGL oco ecoo ao.

1. ae caaae oa cee. oa o oae cee aaec aa oa a a ea, ae a oeoc. c a ca ecaec ceao ce PIXELFORMATDESCRIPTOR. aee eeae a accoee oeaoo ccee, a oa cee. oce oo, a ccea oco eo, oa ee aoee coaa oa c e, oo oeaec oece coca. e, ocece aoo oa oe, ec ChoosePixelFormat(). oce oa oaa cee SetPixelFormat() caaae eo oece coca.

2. Coae oec oa oe OpenGL. a oec coaec c oo wglCreateContext(), aee wglMakeCurrent() caaae e oec. wglGetCurrentDC() eooa oeoo aee oe, a wglGetCurrentDC() - ae oeca ocoee.

O a eoo ec usr_ReSize(), oo caaae ece oac oa.

a ooaee ce oeae eo usr_RenderScene(), oo ae co oee coa oea.

, aee eoo usr_RenderScene() ooo accoe aee 2.1 aaoa oe aa eeo ce, a ae oecoo oa c co oa accoe aee 2.3 aaoa occe ae co.

aoc ee a aoee a eoo - aa 3.1.

aa 3.1 - Ocoe eo

eo

aaee

aaee aaeo

1

PreCreateWindow (CREATESTRUCT& cs)

aa oa

cs - oe c CREATESTRUCT.

ooc eee ae, coe eee-ea c CREATESTRUCT ee ea o oa eo aaeo.

2

usr_bSetupPixelFormat ()

caoa oaa cee

3

usr_bInitOpenGL()

aa OpenGL

4

user_DestoryOpenGL()

Ocooee ecco (-o OpenGL)

5

usr_ReSize (int x, int y, int width, int height)

oee o ce a a ee aea oa

x y oee ooa eoo eo a oa, width height - co oac oa

6

usr_RenderScene()

ce o eo

ae 3.2 ee cea aaoa acco.

aa 3.2 - Cea acco

aae

aaee

CMainframe

acc aoo oa oe. coec ae a oo

CKarkasApp

a acc oe. ae aoo ceo oe. eo oo acca o aa oe, oao a cooe ac aee oe.

CKarkasDoc

acc oea oe.

CKarkasView

acc oa ocoa oea. C ooae eco oac acca oea oe ae cae ae 3D oe.

CAboutDlg

acc caoo oa o oae

DlgPers

acc aoooo oa. C aco ce ece

DlgOptions

acc aoooo oa. C e a acoe ce.

3.4 eoa eeco oao oecee

ceo caa oaoo oa eoo ecoa oe co ce aaeca: oecco Intel Pentium c aoo acoo 800 e, oeaa a - e eee 64 a, coooe cooe ocaco - e eee 200 a, coco e oa-co, oo a Super VGA (co eo - 256). oaoe oeceee: oeaoa ccea WINDOWS 2000/XP e.

3.5 ooco ooae

cao oe eec cooa c caoooo ca, aaeoo aoe a Karkas.exe eo a eco ce. aca oa o a aa aa a e a .

aaoaoe oee ee o o eec, oo co c Windows - oe. oce aca oa ooae, oe aa ce ooaa e c oo oo aa (8 - e, 2 - , 4 - eo, 6 - ao, 7 9 - aee o oc, 1 3 - aee o o oc). ae eec oooc a a oe, o oo cea, aecoa oeco .

Cece oea a aec eo. oa ae a o aco, oce aa ooec oo e oo a ae o, oee o aa o O (co .2).

AEE O

oe aao aoo oe oe aece a o aaoe oa oeao cce ceeca Windows c eee eoo eeo a c cooae oe OpenGL.

a oao, oo e cee eee aa ao coo ao aa:

- ee o ao OpenGL ooo cee Windows;

- oee aec ao cooa cec OpenGL;

- oee ao oaoa aec ee aao ce;

- oee ao oaoa ea ee oe.

ae a oeea aoa c a oooc oe a:

- cooae ea aa;

- cooae aec o;

- eee ocee;

- aa ec;

CCO EA

1. oe .. oea aa. C., BHV, 2002.

2. e ee, oea aa caa OpenGL, 3-e ae.: e. c a. - .: aeco o c, 2005. - 1168 c.

3. A.., oeco A.. oea aa. ooae oe. oca, AO-, 2001.

4. oo . oaoae eeo a. C, BHV, 1998.

5. OpenGL performance optimization, Siggraph'97 course.

6. Visual Introduction in OpenGL, SIGGRAPH'98.

7. The OpenGL graphics system: a specification (version 1.1).

8. oaoae GLUT: oa aa. Miguel Angel Sepulveda, LinuxFocus.

9. The OpenGL Utility Toolkit (GLUT) Programming Interface, API version 3, specification.

10. , . OpenGL. oaoae oeo a. oeccoao/ ., - C.: e, 2004. - 1088c.

OE

A

http://www.stud.wiki/

http://www.stud.wiki/

co A.1 - Ao ocoe oea o

#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

stti hr 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()

{

StrtPs[0]=0;

StrtPs[1]=0;

urDpth=70;

TrnsX=0;

TrnsY=0;

x7 = 0;

y1 = 0;

x9 = 0;

y3 = 0;

FirstTimr=0;

SndTimr=0;

XSnRt=0;

YSnRt=0;

sn_rtt_spd=0;

X=0;

Y=0;

BumTim=0;

Bumngl=0;

BumStrtSpd=0;

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

}

vid KrksViw::nDrw(D* pD)

{

KrksD* pD = GtDumnt();

SSRT_VLID(pD);

usr_RndrSn();

}

BL KrksViw::nPrprPrinting(PrintInf* pInf)

{

rturn DPrprPrinting(pInf);

}

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

{

}

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

{

}

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

#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()

{

HGLR hr;

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

{

HGLR hr;

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(x7, 1, 0, 0);

glRttf(y1, 0, 1, 0);

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

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

glRttf(90, 0, -1, 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);

}

glPlygnMd(GL_FRNT_ND_BK, PlygnMd);

glSlf(3,1,1);

glTrnsltf (0.0,0.0+Y,0.0+X);

//wlls

glPushMtrix();

glSlf (0.55,1,1.6);

gllr3f(0.9,0.7,0.2);

uxSlidub(1.2);

glPpMtrix();

//rf

glPushMtrix();

glTrnsltf (0.0,0.6,0.0);

glSlf (0.55,1,1.13);

gllr3f (0.3,0.3,0.1);

glRttf (45.0,3.0,0.0,0.0);

uxSlidub (1.19);

glPpMtrix();

//tub

glPushMtrix();

glTrnsltf(-0.2,1.0,0.4);

glSlf(0.15,2.0,0.4);

gllr3f(0.5,0.0,0);

uxSlidub(1.0);

glPpMtrix();

//dr

glPushMtrix();

glTrnsltf(0.29,-0.1,-0.2);

glSlf(0.1,0.8,0.5);

gllr3f(0.1,0.1,0);

uxSlidub(1.0);

glTrnsltf(0.45,0.0,-0.24);

gllr3f(1,1,0);

uxSlidSphr(0.1);

glPpMtrix();

//fundtin

glPushMtrix();

glTrnsltf(0,-0.64,0);

glSlf(0.5,0.2,1.5);

gllr3f(0.2,0.1,0);

uxSlidub(1.4);

glPpMtrix();

//windw1

glPushMtrix();

glTrnsltf(0.1,0.0,0.85);

glSlf(0.05,1,0.5);

gllr3f(0.2,0.1,0);

uxSlidub(0.6);

glTrnsltf(-4.5,0.0,0.0);

uxSlidub(0.6);

glTrnsltf(2.3,0.23,0.15);

glSlf(6.5,0.17,0.5);

uxSlidub(0.6);

glTrnsltf(0,-2.7,0.0);

uxSlidub(0.6);

glTrnsltf(0,1.4,-0.2);

gllr3f(0.5,0.5,1);

glSlf(1.0,4.17,1.5);

uxSlidub(0.6);

glPpMtrix();

//windw2

glPushMtrix();

glTrnsltf(0.1,0.0,-0.85);

glSlf(0.05,1,0.5);

gllr3f(0.2,0.1,0);

uxSlidub(0.6);

glTrnsltf(-4.5,0.0,0.0);

uxSlidub(0.6);

glTrnsltf(2.3,0.23,-0.15);

glSlf(6.5,0.17,0.5);

uxSlidub(0.6);

glTrnsltf(0,-2.7,0.0);

uxSlidub(0.6);

glTrnsltf(0,1.4,0.2);

gllr3f(0.5,0.5,1);

glSlf(1.0,4.17,1.5);

uxSlidub(0.6);

glPpMtrix();

glFinish();

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("1.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");

}

}

lsfxMssgBx("");

}

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

{

swith (nhr) {

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 55: x7 += 2; if(x7==360)x7=0;brk;

s 49: y1 += 2;if(y1==360)y1=0; brk;

s 57: x9 += 2; if(x9==360)x9=0;brk;

s 51: y3 += 2; if(y3==360)y3=0;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:

{

X+=0.1*Bumngl*3.14/100;

Y+=0.1*BumStrtSpd*3.14/100;

if(X>=5)

{

KillTimr(2);

X=0;

Y=0;

}

}brk;

s 3:

{ X-=0.07;

if(X<=0.01)

{ KillTimr(3);}

}brk;}

KrksViw::usr_RndrSn();

Viw::nTimr(nIDvnt);

}

vid KrksViw::nBum()

{

if(X <= 0.5)

{

StTimr(2,100,NULL);

usr_RndrSn();

}ls

{

StTimr(3,100,NULL);

usr_RndrSn();

}

}

.1 -

.1 -

.2 -

stud.wiki




  • popa o acc OpenGL. Coae ea yaa. Papaoa poeyp yaa pexepo ce. Papaoa occe ypae co epeca ooae. yoaoe aaee, .

    [1,3 M], 21.06.2011

  • OpenGL. OpenGL. OpenGL . OpenGL. , OpenGL. OpenGL. . GLUT, OpenGL.

    [304,9 K], 01.06.2004

  • OpenGL, , , . "", .

    [866,8 K], 22.06.2011

  • OpenGL . . .

    [1,1 M], 23.06.2011

  • , OpenGL - 2D 3D . , DirectX.

    [19,4 K], 14.08.2013

  • OpenGL C#. , . Direct3D Microsoft DirectX, . .

    [2,1 M], 17.02.2013

  • y=sin(x) OpenGL. , . . .

    [87,2 K], 21.01.2011

  • , OpenGL X, Y, Z. . . . .

    [151,2 K], 21.01.2011

  • Windows oee, aaoaoe cee oaoa Microsoft Visual Studio 2008 a e C++ c cooae oe MFC. oaee oa aac oe. e cee, ayc oe, oeca cyya, aoa c oao.

    [1,2 M], 12.12.2011

  • OpenGL Windows, . . , . .

    [35,0 K], 04.07.2009