… | |
… | |
144 | } |
144 | } |
145 | |
145 | |
146 | template<GLenum type> |
146 | template<GLenum type> |
147 | void entity_opengl2d<type>::draw (draw_context &ctx) |
147 | void entity_opengl2d<type>::draw (draw_context &ctx) |
148 | { |
148 | { |
149 | glBegin (type); |
149 | if (!list) |
|
|
150 | { |
|
|
151 | list = glGenLists (1); |
|
|
152 | glNewList (list, GL_COMPILE); |
150 | |
153 | |
151 | if (ctx.mode == draw_context::LIGHTED) |
154 | glBegin (type); |
152 | { |
155 | |
153 | glMaterialfv (GL_FRONT, GL_DIFFUSE, (GLfloat *)&m.diffuse); |
156 | glMaterialfv (GL_FRONT, GL_DIFFUSE, (GLfloat *)&m.diffuse); |
154 | glMaterialfv (GL_FRONT, GL_SPECULAR, (GLfloat *)&m.specular); |
157 | glMaterialfv (GL_FRONT, GL_SPECULAR, (GLfloat *)&m.specular); |
155 | glMaterialfv (GL_FRONT, GL_EMISSION, (GLfloat *)&m.emission); |
158 | glMaterialfv (GL_FRONT, GL_EMISSION, (GLfloat *)&m.emission); |
156 | glMaterialf (GL_FRONT, GL_SHININESS, m.shininess); |
159 | glMaterialf (GL_FRONT, GL_SHININESS, m.shininess); |
157 | } |
160 | |
158 | |
|
|
159 | for (iterator i = begin (); i < end (); ++i) |
161 | for (iterator i = begin (); i < end (); ++i) |
160 | { |
|
|
161 | if (ctx.mode == draw_context::LIGHTED) |
|
|
162 | { |
162 | { |
163 | glTexCoord2fv ((GLfloat *)&i->t); |
163 | glTexCoord2fv ((GLfloat *)&i->t); |
164 | glNormal3fv ((GLfloat *)&i->n); |
164 | glNormal3fv ((GLfloat *)&i->n); |
|
|
165 | glVertex3fv ((GLfloat *)&i->p); |
165 | } |
166 | } |
166 | |
167 | |
167 | glVertex3fv ((GLfloat *)&i->p); |
168 | glEnd (); |
|
|
169 | glEndList (); |
168 | } |
170 | } |
169 | |
171 | |
170 | glEnd (); |
172 | glCallList (list); |
171 | } |
173 | } |
172 | |
174 | |
173 | template<GLenum type> |
175 | template<GLenum type> |
174 | void entity_opengl1d<type>::show (const sector &sec) |
176 | void entity_opengl1d<type>::show (const sector &sec) |
175 | { |
177 | { |