Commit acadf3f2 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Replace the light chain with a hashmap.

parent 5fce682f
......@@ -1987,7 +1987,7 @@ static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
* NOTE2: Apparently texture transforms do NOT need reapplying
*/
PLIGHTINFOEL *lightChain = NULL;
PLIGHTINFOEL *light = NULL;
glMatrixMode(GL_MODELVIEW);
checkGLcall("glMatrixMode(GL_MODELVIEW)");
......@@ -1995,13 +1995,13 @@ static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
checkGLcall("glLoadMatrixf(...)");
/* Reset lights. TODO: Call light apply func */
lightChain = stateblock->lights;
while (lightChain && lightChain->glIndex != -1) {
glLightfv(GL_LIGHT0 + lightChain->glIndex, GL_POSITION, lightChain->lightPosn);
for(k = 0; k < stateblock->wineD3DDevice->maxConcurrentLights; k++) {
light = stateblock->activeLights[k];
if(!light) continue;
glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, light->lightPosn);
checkGLcall("glLightfv posn");
glLightfv(GL_LIGHT0 + lightChain->glIndex, GL_SPOT_DIRECTION, lightChain->lightDirn);
glLightfv(GL_LIGHT0 + light->glIndex, GL_SPOT_DIRECTION, light->lightDirn);
checkGLcall("glLightfv dirn");
lightChain = lightChain->next;
}
/* Reset Clipping Planes if clipping is enabled. TODO: Call clipplane apply func */
......
......@@ -517,7 +517,6 @@ struct PLIGHTINFOEL {
WINED3DLIGHT OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
DWORD OriginalIndex;
LONG glIndex;
BOOL lightEnabled;
BOOL changed;
BOOL enabledChanged;
......@@ -527,8 +526,7 @@ struct PLIGHTINFOEL {
float exponent;
float cutoff;
PLIGHTINFOEL *next;
PLIGHTINFOEL *prev;
struct list entry;
};
/* The default light parameters */
......@@ -1204,8 +1202,11 @@ struct IWineD3DStateBlockImpl
/* Transform */
WINED3DMATRIX transforms[HIGHEST_TRANSFORMSTATE + 1];
/* Lights */
PLIGHTINFOEL *lights; /* NOTE: active GL lights must be front of the chain */
/* Light hashmap . Collisions are handled using standard wine double linked lists */
#define LIGHTMAP_SIZE 43 /* Use of a prime number recommended. Set to 1 for a linked list! */
#define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE) /* Primitive and simple function */
struct list lightMap[LIGHTMAP_SIZE]; /* Mashmap containing the lights */
PLIGHTINFOEL *activeLights[MAX_ACTIVE_LIGHTS]; /* Map of opengl lights to d3d lights */
/* Clipping */
double clipplane[MAX_CLIPPLANES][4];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment