Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Reinterpet bits cast float->int in GLSL

Hybrid View

  1. #1
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,213

    Reinterpet bits cast float->int in GLSL

    I want the GLSL equivalent of:

    Code glsl:
    float f;
    int   i = *(int *)&f;

    Any way to do this? Prefer std method but dirty hacks OK. Have wanted this before and now I want it again.

    Issue is texture buffers have one component type. I want to mix different types in one, ala interleaved VBOs.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    What you want are the floatBitsToInt and intBitsToFloat functions. There are unsigned versions too.

    Surprisingly, they're in 3.30.

  3. #3
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,213
    Perfect - thanks. Somehow I missed seeing that.

Posting Permissions

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