Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Syntax validator says it's ok

  1. #1
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,256

    Syntax validator says it's ok

    That's legal?

    vec4 myvalue = vec4(1, 1, 1, 1);
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    Re: Syntax validator says it's ok

    passes with flying colors, but spec says it shouldn't, least from what i can see.

    p.s. that's a bit harsh, isn't it?

  3. #3
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,407

    Re: Syntax validator says it's ok

    perhaps theyve decided to relaxe the syntax, good on them.

  4. #4
    Intern Newbie
    Join Date
    Oct 2004
    Posts
    38

    Re: Syntax validator says it's ok

    No, I don't think that's legal, it should be:
    vec4 myvalue = vec4(1.0, 1.0, 1.0, 1.0);
    My guess is that it only compiles if you are on nvidia based hardware since they don't seem to care much about the specs and go on their own way.

  5. #5
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,256

    Re: Syntax validator says it's ok

    Baggio,
    I'm talking about 3D Labs Syntax validator
    http://developer.3dlabs.com/download...date/index.htm

    I had v1.7 and now I just updated to 1.9 and tested again, and the code passed.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    Re: Syntax validator says it's ok

    it seems to be the vec* and mat* constructors only.

    float x = 1;

    will fail (but slips quietly by on my nvidia board :-)).

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    Re: Syntax validator says it's ok

    isn't there a way to get the compiler to just generate a warning on implicit conversions, perhaps with a pragma? you could even have a "treat warnings as errors" pragma (extension).

    it would be nice to have consistency, one way or the other :-)

    edit: my bad, the nvidia compiler does in fact generate warnings for implicit conversions. that's all you need :-)

  8. #8
    Junior Member Regular Contributor
    Join Date
    May 2001
    Posts
    200

    Re: Syntax validator says it's ok

    looks fine to me When using constructors the conversion rules are explicit (float -> int, bool -> float etc..) When using array constructors same rules apply as scalar.

    from GLSLangSpec.Full.1.10.59.pdf section 5.4

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    Re: Syntax validator says it's ok

    pocketmoon is right!

    in section 5 it says any lexically correct parameter list is ok, while in section 4 it says that no implicit conversions are allowed (sigh).

    hmmm... then it goes on to say that parameters must be of the correct size and type. pocketmoon, i don't see where there's an "explicit" conversion (maybe i missed it). can you quote that bit? (nevermind, i see it, 5.4.2, third paragraph). this strikes me as inconsistent with the spirit of implicit conversions, to allow them in constructors, but nowhere else.

    there's still the matter of consistency among compilers :-)

  10. #10
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,102

    Re: Syntax validator says it's ok

    There is no implicit conversion.

    Just like
    float x = float(1);
    is an explicit conversion from int to float...

    vec4 x = vec4(1,1,1,1);
    is an explicit conversion from four ints to a vec4.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •