Results 1 to 5 of 5

Thread: Updating array of vertex coordinates

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2004
    Posts
    4

    Updating array of vertex coordinates

    I have an array of vertex coordinates and I'm using it in conjunction with glVertexPointer to draw a 2d shape. What I'm trying to figure out is, after applying a transformation such as reposition or rotate, how to either 1) update that array to reflect the new coordinates of each vertex, or 2) somehow retrieve the coordinate info.

  2. #2
    Guest

    Re: Updating array of vertex coordinates

    When you say you apply a transformation, are you referring to an OpenGL transformation through glTranslate, glMultMatrixd, etc. or manually changing vertex positions?

    If you're talking about OpenGL transformations, you could use the feedback buffer, you could extract the modelview matrix and transform them yourself in software (...) or some other ways; what exactly is your goal?

    As for replacing the data, you should be able to just overwrite the vertex array in main memory (assuming you're not using any vertex array extensions that lock or upload the data) and reinitialize your vertex pointers.

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2004
    Posts
    4

    Re: Updating array of vertex coordinates

    Yes, I would be using the built-in transform functions like glTranslate, glRotate, and glScale. The reason I need to know the updated coords of the vertices is that I will be doing things based on user input, specifically mouse clicks on certain parts of the 2D shape, so it'd be useful to know where the vertices are located. So I guess I'll try looking into the glFeedbackBuffer. Thanks for the tip.

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    990

    Re: Updating array of vertex coordinates

    Originally posted by S4pphire:
    The reason I need to know the updated coords of the vertices is that I will be doing things based on user input, specifically mouse clicks on certain parts of the 2D shape, so it'd be useful to know where the vertices are located
    You could use gluUnproject for this, it converts window space coordinates back to 3D space coordinates.

    Greetz,

    Nico

  5. #5
    Guest

    Re: Updating array of vertex coordinates

    When I need to know world-space coordinates for everything I just use a spare matrix (for example, GL_MODELVIEW1_ARB if GL_ARB_vertex_blend is supported, or one of the program matrices if you have vertex/fragment programs) to which all modelling transformations are also applied as they are applied to the modelview matrix. For viewing transformations, i.e. gluLookAt or putting the camera somewhere, I just apply it to the modelview matrix. This way, the modelview matrix still correctly goes to eye coordinates from object space while the "modelling" matrix goes from object space to world space.

    Useful for getting relative positions of hierarchial stuff and proper vectors for other effects.

Similar Threads

  1. Vertex array skews texture coordinates???
    By xpnctoc1 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-19-2014, 06:56 PM
  2. Updating part of a uniform array
    By Etay Meiri in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-28-2011, 01:50 PM
  3. Environment Mapping, updating texture coordinates
    By mikau in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-06-2010, 06:02 AM
  4. updating window coordinates in real time
    By dvm in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-16-2004, 04:48 AM
  5. Coordinates, Vertex Array, glDrawElements,etc
    By IAstudent in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-30-2004, 04:49 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