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 9 of 9

Thread: GLSL version 1.4 or greater

  1. #1
    Junior Member Regular Contributor
    Join Date
    Sep 2008
    Posts
    130

    GLSL version 1.4 or greater

    Are there some tutorials about GLSL 1.4 ?
    I cant use gl_Vertex anylonger. Ok texturing works
    just with the command texture(....).

    What do I have to do in the vertex program and in the application to get this work ?

    Code :
    #version 140
    void main(void)
    {
    #version 140
    in vec4 TexCoord0;
    out vec2 TexCoord;
    uniform mat4 mvp;
     
    void main(void)
    {
      gl_Position = mvp * gl_Vertex;
      TexCoord = TexCoord0.st;
    }
    I always get an error using gl_vertex that it is depricated.
    How to handle this in GLSL 1.4 or greater version ?

    thanks & regards,
    lobbel

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

    Re: GLSL version 1.4 or greater

    Quote Originally Posted by lobbel
    Are there some tutorials about GLSL 1.4 ?
    I cant use gl_Vertex anylonger.
    Yeah, alot of the gl_ built-ins went away in GLSL 1.3.

    Change it to something else (like my_Vertex).

    Then in your code use a generic vertex attribute to populate it (e.g. glVertexAttribPointer).

    And then either query the program to find out which generic attribute index it put it on, or tell it which one to put it on via glBindAttribLocation.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Sep 2008
    Posts
    130

    Re: GLSL version 1.4 or greater

    Why it has been removed ? It was easy to use....
    complicates the things more.

    thank you,
    lobbel

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985

    Re: GLSL version 1.4 or greater

    Because it is related to fixed function OpenGL and as such had to be removed to provide a more general framework.

    Anyway, migration is not that difficult as it might look at first sight and on the way you'll see that its mean is to provide even more flexibility and less hard coded functionality.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

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

    Re: GLSL version 1.4 or greater

    Quote Originally Posted by lobbel
    Why it has been removed ? It was easy to use....
    complicates the things more.
    In this specific case, the code conversion impact isn't that great (unless you have batch setup calls spread all over your app rather than having a "drawable batch"-type class. Other things like deprecating gl_ModelViewMatrix, gl_ProjectionMatrix, etc. have bigger code impacts.

    Why did they kill most gl_* built-ins in GLSL 1.3? Well, back in the GL 3.0 days, the prevailing ARB view was that OpenGL would just obsolete the entire fixed-function pipeline. Didn't think much about legacy app port cost or newbie startup. The former turned out to be an obstacle. That's why the compatibility profile is there -- all this stuff still exists in it.

  6. #6
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,947

    Re: GLSL version 1.4 or greater

    It was removed because it is inefficient and it bloats the front end with arbitrary vertex and atribute issue order and density.

    Using vertex immediate mode dispatch in a modern app is ridiculous unless it's some rinky-dink test and/or you're display listing, and then you want to look at other mechanisms.

    The fact is hardware has moved on and and competent programmer should be able to package vertex data into attribute arrays, bind them and issue them with a single call. Further you should be indexing for vertex cache otherwise you're taking a significant hit. On top of this bad developers used to write war & peace per vertex compounding the problem. This way you have fewer methods to shoot yourself in the foot.

    You also have vram memory resident mechanisms to exploit and pulling data onto the call stack is just awful.

    Try it, you will get used to it VERY quickly.

    Remember that there are no preferred attribute slots and invoking attributes per vertex now. With the clean fully deprecated version of the API you're sending bound arrays to shader attribute registers. So the question of which attribute is the invoking one need not arise when you simply have an attribute per vertex bound.

    So, reasons glVertex() sucks:

    Calls per vertex are slow
    Sparse vertex attributes and arbitrary issue order convolutes the front end
    There is no mechanism to exploit vertex cache
    It defeats vram resident attribute mechanisms (VBOs) (display lists would be the old alternative)
    There is no need for an invoking attribute using MODERN shaders
    Bad/naive developers wrote a lot of crap between glBegin and glEnd
    This minor convenience only supplies opportunities to write very slow graphics code, even when used well

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

    Re: GLSL version 1.4 or greater

    Quote Originally Posted by dorbie
    So, reasons glVertex() sucks: ...
    He's not talking about glVertex(), but rather gl_Vertex (GLSL vertex attribute built-in).

    Which you can populate using glVertexPointer so which has nothing to do with immediate mode, supporting both client arrays and VBOs.

    Of course in "the new world order", use your own shader vertex attribute name, populate it using glVertexAttribPointer, and link them up using glBindAttribLocation.

  8. #8
    Junior Member Regular Contributor
    Join Date
    Sep 2008
    Posts
    130

    Re: GLSL version 1.4 or greater

    Ok,
    thanks for comments. I will have a look into the
    book opengl glsl and I found a tutorial that
    covers the changes made in version 1.40.

    regards,
    lobbel

  9. #9
    Junior Member Newbie
    Join Date
    Aug 2010
    Posts
    1

    Re: GLSL version 1.4 or greater

    Could you share the link to that tutorial?

Posting Permissions

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