how to transform single vertices?

Hi,

I have a little problem: I don’t know how to transform single vertices!

I made this testfunction to get a good understanding of the transformation matrix and all the parameters:

int testfunc1 (GLfloat x, GLfloat y, GLfloat z)
{

GLfloat vRed= {1.0f, 0.0f, 0.0f, 1.0f};
glPointSize(3.0f);

M3DMatrix44f TestMatrix =
{1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.1f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.0f, 0.0f, 1.0f} ;

shaderManager.UseStockShader(GLT_SHADER_FLAT, TestMatrix, vRed);

glBegin(GL_POINTS);
glVertex3f(x,y,z);
glEnd();

return 0;
}

I added it to my RenderScene:

void RenderScene(void)
{

// Clear the window and the depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

   [b]//this point is translated too! But why? :([/b]

glBegin(GL_POINTS);
glVertex3f(0.0f, 0.0f, 0.0f);
glEnd();

testfunc1(0.2f, 0.0f,0.0f);

// Swap buffers, and immediately refresh
glutSwapBuffers();

}

The Problem is, that my testfunc1 also transforms all other points that are specified in my RenderScene function.

I hope you can hel me :slight_smile:

My guess is RenderScene is actually called at least twice in your program (I’m guessing GLUT?) and you never deactivate the shader, so on the second time through RenderScene the shader is still active and transforms your point.

Thank you very much! Actually I dont know how I deactivate it. So I used the same command but loading an identity Matrix and put it on the end of the transformed point.

Now just the right point is translated. yeah =)

Thanks a lot !

I don’t know the framework you are using for handling your shaders, but in pure OpenGL deactivating shaders is done by making the program with id 0 current: glUseProgram(0).
Depending on the framework it may not be a good idea to call that “behind its back” though, it may get confused about what state is active.

i am actually using superbible5 and the shader is in some next chapters. actually im just interested of the working of the transfoormation matrix