Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02233490 authored by Nick Desaulniers's avatar Nick Desaulniers
Browse files

[frameworks][native][opengl] fix -Wimplicit-int-float-conversion



IEEE754 single precision cannot precisely represent RAND_MAX.

error: implicit conversion from 'int' to 'float' changes value from
2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion]

For purposes of generating random uniforms, this does not matter. Add
explicit casts of RAND_MAX to float to fix.

Bug: 139945549
Test: mm
Change-Id: I3a609b9bbe2e62eeacf5a6853ba625a512e5bcba
Signed-off-by: default avatarNick Desaulniers <ndesaulniers@google.com>
parent 373c5df1
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -191,10 +191,10 @@ static void setupVA() {
static void randUniform(int pgm, const char *var) {
    GLint loc = glGetUniformLocation(pgm, var);
    if (loc >= 0) {
        float x = ((float)rand()) / RAND_MAX;
        float y = ((float)rand()) / RAND_MAX;
        float z = ((float)rand()) / RAND_MAX;
        float w = ((float)rand()) / RAND_MAX;
        float x = ((float)rand()) / (float)RAND_MAX;
        float y = ((float)rand()) / (float)RAND_MAX;
        float z = ((float)rand()) / (float)RAND_MAX;
        float w = ((float)rand()) / (float)RAND_MAX;
        glUniform4f(loc, x, y, z, w);
    }
}