View Full Version : how to custom implement gltranslate
09-29-2008, 11:33 AM
I want to implement opengl translate function
static void mytranslate(float x,float y,float z)
Ive implemented this using gmtl and in visual studio.
Im getting the following errors
error C3861: 'mytranslate': identifier not found
error C2365: 'mytranslate' : redefinition; previous definition was 'formerly unknown identifier'
please help me why im getting these errors??
If you want any more details i will give it.
09-29-2008, 11:51 AM
Do you use mytranslate function in another file. I am very not sure about this one, but using the qualifier static for a function tell the compiler that function will only be used in the file where it is declared.
If this information is false don't blame me, I am still learning.
Remove the static qualifier, verify if include file are correct, clear the project (this remove compiled object file) and recompile all your file.
09-29-2008, 11:55 AM
Hi,Thank you for the reply.Im not using any header files other than standard ones and inorder to use the function i simply used
translate(2,0,0);Does this work???I removed static qualifier but gettin the same error.
09-29-2008, 12:06 PM
Ok, insert the prototype of your function just after all your include file and before the main function.
#include <stdio.h> ...
//prototype of the function
void mytranslate(float x,float y,float z);
//definition of the function
09-29-2008, 12:22 PM
ya its working but can any one tell me how to use glLoadMatrix and glMultmtrix???bcos previous transformations are not working???
09-29-2008, 12:26 PM
Use glMultMatrixf(M.getData()) instead of glLoadMatrixf(M.getData()). The first multiply your matrix with the matrix at the top of the matrix stack, the second replace it.
09-29-2008, 12:37 PM
Do i need to do M.T or T.M to translate???
09-29-2008, 12:44 PM
I don't see the need to do gmtl::postMult(M,T) because you don't define the M matrix (what is inside this matrix? identity?). Just use the T matrix. If you use glMultMatrix, OpenGL will multiply the matrix at the top of the stack(MTS) with the matrix T (MTS*T).
09-29-2008, 12:49 PM
The thing is shape of my cube is changing in vertical direction when i use this translate function.Im my code i implemented translate follows
gluLookAt (0.0, 0.0, 20.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
09-29-2008, 12:55 PM
Remember that in OpenGL you have to declare transformations in the inverse order. So your code that you post above will do the rotation first then the translation.
09-29-2008, 01:06 PM
Thank you but the thing is that when a use
mytranslate() its undoing the rotation???
ok now i got it.Thank u very much dude for the help
09-29-2008, 01:21 PM
Remember that OpenGL store is matrix in column major order. Transpose your matrix T to be in the right order or use glMultTransposeMatrixf (http://www.opengl.org/sdk/docs/man/xhtml/glMultTransposeMatrix.xml).
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.