Merged 15170:15635 from trunk (no conflicts or even merges)
[blender.git] / source / gameengine / GamePlayer / common / GPC_RenderTools.cpp
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21  * All rights reserved.
22  *
23  * The Original Code is: all of this file.
24  *
25  * Contributor(s): none yet.
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29
30 #include <assert.h>
31
32 #ifdef WIN32
33 #pragma warning (disable : 4786)
34 #include <windows.h>
35 #endif 
36
37 #include "GL/glew.h"
38
39 #include <iostream>
40
41 #include "GPC_RenderTools.h"
42
43 #include "RAS_IRenderTools.h"
44 #include "RAS_IRasterizer.h"
45 #include "RAS_LightObject.h"
46 #include "RAS_ICanvas.h"
47 #include "RAS_GLExtensionManager.h"
48
49 // next two includes/dependencies come from the shadow feature
50 // it needs the gameobject and the sumo physics scene for a raycast
51 #include "KX_GameObject.h"
52
53 #include "GPC_PolygonMaterial.h"
54 #include "KX_PolygonMaterial.h"
55 #include "Value.h"
56
57 //#include "KX_BlenderGL.h" // for text printing
58 //#include "KX_BlenderClientObject.h"
59 #include "STR_String.h"
60 #include "RAS_BucketManager.h" // for polymaterial (needed for textprinting)
61
62
63 // Blender includes
64 /* This list includes only data type definitions */
65 #include "DNA_object_types.h"
66 #include "DNA_material_types.h"
67 #include "DNA_image_types.h"
68 #include "DNA_lamp_types.h"
69 #include "DNA_group_types.h"
70 #include "DNA_scene_types.h"
71 #include "DNA_camera_types.h"
72 #include "DNA_property_types.h"
73 #include "DNA_text_types.h"
74 #include "DNA_sensor_types.h"
75 #include "DNA_controller_types.h"
76 #include "DNA_actuator_types.h"
77 #include "DNA_mesh_types.h"
78 #include "DNA_meshdata_types.h"
79 #include "DNA_view3d_types.h"
80 #include "DNA_world_types.h"
81
82 #include "BKE_global.h"
83 #include "BKE_image.h"
84 #include "BKE_bmfont.h"
85 #include "BKE_bmfont_types.h"
86 #include "BKE_main.h"
87
88 #include "IMB_imbuf_types.h"
89 // End of Blender includes
90
91 #include "KX_Scene.h"
92 #include "KX_RayCast.h"
93 #include "KX_IPhysicsController.h"
94 #include "PHY_IPhysicsEnvironment.h"
95 #include "KX_BlenderMaterial.h"
96
97 GPC_RenderTools::GPC_RenderTools()
98 {
99         m_font = BMF_GetFont(BMF_kHelvetica10);
100         glGetIntegerv(GL_MAX_LIGHTS, (GLint*) &m_numgllights);
101         if (m_numgllights < 8)
102                 m_numgllights = 8;
103 }
104
105
106 GPC_RenderTools::~GPC_RenderTools()
107 {
108 }
109
110
111 void GPC_RenderTools::EndFrame(RAS_IRasterizer* rasty)
112 {
113 }
114
115
116 void GPC_RenderTools::BeginFrame(RAS_IRasterizer* rasty)
117 {
118         m_clientobject=NULL;
119         m_modified=true;
120         DisableOpenGLLights();
121
122 }
123
124 int GPC_RenderTools::ProcessLighting(int layer)
125 {
126         int result = false;
127
128         if (layer < 0)
129         {
130                 DisableOpenGLLights();
131                 result = false;
132         } else
133         {
134                 if (m_clientobject)
135                 {       
136                         if (applyLights(layer))
137                         {
138                                 EnableOpenGLLights();
139                                 result = true;
140                         } else
141                         {
142                                 DisableOpenGLLights();
143                                 result = false;
144                         }
145                 }
146         }
147         return result;
148 }
149
150 void GPC_RenderTools::EnableOpenGLLights()
151 {
152         glEnable(GL_LIGHTING);
153         glEnable(GL_COLOR_MATERIAL);
154         glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE);
155         if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2)
156                 glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
157 }
158
159 void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode, 
160                                                                    const char* text, 
161                                                                    int xco, 
162                                                                    int yco, 
163                                                                    int width, 
164                                                                    int height)
165 {
166         STR_String tmpstr(text);
167         int lines;
168         char* s = tmpstr.Ptr();
169         char* p;
170         
171
172         // Save and change OpenGL settings
173         int texture2D;
174         glGetIntegerv(GL_TEXTURE_2D, (GLint*)&texture2D);
175         glDisable(GL_TEXTURE_2D);
176         int fog;
177         glGetIntegerv(GL_FOG, (GLint*)&fog);
178         glDisable(GL_FOG);
179         
180         int light;
181         glGetIntegerv(GL_LIGHTING, (GLint*)&light);
182         glDisable(GL_LIGHTING);
183
184         
185         // Set up viewing settings
186         glMatrixMode(GL_PROJECTION);
187         glPushMatrix();
188         glLoadIdentity();
189         glOrtho(0, width, 0, height, -1, 1);
190         glMatrixMode(GL_MODELVIEW);
191         glPushMatrix();
192         glLoadIdentity();
193         
194         // Actual drawing
195         unsigned char colors[2][3] = {
196                 {0x00, 0x00, 0x00},
197                 {0xFF, 0xFF, 0xFF}
198         };
199         int numTimes = mode == RAS_TEXT_PADDED ? 2 : 1;
200         for (int i = 0; i < numTimes; i++) {
201                 glColor3ub(colors[i][0], colors[i][1], colors[i][2]);
202                 glRasterPos2i(xco, yco);
203                 for (p = s, lines = 0; *p; p++) {
204                         if (*p == '\n')
205                         {
206                                 lines++;
207                                 glRasterPos2i(xco, yco-(lines*18));
208                         }
209                         BMF_DrawCharacter(m_font, *p);
210                 }
211                 xco += 1;
212                 yco += 1;
213         }
214
215         // Restore view settings
216         glMatrixMode(GL_PROJECTION);
217         glPopMatrix();
218         glMatrixMode(GL_MODELVIEW);
219         glPopMatrix();
220
221         // Restore OpenGL Settings
222         if (fog)
223                 glEnable(GL_FOG);
224         else
225                 glDisable(GL_FOG);
226         
227         if (texture2D)
228                 glEnable(GL_TEXTURE_2D);
229         else
230                 glDisable(GL_TEXTURE_2D);
231         if (light)
232                 glEnable(GL_LIGHTING);
233         else
234                 glDisable(GL_LIGHTING);
235 }
236
237 /**
238  * Copied from KX_BlenderRenderTools.cpp in KX_blenderhook
239  * Renders text into a (series of) polygon(s), using a texture font,
240  * Each character consists of one polygon (one quad or two triangles)
241  */
242 void GPC_RenderTools::RenderText(
243         int mode,
244         RAS_IPolyMaterial* polymat,
245         float v1[3], float v2[3], float v3[3], float v4[3])
246 {
247         STR_String mytext = ((CValue*)m_clientobject)->GetPropertyText("Text");
248         
249         const unsigned int flag = polymat->GetFlag();
250         struct MTFace* tface = 0;
251         unsigned int* col = 0;
252
253         if(flag & RAS_BLENDERMAT) {
254                 KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(polymat);
255                 tface = bl_mat->GetMTFace();
256                 col = bl_mat->GetMCol();
257         } else {
258                 KX_PolygonMaterial* blenderpoly = static_cast<KX_PolygonMaterial*>(polymat);
259                 tface = blenderpoly->GetMTFace();
260                 col = blenderpoly->GetMCol();
261         }
262                 
263         BL_RenderText(mode, mytext, mytext.Length(), tface, col, v1, v2, v3, v4);
264 }
265
266
267
268 /**
269  * Copied from KX_BlenderGL.cpp in KX_blenderhook
270  */
271 void GPC_RenderTools::BL_RenderText(
272         int mode,
273         const char* textstr,
274         int textlen,
275         struct MTFace* tface,
276         unsigned int* col,
277         float v1[3],float v2[3],float v3[3],float v4[3])
278 {
279         struct Image* ima;
280
281         if (mode & TF_BMFONT) {
282                         //char string[MAX_PROPSTRING];
283 //                      float tmat[4][4];
284                         int characters, index, character;
285                         float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance;
286                         
287 //                      bProperty *prop;
288
289                         // string = "Frank van Beek";
290
291                         characters = textlen;
292
293                         ima = (struct Image*) tface->tpage;
294                         if (ima == NULL) {
295                                 characters = 0;
296                         }
297
298                         if(!col) glColor3f(1.0f, 1.0f, 1.0f);
299
300                         glPushMatrix();
301                         for (index = 0; index < characters; index++) {
302                                 // lets calculate offset stuff
303                                 character = textstr[index];
304                                 
305                                 // space starts at offset 1
306                                 // character = character - ' ' + 1;
307                                 
308                                 matrixGlyph((ImBuf *)ima->ibufs.first, character, & centerx, &centery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
309                                 
310                                 glBegin(GL_POLYGON);
311                                 // printf(" %c %f %f %f %f\n", character, tface->uv[0][0], tface->uv[0][1], );
312                                 // glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy);
313                                 glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy);
314
315                                 if(col) BL_spack(col[0]);
316                                 // glVertex3fv(v1);
317                                 glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]);
318                                 
319                                 glTexCoord2f((tface->uv[1][0] - centerx) * sizex + transx, (tface->uv[1][1] - centery) * sizey + transy);
320                                 if(col) BL_spack(col[1]);
321                                 // glVertex3fv(v2);
322                                 glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]);
323         
324                                 glTexCoord2f((tface->uv[2][0] - centerx) * sizex + transx, (tface->uv[2][1] - centery) * sizey + transy);
325                                 if(col) BL_spack(col[2]);
326                                 // glVertex3fv(v3);
327                                 glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]);
328         
329                                 if(v4) {
330                                         // glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, 1.0 - (1.0 - tface->uv[3][1]) * sizey - transy);
331                                         glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, (tface->uv[3][1] - centery) * sizey + transy);
332                                         if(col) BL_spack(col[3]);
333                                         // glVertex3fv(v4);
334                                         glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]);
335                                 }
336                                 glEnd();
337
338                                 glTranslatef(advance, 0.0, 0.0);
339                         }
340                         glPopMatrix();
341
342                 }
343 }
344
345
346 RAS_IPolyMaterial* GPC_RenderTools::CreateBlenderPolyMaterial(
347                         const STR_String &texname,
348                         bool ba,const STR_String& matname,int tile,int tilexrep,int tileyrep,int mode,bool transparant, bool zsort,
349                         int lightlayer,bool bIsTriangle,void* clientobject,void* tface)
350 {
351         assert(!"Deprecated");
352 /*      return new GPC_PolygonMaterial(texname, ba,matname,tile,tilexrep,tileyrep,
353                         mode,transparant,zsort,lightlayer,bIsTriangle,clientobject,tface);
354                         */
355         return NULL;
356 }
357
358
359 int GPC_RenderTools::applyLights(int objectlayer)
360 {
361 // taken from blender source, incompatibility between Blender Object / GameObject       
362
363         int count;
364         float vec[4];
365         
366         vec[3]= 1.0;
367         
368         for(count=0; count<m_numgllights; count++)
369                 glDisable((GLenum)(GL_LIGHT0+count));
370         
371         //std::vector<struct    RAS_LightObject*> m_lights;
372         std::vector<struct      RAS_LightObject*>::iterator lit = m_lights.begin();
373
374         
375         for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit)
376         {
377                 RAS_LightObject* lightdata = (*lit);
378                 if (lightdata->m_layer & objectlayer)
379                 {
380
381                         glPushMatrix();
382                         glLoadMatrixf(m_viewmat);
383                         
384                         
385                         vec[0] = (*(lightdata->m_worldmatrix))(0,3);
386                         vec[1] = (*(lightdata->m_worldmatrix))(1,3);
387                         vec[2] = (*(lightdata->m_worldmatrix))(2,3);
388                         vec[3] = 1;
389
390
391                         if(lightdata->m_type==RAS_LightObject::LIGHT_SUN) {
392                                 
393                                 vec[0] = (*(lightdata->m_worldmatrix))(0,2);
394                                 vec[1] = (*(lightdata->m_worldmatrix))(1,2);
395                                 vec[2] = (*(lightdata->m_worldmatrix))(2,2);
396                                 //vec[0]= base->object->obmat[2][0];
397                                 //vec[1]= base->object->obmat[2][1];
398                                 //vec[2]= base->object->obmat[2][2];
399                                 vec[3]= 0.0;
400                                 glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); 
401                         }
402                         else {
403                                 //vec[3]= 1.0;
404                                 glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); 
405                                 glLightf((GLenum)(GL_LIGHT0+count), GL_CONSTANT_ATTENUATION, 1.0);
406                                 glLightf((GLenum)(GL_LIGHT0+count), GL_LINEAR_ATTENUATION, lightdata->m_att1/lightdata->m_distance);
407                                 // without this next line it looks backward compatible.
408                                 //attennuation still is acceptable 
409                                 glLightf((GLenum)(GL_LIGHT0+count), GL_QUADRATIC_ATTENUATION, lightdata->m_att2/(lightdata->m_distance*lightdata->m_distance)); 
410                                 
411                                 if(lightdata->m_type==RAS_LightObject::LIGHT_SPOT) {
412                                         vec[0] = -(*(lightdata->m_worldmatrix))(0,2);
413                                         vec[1] = -(*(lightdata->m_worldmatrix))(1,2);
414                                         vec[2] = -(*(lightdata->m_worldmatrix))(2,2);
415                                         //vec[0]= -base->object->obmat[2][0];
416                                         //vec[1]= -base->object->obmat[2][1];
417                                         //vec[2]= -base->object->obmat[2][2];
418                                         glLightfv((GLenum)(GL_LIGHT0+count), GL_SPOT_DIRECTION, vec);
419                                         glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, lightdata->m_spotsize/2.0);
420                                         glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_EXPONENT, 128.0*lightdata->m_spotblend);
421                                 }
422                                 else glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, 180.0);
423                         }
424                         
425                         if (lightdata->m_nodiffuse)
426                         {
427                                 vec[0] = vec[1] = vec[2] = vec[3] = 0.0;
428                         } else {
429                                 vec[0]= lightdata->m_energy*lightdata->m_red;
430                                 vec[1]= lightdata->m_energy*lightdata->m_green;
431                                 vec[2]= lightdata->m_energy*lightdata->m_blue;
432                                 vec[3]= 1.0;
433                         }
434                         glLightfv((GLenum)(GL_LIGHT0+count), GL_DIFFUSE, vec);
435                         if (lightdata->m_nospecular)
436                         {
437                                 vec[0] = vec[1] = vec[2] = vec[3] = 0.0;
438                         } else if (lightdata->m_nodiffuse) {
439                                 vec[0]= lightdata->m_energy*lightdata->m_red;
440                                 vec[1]= lightdata->m_energy*lightdata->m_green;
441                                 vec[2]= lightdata->m_energy*lightdata->m_blue;
442                                 vec[3]= 1.0;
443                         }
444                         glLightfv((GLenum)(GL_LIGHT0+count), GL_SPECULAR, vec);
445                         glEnable((GLenum)(GL_LIGHT0+count));
446                         
447                         count++;
448
449                         glPopMatrix();
450                 }
451         }
452
453         return count;
454
455 }
456
457 void GPC_RenderTools::SetClientObject(void* obj)
458 {
459         if (m_clientobject != obj)
460         {
461                 if (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling())
462                 {
463                         glFrontFace(GL_CCW);
464                 } else 
465                 {
466                         glFrontFace(GL_CW);
467                 }
468                 m_clientobject = obj;
469                 m_modified = true;
470         }
471 }
472
473 bool GPC_RenderTools::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data)
474 {
475         double* const oglmatrix = (double* const) data;
476         MT_Point3 resultpoint(hit_point);
477         MT_Vector3 resultnormal(hit_normal);
478         MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
479         MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized();
480         left = (dir.cross(resultnormal)).safe_normalized();
481         // for the up vector, we take the 'resultnormal' returned by the physics
482         
483         double maat[16]={
484                         left[0],        left[1],        left[2], 0,
485                                 dir[0],         dir[1],         dir[2], 0,
486                 resultnormal[0],resultnormal[1],resultnormal[2], 0,
487                                 0,              0,              0, 1};
488         glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]);
489         //glMultMatrixd(oglmatrix);
490         glMultMatrixd(maat);
491         return true;
492 }
493
494 void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode )
495 {
496         if (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED ||
497                 objectdrawmode & RAS_IPolyMaterial::BILLBOARD_AXISALIGNED)
498         {
499                 // rotate the billboard/halo
500                 //page 360/361 3D Game Engine Design, David Eberly for a discussion
501                 // on screen aligned and axis aligned billboards
502                 // assumed is that the preprocessor transformed all billboard polygons
503                 // so that their normal points into the positive x direction (1.0 , 0.0 , 0.0)
504                 // when new parenting for objects is done, this rotation
505                 // will be moved into the object
506                 
507                 MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]);
508                 MT_Point3 campos = rasty->GetCameraPosition();
509                 MT_Vector3 dir = (campos - objpos).safe_normalized();
510                 MT_Vector3 up(0,0,1.0);
511
512                 KX_GameObject* gameobj = (KX_GameObject*) this->m_clientobject;
513                 // get scaling of halo object
514                 MT_Vector3  size = gameobj->GetSGNode()->GetLocalScale();
515                 
516                 bool screenaligned = (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED)!=0;//false; //either screen or axisaligned
517                 if (screenaligned)
518                 {
519                         up = (up - up.dot(dir) * dir).safe_normalized();
520                 } else
521                 {
522                         dir = (dir - up.dot(dir)*up).safe_normalized();
523                 }
524                 
525                 MT_Vector3 left  = dir.normalized();
526                 dir = (left.cross(up)).normalized();
527
528                 // we have calculated the row vectors, now we keep
529                 // local scaling into account:
530
531                 left *= size[0];
532                 dir  *= size[1];
533                 up   *= size[2];
534                 double maat[16]={
535                         left[0], left[1],left[2], 0,
536                                 dir[0], dir[1],dir[2],0,
537                                 up[0],up[1],up[2],0,
538                                 0,0,0,1};
539                         glTranslated(objpos[0],objpos[1],objpos[2]);
540                         glMultMatrixd(maat);
541                         
542         } else
543         {
544                 if (objectdrawmode & RAS_IPolyMaterial::SHADOW)
545                 {
546                         // shadow must be cast to the ground, physics system needed here!
547                         MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
548                         KX_GameObject *gameobj = (KX_GameObject*) this->m_clientobject;
549                         MT_Vector3 direction = MT_Vector3(0,0,-1);
550
551                         direction.normalize();
552                         direction *= 100000;
553
554                         MT_Point3 topoint = frompoint + direction;
555
556                         KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo;
557                         PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment();
558                         KX_IPhysicsController* physics_controller = gameobj->GetPhysicsController();
559                         
560                         KX_GameObject *parent = gameobj->GetParent();
561                         if (!physics_controller && parent)
562                                 physics_controller = parent->GetPhysicsController();
563                         if (parent)
564                                 parent->Release();
565                                 
566                         MT_Point3 resultpoint;
567                         MT_Vector3 resultnormal;
568                         if (!KX_RayCast::RayTest(physics_controller, physics_environment, frompoint, topoint, resultpoint, resultnormal, KX_RayCast::Callback<GPC_RenderTools>(this, oglmatrix)))
569                         {
570                                 // couldn't find something to cast the shadow on...
571                                 glMultMatrixd(oglmatrix);
572                         }
573                 } else
574                 {
575
576                         // 'normal' object
577                         glMultMatrixd(oglmatrix);
578                 }
579         }
580 }
581
582 void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer)
583 {
584         int state = rasterizer->GetMotionBlurState();
585         float motionblurvalue;
586         if(state)
587         {
588                 motionblurvalue = rasterizer->GetMotionBlurValue();
589                 if(state==1)
590                 {
591                         //bugfix:load color buffer into accum buffer for the first time(state=1)
592                         glAccum(GL_LOAD, 1.0);
593                         rasterizer->SetMotionBlurState(2);
594                 }
595                 else if(motionblurvalue>=0.0 && motionblurvalue<=1.0)
596                 {
597                         glAccum(GL_MULT, motionblurvalue);
598                         glAccum(GL_ACCUM, 1-motionblurvalue);
599                         glAccum(GL_RETURN, 1.0);
600                         glFlush();
601                 }
602         }
603 }
604
605 void GPC_RenderTools::Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)
606 {
607         m_filtermanager.EnableFilter(propNames, gameObj, filtermode, pass, text);
608 }
609
610 void GPC_RenderTools::Render2DFilters(RAS_ICanvas* canvas)
611 {
612         m_filtermanager.RenderFilters( canvas);
613 }
614
615 unsigned int GPC_RenderTools::m_numgllights;