Results 1 to 3 of 3

Thread: How to link with input vertex data?

  1. #1
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296

    Question How to link with input vertex data?

    This is a simple vertex shader,
    in vec3 VertexPosition;
    in vec3 VertexColor;
    out vec3 Color;

    void main()
    {
    Color =VertexColor;
    gl_Position = vec4(VertexPosition,1.0);
    }

    Where is VertexPosition? from .cpp, we have positionData array, How to find the pointer VertexPositoin points to the data?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,112
    Quote Originally Posted by reader1 View Post
    Where is VertexPosition? from .cpp, we have positionData array, How to find the pointer VertexPositoin points to the data?
    You can use glGetAttribLocation() after the program is linked to obtain the index for an attribute, or glBindAttribLocation() before the program is linked to set it to a specific value. Or you can use a layout(location=...) specifier in the variable's declaration to assign a specific index.

    Arrays of data are associated with an attribute index using glVertexAttribPointer().

  3. #3
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    Quote Originally Posted by GClements View Post
    You can use glGetAttribLocation() after the program is linked to obtain the index for an attribute, or glBindAttribLocation() before the program is linked to set it to a specific value. Or you can use a layout(location=...) specifier in the variable's declaration to assign a specific index.

    Arrays of data are associated with an attribute index using glVertexAttribPointer().
    Thank you very much for the porompt reply. I find an article about this issue, which is as same as your descriptoin

Similar Threads

  1. how to bind two vertex buffers to vertex shader input, as in DirectX
    By saman_artorious in forum OpenGL: Basic Coding
    Replies: 14
    Last Post: 07-01-2013, 10:35 PM
  2. Indirection from <triangles>-input to vertex data
    By msteinberg in forum COLLADA
    Replies: 1
    Last Post: 12-20-2007, 03:22 PM
  3. Replies: 0
    Last Post: 12-04-2003, 03:15 AM
  4. Vertex Program pulling AGP data (other than vertex data)
    By Cyranose in forum OpenGL: General
    Replies: 1
    Last Post: 05-01-2003, 08:16 PM
  5. How to input a disk data file with mouse
    By shutian in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-14-2000, 01:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean