peepa oe oeoo paa

aaee ooo oe OpenGL. " ". pyypa yoaa eoo poea. peoa eeoy popaoy oeee.

,
03.07.2011

1. OPENGL

1.1 aaee ooo oe OpenGL

1.2 aoa apa

1.3 poe

1.4 eee

1.5 oae ea yaa

2. ڨ ͻ

2.1 apaoa poeyp yaa peepo e

2.2. apaoa epea ooae

2.3 apaoa oe ypae o

3.

3.1 e ee o popae

3.2 yoaoe aaee

3.3 oea pyypa yoaa eoo poea

3.4 peoa eeoy popaoy oeee

3.5 yooo ooae

4.

poee

poee

poee

poee

OpenGL e o a oyp pa popa epeo (API - Application Programming Interface) papao poe oa yepo peepo pa.

aap OpenGL (Open Graphics Library - opa paea oea) papaoa yepe 1992 oy ey pa oa papao popaoo oeee a e aapao-ea epe, po peaa a pa aopa. oo aapa aa oea IRIS GL, papaoaa po Silicon Graphics Inc.

oea aae ooo 120 pa oa, oope popa oye aa oeo oepa, eoo aa epa pae poe.

a eo e paea ea OpenGL oepae oo pooee aapa popa aop. a ea oya e, o paoae pee Windows, ooae oepo Apple. ooo papopaee o e Mesa (ae API a ae OpenGL) oo opoa oe oepao e, o e Linux.

apaep ooeo OpenGL, oope oee papopaee pae oo paeoo aapa, :

ao. ooe ee aape peay a opao, o opa oeo papaoa paee popa oeeee.

aeo epeoo. poe, oye OpenGL, apapy oao ya peya e ao o a oyeo oepaoo e opaa oopae opa. poe oo, poe oy o a a epoa oepa, a a pao a yepoepa.

eo pee. aap OpenGL ee poyay pyypy yo o epe, o ooe e apaa oaa ee poe, oepae ee po oa, e ooae py pae oe. eooe y oeee oeo pa oopyoae peaoa a ypoe oe aeo ypoa papaoy poe.

ae opoeo aooo aea pao peep poe ypoae oae yea e e ypa oepo pa - oepoae peep oeo, apaae, eyppoae, aa .. poe yoae ooo OpenGL ya opo yaeo oe eopee pae aeo peea.

1. OPENGL

1.1 aaee ooo oe OpenGL

ypoe papao popa a e ++ yeye ooe oeo oo oe peaae aopo ope pee oae, o e paeo o paoaa pe. oea OpenGL e o a oyp popa epeo (API) pao peepo pao. aap OpenGL yepe 1992 . ey pa oa papao popaoo oeee. o ooo aa oea IRIS GL, papaoaa po Silicon Graphics a ae oe paeo a opoo yepea (1982 .).

OpenGL epeo a pa paea oea (Open Graphics Library). popa, oye OpenGL, apapy oao ya peya o o oepao ea - a epoa oepa, a pao a a yepoepa.

o pe popaa, OpenGL - o popa epe pae ypo (apep, pae yopee). ae e ooo 150 pa y, oo oop popa oe aaa oa pa peep yep oeo o yaa (peep). .e. popae ao aa eoooee oeo peepo popae, opee pye apaep (oopo, paee), aa oa oeo (e, eypa, aepa ..), ooee aae, a ae oea OpenGL o eepa yepo poe o peepo e.

oo aa, o oea OpenGL e oeo oo yaa peep e (rendering library). a e oepae ae o epepe ypoa (apep, aaypy ) e oep pe ypae pa oa. eeee aoe epep ypo oeo OpenGL opeo oepaoo ee e aae popaa.

oe ooo OpenGL, peoaee popay, oo pae a eoo py:

1. eoepee papoe p. a ooe po po e oae oe. eoepee p - o o, ope ooyo. apo pa oe a opae.

2. a. a pe opoe a p o oop oa.

3. oe oee peopaoa. peopaoa oo aaa popaeoe paooee oeo, e opy oeo aaa ooee aep, oopo OpenGL po peypyee poeooe opaee.

4. aoa eo. oepa eo OpenGL e pe RGBA (pa - e - - popao) e pe (e aae opo oepo ape).

5. aee e oepoe.

6. oa yepa. OpenGL oya oapa, oa yepa. oa yepa pee ypae epa p ya. p o opaee aoo apa aaa pye eo yepe, a a pa ap opye oo oe oo, a oo apoa.

7. aoee eyp. eyp ypoa oae pea e. a oe, apep, epy, ao eypy (eoopoe opaee), o oe ye e ae (apep, epa ye e a paoe ).

8. aae. oaeoe aae oepye yeao, oey papo e. p aa opeo OpenGL ee eo e ee a, o ope oopaa a pae e ao".

9. eee. aae paooe, eo ea oo ea.

10. eae e. apep, ya, , popao oeo. pea oo ea e oee pea.

o oea OpenGL peoae pae e ooo oepoa opoee pep e, eoope paee y eopeeo OpenGL eoy. apep, o aa ooee apaee aep ae e pe paa poeoy apy, o opeo oaoo poo e. ooy OpenGL yey a aaee ooaee oe.

a oe aae GLU. a oea e a aapa oae ee ao oeo OpenGL. oa GLU o oee oe y (apep, oa pa a peye eo oa oaa). oee GLU e ae y pao o aa, peaoa ooee oepa a apa ooee poe.

e e ee oe - GLUT ( Unix) GLAUX ( MS Windows). peaoa e oo ooee y OpenGL ( opoe eoop o yp poe oya epapa), o ae e y pao oa, aaypo oo poe. o paoa OpenGL opeo oepaoo ee (apep, Windows Unix), ao poe eoopy peapey apoy, oopa a o oepaoo e. GLUT GLAUX oo yao eo oaa opee oo, oopo ye paoa OpenGL, aa y opao oa o aayp .

ooo OpenGL oa epe y eo oe. e y oo pae a aeop.

y oa po opee oe eo ypo epap (p), oope ooa oopaa paea oea. OpenGL aee po ya o, , ooyo ..

y oa oo ea ya oa ooe apaepo oo ea, paooe peepo ee.

y aa apyo. oo aa apyo popa opeee, a yy e a pae oopaaee oe. py oa, e oo po opeee, o o a pae, o apy opee oo oa a pa. aee apyo OpenGL ooe aaa e, apaep aepaa, eyp, apaep oee.

y yaa ooe aa ooee aae pyao popae, apaep oea aep. a apaep, ea oe e oo pao opo opaee, o oe oe, oaae e o pe.

aop y eoepe peopaoa oo popay o pae peopaoa oeo - oopo, epeo, aapoae.

p o OpenGL oe o ooee oepa, ae a ooae ao opoe oepoe, yaee e paeo opae, paoa opae a ypoe ee ..

1.2 aoa apa

aa pa peopaoa oeo e OpenGL oy oepa a apa, p o paa p a ap: oeo-oa, apa poe apa eyp. e o e paep 4x4. oa apa opeee peopaoa oea po oopaa, ae a apae epeo, eee aaa oopo. apa poe opeee, a yy poepoa peepe oe a oo paa ( ooe oopa), a apa eyp opeee aoee eyp a oe.

oee oopa a ap poo oe oa ooeye oa OpenGL, opeee oopay (a pao, o oaa glVertex*.

oo o pa, ay apy ao e, oye oaa: void glMatrixMode(GLenum mode), o oopo, o aee apaepa mode pa GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE ae pe pao oeo-oo ape, ape poe, ape eyp ooeeo. oa oa, aa ap oo oo a, eooo aaa yao ooey pe.

opeee eeo ap eyeo a ae oaa void glLoadMatrix[f d](GLtype *m), e m yaae a a 16 eeo a float double ooe aae oa, p o aaa e oe aa ep oe ap, ae opo, pe eep. e pa eye opa ae, ae m apa aaa o oa.

oaa void glLoadIdentity(void) aee eyy apy a ey.

1.3 poe

OpenGL yey aape oa aa opopaeo (apaeo) epeo poe. ep poe 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).

epa oaa oae apy poe yee oe o (apaeee o) eoopoe ee oopa. apaep oa aa o (left, bottom, znear) (right, top, zfar), oope oea eoy ey paoy epey ya oa oa. apaep near far aa paoe o e ae ooe oee o yae o o (0,0,0) oy opae.

yo 1 - popaea poe

epea poe opeee oao void gluPerspective(GLdouble angley, GLdouble aspect, GLdouble znear, GLdouble zfar), oopa aae yee oy o eoopoe ee oopa. apaep angley opeee yo o paya o o y oe ao aaoe o 0 o 180. o o o o x aae apaepo aspect, oop oo aae a ooee opo oa oa (a pao, paepo oa).

apaep zfar znear aa paoe o aae o ooe oee o ye o ooe. e oe ooee zfar/znear, e ye yepe y yy paa paooee po oepo, a a o yoa eo ye aa aa ya aaoe o 0 o 1.

pee e aaa ap poe, yo pe pao yo ape oao glMatrixMode(GL_PROJECTION) po eyy, a glLoadIdentity().

yo 2 - epea poe

1.4 eee

OpenGL oye oe oee, ooe oopo e o opeee eo aopa: oa aepaa eyp, eo opa o oe, a ae ooee oa ea aae. oppeoo paea oeeo oe ao ooa ee opa, oao oa: a glScale*(), oy e y opae. o o ya, yo ooa pe opaa eopo opae, oop ae oo oa glEnable(GL_NORMALIZE) .

aa oa apaepo oee oy oa void glLightModel[i, f](GLenum pname, GLenum param) void glLightModel[i f]v(GLenum pname, const GLtype *params).

pye pname opeee, ao apaep oe oee ye apaa oe pa eye ae: GL_LIGHT_MODEL_LOCAL_VIEWER, apaep param oe ye aae ooee aae. o pae GL_FALSE, o apaee oopa ae apae o z, e ao o ooe o oopaa. e o pae GL_TRUE, o aae ao aae oo e oopa. o oe yy aeo oee, o yoe eo pae. aee o yoa - GL_FALSE.

GL_LIGHT_MODEL_TWO_SIDE apaep param oe ye ypae peo paea oeeo, a e, a opa pae. o pae GL_FALSE, o oeeo paae oo e pae. e o pae GL_TRUE, pae poo opa pae. aee o yoa - GL_FALSE.

GL_LIGHT_MODEL_AMBIENT apaep params oe oepa epe e eee a, oope opee e oooo oee ae yae oy opeee oo ea. aee o yoa - (0.2, 0.2, 0.2,1.0).

1.5 oae ea yaa

a epe ao oye ooo OpenGL - oae ea yaa. eoe ayaae e oae pea e, a aeo oe p eoope apea, oope o, oa ee pyy oaee oe.

ya OpenGL peaye ye ee ea oeo ee ao o y, .e. pao o o ae. eee ea poo o ep po, o aoo e a ae paepa ao o peaa OpenGL. poeo oo ao ypa.

e ea ayaa eooo a oay glEnable(GL_FOG).

eo e eo yaa epe oo opee oo oa void glFog[if](enum pname, T param); void glFog[if]v(enum pname, T params);

pye pname oe pa eye ae:

GL_FOG_MODE apye param opeee opyy, o oopo ye eo yaa oe. o yae param oe pa ae:

- GL_EXP eo e o opye f=exp(-d*z);

- GL_EXP2 eo e o opye f=exp(-(d*z)2);

- GL_LINEAR eo e o opye f=e-z/e-s,

e z - paoe o ep, oopo e eo yaa, o o ae.

oe d, e, s aa oo ey ae apyea pname:

- GL_FOG_DENSITY param opeee oe d;

- GL_FOG_START param opeee oe s;

- GL_FOG_END param opeee oe e.

e yaa aae oo apyea pname, paoo GL_FOG_COLOR o yae params - yaae a a 4- ooe ea.

2. ڨ ͻ

2.1 apaoa poeyp yaa peepo e

e oae a ooo paa oee eoe void CLR1View:: maindraw(). oe oo ooo ooo a po, o ooo ooa ae p, a p, poyo.

ep apoa o epe a o,oo po, (oa a e a e ) . aee apoa pa, oop oo a eae, a: o paa, epe paa, a paa, pea paa -poyo.

ae apoa aa pooe, a e ooe poyoo.

py, ooo paa ee opy peaoo pa.

e eooe oepa o ooy oeo py pyy poo y: glTranslatef, glRotatef.

e o eoa peae poe .

a e ee pyy o ea, oe, paooe o o epa oopaaeoo ya. oo a/a e yaa.

2.2 apaoa epea ooae

epe epe, ooae oe e paoy popa. e eye ooo:

- a/a ya;

- paopaa oe ooeo y oe;

- ee/ee pae o;

a e oae ope a, pa e oeo, aa ooe peea e:

aa 1 - ope a

y e

opa aa

1

pao

D

2

eo

A

3

ep

W

4

S

5

oa ya

T

6

pa ya

T

7

paee oe epe

X

8

paee oe aa

Z

9

apa

G

10

apa

H

11

/ e

1

12

paee o

;

13

paee o Y

;

2.3 apaoa oe ypae o

oe Windows-poee ooao a o opaoe, py oa oeee popa ypae o. a poe oe e Windows-poee, , eoaeo, opaoa o aae aoe eo. a popaa, ooaa a MFC epe a e aoy o opaoe o, popa oe yaa o, oop yo o p ooe opeoo o.

oo o, pa ay po, oppeo pao popa, oo eye:

- WM_SIZE;

- WM_DESTROY;

- WM_ERASEBKGND;

- WM_TIMER;

- ONKEYDOWN;

- ONMOUSEWHEEL;

opaoe o WM_SIZE oe o, eoo ee e ooeo paepo oa, opaoe o WM_DESTROY oooee a peypo. opaoe WM_ERASEBKGND ae o peopae epa. ae o ya opao o op yo aoo e.

oe

3.

3.1 e ee o popae

popaa aae peepa oe oeoo paa. p e ooa, ooae oyae ooo paoa yao oe oeoo paa. paa oe ooeo y oe, a/a ya, a a paee oe. popaoe oeeee, a oopo papaoao poee - Microsoft Visual Studio 2006 ooae oe OpenGL..

3.2 yoaoe aaee

aa popaa peaaae peae peepo oe oeoo paa. poee ae eye ooo:

- aa oe;

- e e ooee popae (paa ooeo y oe);

- a/a e yaa;

- a a paee oe.

3.3 oea pyypa yoaa eoo poea

aa OpenGL poo a aa.

ep a. eoe PreCreateWindow yaaae oa, oe eo - opa ee, o eae ye usr_bSetupPixelFormat, oopo o oepe o ChoosePixelFormat SetPixelFormat, oope poep opa yaaa eo ooeeo.

opo a. oae oe opoee, a o oeae wglCreateContext, a y oae o oe opoee OpenGL, oop oe ypoo, peoae epopo hdc. a yaaae ey oe wglMakeCurrent ( yae oea e y wglDeleteContext). a aa oeae eo usr_bInitOpenGL.

p aepe pao popa yo ooo ae peyp, a o oeae eo user_DestoryOpenGL.

e o a eo (usr_ReSize) yaaae oa oa, epey. ae p ao ee paepa oa.

oae ao e. a o oeae eo usr_RenderScene, oop ae p ao epepo oa, o oepe ae ooaee y poa maindraw, oopa o ay oe oeoo paa.

a a aa popaa e a aae Windows-poee, o aop e pao a o ope o, a ooae, o oepe, oyae ooo, epe epe, opoa o. ooy ay po pa opao o, a a op yo e, aae op a. ae ae oa oeo pyyp popa o oa paee 2.3 apaoa oe ypae o. oe peea aa, oopo oopae ooe eo (y) oao, a o o oea (aa 2).

aa 2 - oe eo y

y (eoa)

ae

1

PreCreateWindow

aa oa

2

usr_bSetupPixelFormat

aoa opaa ee

3

usr_bInitOpenGL

aa OpenGL

4

user_DestoryOpenGL

ooee peypo

5

usr_ReSize

oppepye o e a pa p ee paepa oa

6

usr_RenderScene

ye ey ( ao ae eo poa)

7

maindraw

ye pyoo aoo

8

Axis

ooaea y, pye o oopa

9

glPushMatrix

oeae e o eye ap.

10

glPopMatrix

aae a epy ea apy, paooey o ape a epe, ae ee oo.

11

glTranslated

oe eye ap a eop a.

12

glRotated

y e apa oopoa

13

glVertex3d

aae ooee ep peepo popae

14

glColor3d

aaae ey e ep.

3.4 peoa eeoy popaoy oeee

yeo yaa popaoo poya eoo epoa oep o ey apaepa: poeop Intel Pentium aoo aoo 800 e, oepaa a - e eee 64 a, oooe ooe popao - e eee 500 a, ypoo e oa-o, oop a Super VGA (o eo - 256). popaoe oeeee: Microsoft Visual Studio 2006, oepaoa ea WINDOWS 2000/XP e.

3.5 yooo ooae

yao poe peye opoa yaoooo a, paaeoo paoe a LR1.exe y peop a eo e. aya popa yo a paa aa a ey ay . ay oo oye yaoooo a.

o yoaoo aae poe o, o ooae oyae eye ooo:

- e ooee oe popae (paa ooeo y oe);

- a/a e yaa;

- a a oea.

o e ooee oe popae yo o oo ey e:

- aa a oy oo >, <., ^, v oopoa ooeyy opoy.

o pa epe () apo e yo o eyee:

o / e yaa yo:

- aa a ay T.

o paa oea epe eooo aa oy X, o paa oea aa - Z

pae apae poee p Windows ooo.

4.

e ao ypoo pao e oyee pae ao o papaoe popa oepao e eea Windows peee eoo peepo pa ooae oe OpenGL.

paa ypoo pao oe eye aa:

- yee po pao OpenGL

- pae pa;

- oeee;

- eo yaa po.

apaoaoe poee e ooyoao 3D oe oeoo paa, oep ee ooe oeo poe apoe, oo oop opaa ooe ooo ooa paeo oe OpenGL, a ae yo o epe. oe ooa aoo poe:

- ao;

- aeo epeoo;

- eo pee;

- ae opoeo aooo aea pao peep poe.

1. ope .. oepa paa. ., BHV, 2002.

2. . ., opeo . . oepa paa. ooae oe. oa, -, 2001.

3. opo . popapoae peepo pa. ,

4. Performance OpenGL: Platform Independent Techniques.

5. oo . epe popapoa peepo pa Windows ep. a. - .: ep

6. Visual Introduction in OpenGL, SIGGRAPH'98.

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

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

9. poo ., aeo . eoe ooe. popapoae a Open GL. . 2000 .

10. oo, pyee- eo aop oepo pa pepa a Visual C++ (2003).

11. ep, eep - oepa paa aap OpenGL (2005)

poee

popa o opoe oe

void CLR1View::usr_RenderScene()

{

glClearColor(0.8f, 0.5f, 0.0f, 1);

glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);

glLoadIdentity();

glRotated(-15, -15, -25,0);

glTranslated(x_S, 0, 0);

glTranslated(0, y_S, 0);

glTranslated(0, 0, z_S);

glRotated(x_rotate, 1, 0,0);

glRotated(y_rotate, 0, 1,0);

glRotated(z_rotate, 0, 0,1);

glPushMatrix();

maindraw();

glPopMatrix();

glFinish();

SwapBuffers(::wglGetCurrentDC());

}

void CLR1View::maindraw(void)

{

glPushMatrix();

// epe oe

glPushMatrix();

glTranslated(-2, 0, 1.25);

glRotated(90, 1, 0, 0);

auxSolidCylinder(0.15, 4.5);

glPopMatrix();

//epee oea

//paoe oeo

glColor3d(0, 0, 0);

glPushMatrix();

glTranslated(-2, 0, 1.5);

glRotated(90, 1, 0, 0);

glRotated(g, 0, 1, 0);

auxSolidCylinder(0.9, 0.8);

glPopMatrix();

//eoe oeo

glPushMatrix();

glTranslated(-2, 0, -2.75);

glRotated(90, 1, 0, 0);

glRotated(g, 0, 1, 0);

auxSolidCylinder(0.9, 0.8);

glPopMatrix();

glColor3d(1, 0, 0);

glLineWidth(6);

// epe oe

glPushMatrix();

glColor3d(1, 1, 0);

glTranslated(-2, 0, 2.1);

glRotated(0, 0, 0, 1);

glRotated(g, 0, 0, 1);

glBegin(GL_LINES);

glVertex3d(0, 0.8, 0.3);

glVertex3d(0, -0.8, -0.3);

glVertex3d(0, 0.8, -0.3);

glVertex3d(0, -0.8, 0.3);

glVertex3d(-0.8, 0, 0.3);

glVertex3d(0.8, 0, -0.3);

glVertex3d(-0.8, 0, -0.3);

glVertex3d(0.8, 0, 0.3);

glEnd();

glPopMatrix();

glPushMatrix();

glColor3d(1, 1, 1);

glTranslated(-2, 0, -2.1);

glRotated(0, 0, 0, 1);

glRotated(g, 0, 0, 1);

glBegin(GL_LINES);

glVertex3d(0, 0.8, 0.3);

glVertex3d(0, -0.8, -0.3);

glVertex3d(0, 0.8, -0.3);

glVertex3d(0, -0.8, 0.3);

glVertex3d(-0.8, 0, 0.3);

glVertex3d(0.8, 0, -0.3);

glVertex3d(-0.8, 0, -0.3);

glVertex3d(0.8, 0, 0.3);

glEnd();

glPopMatrix();

glLineWidth(1);

glColor3d(0, 0, 1);

// a oe

glPushMatrix();

glTranslated(7.5, 0, 1.25);

glRotated(90, 1, 0, 0);

auxSolidCylinder(0.15, 4.5);

glPopMatrix();

//ae oea

//paoe

glColor3d(0, 0, 0);

glPushMatrix();

glTranslated(7.5, 0, 1.5);

glRotated(90, 1, 0, 0);

glRotated(g, 0, 1, 0);

auxSolidCylinder(0.9, 1);

glPopMatrix();

//eoe

glPushMatrix();

glTranslated(7.5, 0, -2.75);

glRotated(90, 1, 0, 0);

glRotated(g, 0, 1, 0);

auxSolidCylinder(0.9, 1);

glPopMatrix();

glLineWidth(4);

// a oe

glPushMatrix();

glColor3d(1, 1, 0);

glTranslated(7.5, 0.0, 0);

glRotated(0, 0, 1, 0);

glRotated(g, 0, 0, 1);

glBegin(GL_LINES);

glVertex3d(0.0, 0.8, 2.4);

glVertex3d(0.0, -0.8, 1.8);

glVertex3d(0.0, 0.8, 1.8);

glVertex3d(0.0, -0.8, 2.4);

glVertex3d(-0.8, 0, 2.4);

glVertex3d(0.8, 0, 1.8);

glVertex3d(-0.8, 0, 1.8);

glVertex3d(0.8, 0, 2.4);

glEnd();

glPopMatrix();

glPushMatrix();

glColor3d(1, 1, 0);

glTranslated(7.5, 0, 0.0);

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

glRotated(g, 0, 0, 1);

glBegin(GL_LINES);

glVertex3d(0.0, 0.8, -2.4);

glVertex3d(0.0, -0.8, -1.8);

glVertex3d(0.0, 0.8, -1.8);

glVertex3d(0.0, -0.8, -2.4);

glVertex3d(-0.8, 0, -2.4);

glVertex3d(0.8, 0, -1.8);

glVertex3d(-0.8, 0, -1.8);

glVertex3d(0.8, 0, -2.4);

glEnd();

glLineWidth(1);

glPopMatrix();

// paa

glPushMatrix();

glColor3d(1, 1, 0);

glTranslated(3, 0, 0);

auxSolidBox(16, 0.7, 2);

glPopMatrix();

//epe paa

glPushMatrix();

glColor3d(1, 1, 0);

glTranslated(7, 6, 0);

auxSolidBox(2, 12, 2);

glPopMatrix();

//a paa

glPushMatrix();

glColor3d(1, 1, 0);

glTranslated(7, 11, 0);

auxSolidBox(3, 3, 3);

glPopMatrix();

//pea paa

glPushMatrix();

glColor3d(1, 1, 0);

glTranslated(3, 10, 0);

auxSolidBox(10, 1.5, 1.5);

glPopMatrix();

//aa

glPushMatrix();

glColor3d(1, 1, 0);

glTranslated(-0.5, 7.8, 0);

auxSolidBox(0.2, 3, 0.2);

glPopMatrix();

//pooe

glPushMatrix();

glColor3d(0, 0, 0);

glTranslated(8.5, 5, 0);

auxSolidBox(1, 10, 1.5);

glPopMatrix();

//o-1

glPushMatrix();

glColor3d(0, 0, 1);

glTranslated(7, 11, 0);

auxSolidBox(2, 2, 3.2);

glPopMatrix();

//o-2

glPushMatrix();

glColor3d(0, 0, 1);

glTranslated(7, 11, 0);

auxSolidBox(3.2, 2, 2);

glPopMatrix();

//py

glColor3d(0, 0, 0);

glPushMatrix();

glTranslated(0, 5.5, 0);

glRotated(90, 1, 0, 1);

glRotated(g, 0, 1, 0);

auxSolidCylinder(0.9, 1);

glLineWidth(1);

glPopMatrix();

BOOL CLR1View::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)

{

if (zDelta>0)

{

Corner++;

}

else

{Corner--;}

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho(-Corner,Corner,-Corner,Corner,-Corner,Corner);

glMatrixMode(GL_MODELVIEW);

CLR1View::usr_RenderScene();

return CView::OnMouseWheel(nFlags, zDelta, pt);

}

void CLR1View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)

{

switch(nChar)

{

case VK_DOWN : x_rotate += 10;break;// paee o +

case VK_UP : x_rotate -= 10;break;// paee o -

case VK_LEFT : y_rotate += 10;break;// paee o Y +

case VK_RIGHT : y_rotate -= 10;break;// paee o Y -

case 188 : z_rotate += 10;break;// paee o Z +

case 190 : z_rotate -= 10;break;// paee o Z -

case 68 : x_S += 1;break; // epeeee o +

case 65 : x_S -= 1;break; // epeeee o -

case 87 : y_S += 1;break; // epeeee o Y +

case 83 : y_S -= 1;break; // epeeee o Y -

case 187 : z_S += 1;break; // epeeee o Z +

case 189 : z_S -= 1;break; // epeeee o Z -

/ oeee L

case 49 :

if(o==0)

{

glEnable(GL_LIGHTING);

o++;

}

else

if (o==1)

{

glDisable(GL_LIGHTING);

o--;

}

break;

case 90 : g += 25;break;// paa oea aa

case 88 : g -= 60;break;// paa oea epe

case 71 : glEnable(GL_BLEND);glDisable(GL_DEPTH_TEST); break; // popao G

case 72 : glDisable(GL_BLEND);glEnable(GL_DEPTH_TEST);break; // popao H

// / ya T

case 84 :

if(o==0)

{

glEnable(GL_FOG);

o++;

}

else

if (o==1)

{

glDisable(GL_FOG);

o--;

}

break;

case 75 : carcas=0;break;

case 76 : carcas=1;break;

}

Invalidate();

CView::OnKeyDown(nChar, nRepCnt, nFlags);

}

BOOL CLR1View::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)

{

if (zDelta>0)

{

Corner++;

}

else

{Corner--;}

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho(-Corner,Corner,-Corner,Corner,-Corner,Corner);

glMatrixMode(GL_MODELVIEW);

CLR1View::usr_RenderScene();

return CView::OnMouseWheel(nFlags, zDelta, pt);

}

poee

apaa ao

yo .1 - apaa ao

poee

op opoe peepoo oea pea OpenGL

poee

paa opa poe

yo .1 - paa opa poe

stud.wiki




  • OpenGL. , 3D- "".

    [1,7 M], 28.06.2011

  • OpenGL. "": , .

    [1,4 M], 26.06.2011

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

    [1,8 M], 23.06.2011

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

    [3,9 M], 29.06.2011

  • OpenGL, , , . "", .

    [866,8 K], 22.06.2011

  • OpenGL . . .

    [1,1 M], 23.06.2011

  • 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

  • pnGL . , . .

    [261,3 K], 02.07.2011

  • OnGL , , . " " .

    [42,5 K], 26.06.2011

  • pnGL Windws . , .

    [747,0 K], 26.06.2011