PDA

View Full Version : how to move a vertex that exists in opengl context



noobscratcher
10-28-2011, 07:50 AM
Hello wonderfull people i was curious to know "how" i would be able to manipulate the position of a vertex that exists already in my opengl context using OpenGL

I've had a look around on OpenGL forum and googled around perhaps im missing something simple but this is what i thought i'm guessing i have to do

draw out all my vertexes then store them in a void like


void openglshape(void)
{

glBegin(GL_QUADS);

//Top Right
glTexCoord2f(1,1);
glVertex2f(100.0f,20.0f);
//Top Left
glTexCoord2f(0,1);
glVertex2f(0.0f,20.0f);
//Bottom Left
glTexCoord2f(0,0);
glVertex2f(0.0f,200.0f);
//Bottom Right
glTexCoord2f(1,0);
glVertex2f(100.0f,200.0f);
glEnd();
}

and then like GlTranslate??? :confused: not shore this is where i'm stuck.

noobscratcher
10-28-2011, 02:18 PM
:)

BionicBytes
10-29-2011, 06:21 AM
If you have a set of vertices and you want to reposition them then you can use glTranslatef to 'move' them relative to the camera.
What is actually happening is the glTranslatef is modifying the glModelView matrix so you'll need to push/ pop the current modelview matrix between draw calls of you need to preserve the camera.

noobscratcher
10-29-2011, 08:14 AM
oh that is so cool ! thanks for the tip