Results 1 to 4 of 4

Thread: manipulating one coordinate of vertices

  1. #1
    Newbie Newbie
    Join Date
    Jul 2015
    Posts
    2

    manipulating one coordinate of vertices

    I am learning OpenGL 2.0 from wikibooks: https://en.wikibooks.org/wiki/OpenGL_Programming

    I am animating a 2D plot. The x-coordinates of all the vertices are set once. I have the y-coordinates stored in a std::vector. Redrawing every few hundred frames.
    Would it be possible to update only the y-coordinate information in the vertex shader? The number of y-coordinates (size of vector) is a variable.
    Another option is passing both the x and y coordinates, but keeping them in separate structures.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,103
    Quote Originally Posted by paccuu View Post
    Would it be possible to update only the y-coordinate information in the vertex shader?
    Yes. The vertex shader needs to set gl_Position for each vertex, but can do so however you wish. So you can have separate 1-component attributes for the X and Y coordinates.

    If the X coordinates are equally spaced, there's no need to supply the individual values. You can just supply the offset and spacing via uniforms and derive the values from gl_VertexID.

  3. #3
    Newbie Newbie
    Join Date
    Jul 2015
    Posts
    2
    Thank you. What would the types of these attributes be? The most natural type for me would be vec1, but i can't see such a thing.

  4. #4
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,674
    The type would be `float`.

Similar Threads

  1. Manipulating RGB for mesh vertices
    By Arnab in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 09-02-2008, 05:38 AM
  2. Manipulating memory buffers.
    By amit aides in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-30-2005, 02:03 PM
  3. Displaying and manipulating -
    By JimmyFo in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 09-28-2004, 06:18 AM
  4. Manipulating Objects
    By Ken in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 12-03-2000, 10:40 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