Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: how to custom implement gltranslate

  1. #1
    Member Contributor
    Join Date
    Sep 2008
    Posts
    65

    how to custom implement gltranslate

    sir,
    I want to implement opengl translate function
    Code :
    static void mytranslate(float x,float y,float z)
    {
    	gmtl::Matrix44f M,T;
    	T.set(1,0,0,x,
    		  0,1,0,y,
    		  0,0,0,z,
    		  0,0,0,1);
    	gmtl::postMult(M,T);
    	glMatrixMode(GL_MODELVIEW);
    	glLoadMatrixf(M.getData());
     
    }
    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.

  2. #2
    Senior Member Regular Contributor trinitrotoluene's Avatar
    Join Date
    Sep 2008
    Location
    Montérégie,Québec
    Posts
    362

    Re: how to custom implement gltranslate

    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.




  3. #3
    Member Contributor
    Join Date
    Sep 2008
    Posts
    65

    Re: how to custom implement gltranslate

    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.

  4. #4
    Senior Member Regular Contributor trinitrotoluene's Avatar
    Join Date
    Sep 2008
    Location
    Montérégie,Québec
    Posts
    362

    Re: how to custom implement gltranslate

    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);

    void main(...)
    {
    ...
    mytranslate(...)
    ...
    }

    //definition of the function
    mytranslate(...)
    {

    }

  5. #5
    Member Contributor
    Join Date
    Sep 2008
    Posts
    65

    Re: how to custom implement gltranslate

    ya its working but can any one tell me how to use glLoadMatrix and glMultmtrix???bcos previous transformations are not working???

  6. #6
    Senior Member Regular Contributor trinitrotoluene's Avatar
    Join Date
    Sep 2008
    Location
    Montérégie,Québec
    Posts
    362

    Re: how to custom implement gltranslate

    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.

  7. #7
    Member Contributor
    Join Date
    Sep 2008
    Posts
    65

    Re: how to custom implement gltranslate

    Do i need to do M.T or T.M to translate???

  8. #8
    Senior Member Regular Contributor trinitrotoluene's Avatar
    Join Date
    Sep 2008
    Location
    Montérégie,Québec
    Posts
    362

    Re: how to custom implement gltranslate

    I don't see the need to do gmtl:ostMult(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).

  9. #9
    Member Contributor
    Join Date
    Sep 2008
    Posts
    65

    Re: how to custom implement gltranslate

    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

    Code :
    glClear(GL_COLOR_BUFFER_BIT);
    	//glColor3f(1.0,1.0,1.0);
    	glPushMatrix();
    	glLoadIdentity();
    	gluLookAt (0.0, 0.0, 20.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
    	mytranslate(1.0,0.0,0.0);
    	glRotatef(-60,1.0,.0,0.0);
    	glBegin();

  10. #10
    Senior Member Regular Contributor trinitrotoluene's Avatar
    Join Date
    Sep 2008
    Location
    Montérégie,Québec
    Posts
    362

    Re: how to custom implement gltranslate

    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.

Page 1 of 2 12 LastLast

Similar Threads

  1. fbo gltranslate
    By mikethebike in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 02-01-2012, 03:53 AM
  2. Need to custom implement gluLookAt()
    By brett01 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 10-02-2008, 01:27 PM
  3. glTranslate
    By Eymerich in forum OpenGL ES
    Replies: 3
    Last Post: 12-18-2007, 03:52 AM
  4. gltranslate
    By CNCapps in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-28-2006, 09:54 AM
  5. glTranslate
    By Andrew Waller in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-30-2006, 12:42 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