Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Need Suggestions on Screen co-ordinate system

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2011
    Location
    seoul, south korea
    Posts
    15

    Smile Need Suggestions on Screen co-ordinate system

    Hi
    go thru this screen co-ordinate creation snippet :


    // CMFC_View drawing in MFC.
    void CMFC_View::OnDraw(CDC* pDC)
    {
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    //if(m_3D)
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    ////select the viewing volume
    if(perspectView)
    {
    gluPerspective(26.0f, aspect_ratio, 1.0f, 10000.0f);
    gluLookAt(0.0f,0.0f,m_width*2,0.0f,0.0f,0.0f,0.0f, 1.0f,0.0f);
    } else {
    glOrtho(-1*m_width,m_width,-1*m_height,m_height,-1*1000,1000);
    }//// switch back to the modelview matrix and clear it
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    GetGLMat(m); //Creates 16 elements for Transformations and holds the data.
    glMultMatrixf(m); // Multiplies to the MODELVIEW matrix for changes in display.
    glPushMatrix();
    DisplayGL();
    glPopMatrix();
    glFlush();
    SwapBuffers(m_pDC->GetSafeHdc());
    }


    My questions are
    1. I am creating a orthognal viewport is this good for Modification of vertices in world screen?
    2. If yes give me suggestions on how to modify the Vertices in world screen after transformations?
    3. If any other formats to control world screen co-ordinate system, welcome?

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    941
    First, a few notes:

    a) Please put your snippet into a '['code']' your code here '['/code']' section. Also, you should read the forum guidelines since asking people to read through code in the way you do above isn't really that polite.
    b) Second, what the hell is a world screen? You are either in world coordinates or in screen coordinates.
    c) I can't see any line of code setting up a viewport. Do you understand what a viewport is? Do you mean the view frustum?
    d) I really don't know what your 3. question is supposed to mean.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2011
    Location
    seoul, south korea
    Posts
    15
    I apologize for this post kind. I am a new to this so I did mistake forgive me sorry again. I am trying to explain I have a viewport of ortho so during rotation,scale I am facing problem. The 3D object rotates with respective center of its axis when Z=0. when Z changes the center of rotation not going to happen so my question is how to make world transformations and local transformations of screen co-ordinate system. If you know please tell me that so I can adopt to ma code.

    thanks and regards
    9max9

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    941
    I have a viewport of ortho[..]
    The viewport has nothing to do with the current projection matrix. The viewport is simply a 2D subset of the framebuffer and is used to map vertices from normalized device coordinates to the screen. What you're talking about is an orthogonal projection, glOrtho takes arguments describing the planes of the view-frustum which affects projection of vertices to clip coordinates.

    how to make world transformations and local transformations of screen co-ordinate system.
    .

    The screen coordinate system has nothing to do with rotating objects in object- or world-space. You can reconstruct world-space positions from screen space with additional information but that's not what you're going for.

    As far as I get it you're simply trying to rotate an object locally. So you want some object to always rotate about a certain axis, independent of its world-space position. Is that correct?

  5. #5
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421
    Quote Originally Posted by chethan View Post
    My questions are
    1. I am creating a orthognal viewport is this good for Modification of vertices in world screen?
    2. If yes give me suggestions on how to modify the Vertices in world screen after transformations?
    3. If any other formats to control world screen co-ordinate system, welcome?
    1. it is fine.
    2. You transform all the vertices from object space to screen space using gluProject. Check to see which vertex is closest to the mouse. Select that vertex. As the mouse moves, move the vertex.
    3. You mean other projections? You can try in perspective space if you are up to it.

    BTW : don't call gluLooktAt on a perspective matrix. It will mess up your lighting and certain texgen modes.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •