Morph-SynRJ
view cmn_design.cxx @ 0:22de913c2d84
morph-synrj intro
| author | "Cedric Pinson <cedric.pinson@alcove.fr> <mornifle@plopbyte.net>" |
|---|---|
| date | Tue Nov 27 15:23:52 2007 +0100 (2007-11-27) |
| parents | |
| children |
line source
1 #include "sys_assert.h"
2 #include "mth_vector3.h"
3 #include "gl_header.h"
4 #include "cmn_intro.h"
5 #include "cmn_design.h"
8 void cmnDesignScroller_t::Init(GLuint _texture)
9 {
10 texture=_texture;
11 uvs[0]=uvs[1]=0;
12 scroll[0]=scroll[1]=1.0;
13 }
15 void cmnDesignScroller_t::Update()
16 {
17 double dt=Timer->GetFrameTime();
18 uvs[0]+=scroll[0]*dt;
19 uvs[1]+=scroll[1]*dt;
20 }
22 void cmnDesignScroller_t::Draw()
23 {
24 cmnPushMatrix();
26 cmnSetPlanarView();
28 txtBindTexture2d(texture,0);
29 glMatrixMode(GL_TEXTURE);
30 glTranslatef(uvs[0],uvs[1],0);
32 glBegin(GL_QUADS);
34 glTexCoord2f(0,0);
35 glVertex2f(0,0);
37 glTexCoord2f(0,1);
38 glVertex2f(0,RY);
40 glTexCoord2f(1,1);
41 glVertex2f(RX,RY);
43 glTexCoord2f(1,0);
44 glVertex2f(RX,0);
46 glEnd();
47 glLoadIdentity();
48 txtUnBindTexture2d(0);
49 cmnPopMatrix();
50 glMatrixMode(GL_MODELVIEW);
51 }
54 void cmnDesign_t::Update()
55 {
56 internalTime+=Timer->GetFrameTime();
57 for (int i=0;i<nbElements;i++)
58 if (!elements[i]->active) {
59 if (elements[i]->start<=internalTime)
60 elements[i]->active=true;
61 } else
62 elements[i]->Update();
63 }
66 void cmnDesign_t::Draw()
67 {
68 for (int i=0;i<nbElements;i++)
69 if (elements[i]->active)
70 elements[i]->Draw();
71 }
77 void cmnDesignElementTexturedQuad_t::Draw()
78 {
79 if (texture) {
80 glColor4f(color[0],color[1],color[2],alpha);
81 // glColor4f(1,1,1,1);
82 txtBindTexture2d(texture,0);
83 glBegin(GL_QUADS);
84 glTexCoord2f(0,0);
85 glVertex3f(position[0],position[1],position[2]);
86 glTexCoord2f(0,0.999);
87 glVertex3f(position[0],position[1]+sizey,position[2]);
88 glTexCoord2f(0.999,0.999);
89 glVertex3f(position[0]+sizex,position[1]+sizey,position[2]);
90 glTexCoord2f(0.999,0);
91 glVertex3f(position[0]+sizex,position[1],position[2]);
92 glEnd();
93 txtUnBindTexture2d(0);
94 } else {
95 SYS_ASSERT(0);
96 glBegin(GL_QUADS);
97 glVertex3f(position[0],position[1],position[2]);
98 glVertex3f(position[0],position[1]+sizey,position[2]);
99 glVertex3f(position[0]+sizex,position[1]+sizey,position[2]);
100 glVertex3f(position[0]+sizex,position[1],position[2]);
101 glEnd();
102 }
103 }
