merge with trunk at r31523
[blender.git] / source / blender / gpu / intern / gpu_draw.c
index 4c477db627ea0d169f369aba5a0f205e7aa98663..3bf1880cf691bf93063e219786d3058c36ec6218 100644 (file)
@@ -525,7 +525,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int tfmode, int c
        }
 
        /* scale if not a power of two */
-       if (!mipmap && (!is_pow2_limit(rectw) || !is_pow2_limit(recth))) {
+       if ((!is_pow2_limit(rectw) || !is_pow2_limit(recth))) {
                rectw= smaller_pow2_limit(rectw);
                recth= smaller_pow2_limit(recth);
                
@@ -1228,7 +1228,7 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4
        Base *base;
        Lamp *la;
        int count;
-       float position[4], direction[4], energy[4];
+       float position[4], direction[4], energy[4], power;
        
        /* disable all lights */
        for(count=0; count<8; count++)
@@ -1269,8 +1269,8 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4
 
                        glLightfv(GL_LIGHT0+count, GL_POSITION, position); 
                        glLightf(GL_LIGHT0+count, GL_CONSTANT_ATTENUATION, 1.0);
-                       glLightf(GL_LIGHT0+count, GL_LINEAR_ATTENUATION, la->att1/la->dist);
-                       glLightf(GL_LIGHT0+count, GL_QUADRATIC_ATTENUATION, la->att2/(la->dist*la->dist));
+                       glLightf(GL_LIGHT0+count, GL_LINEAR_ATTENUATION, 0.0f/la->dist);
+                       glLightf(GL_LIGHT0+count, GL_QUADRATIC_ATTENUATION, 1.0f/(la->dist*la->dist));
                        
                        if(la->type==LA_SPOT) {
                                /* spot lamp */
@@ -1284,11 +1284,13 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4
                        else
                                glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, 180.0);
                }
+
+               power= (ELEM(la->type, LA_SUN, LA_HEMI))? la->energy*M_PI: la->energy*M_PI; //XXX la->power
                
                /* setup energy */
-               energy[0]= la->energy*la->r;
-               energy[1]= la->energy*la->g;
-               energy[2]= la->energy*la->b;
+               energy[0]= power*la->r;
+               energy[1]= power*la->g;
+               energy[2]= power*la->b;
                energy[3]= 1.0;
 
                glLightfv(GL_LIGHT0+count, GL_DIFFUSE, energy);