mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-13 23:43:34 +00:00
TinyGL: Do not underflow on specular light calculation
When casting from float to int, the value can underflow making the index negative which causes a segmentation fault when accessing the array. Fixes #320
This commit is contained in:
parent
d764b75f46
commit
a50201481d
@ -294,9 +294,11 @@ void gl_shade_vertex(GLContext *c, GLVertex *v) {
|
||||
// testing specular buffer code
|
||||
// dot_spec= pow(dot_spec,m->shininess)
|
||||
specbuf = specbuf_get_buffer(c, m->shininess_i, m->shininess);
|
||||
idx = (int)(dot_spec * SPECULAR_BUFFER_SIZE);
|
||||
if (idx > SPECULAR_BUFFER_SIZE)
|
||||
tmp = dot_spec * SPECULAR_BUFFER_SIZE;
|
||||
if (tmp > SPECULAR_BUFFER_SIZE)
|
||||
idx = SPECULAR_BUFFER_SIZE;
|
||||
else
|
||||
idx = (int)tmp;
|
||||
|
||||
dot_spec = specbuf->buf[idx];
|
||||
lR += dot_spec * l->specular.v[0] * m->specular.v[0];
|
||||
|
Loading…
x
Reference in New Issue
Block a user