Results 1 to 2 of 2

Thread: translation problem

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2001
    Posts
    1

    translation problem

    I would like to know how to translate logical to screen coordinates.I am aware of the gluProject/gluUnProject ,but i don't need tehm.What i need is to find a way to estimate how many pixels correspond to a logical unit of length.Any help would be appreciated.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Feb 2001
    Posts
    108

    Re: translation problem

    if you are doing stuff on the viewport plane, itīs easy:

    one pixel width = viewport_with / screen_x_resolution
    oe pixel height = viewport height / screen_y_resolution

    so, if you want to draw a dot directly in fron of the camera (basically in 2D) at coordinates (300,200), with a frustum starting at 1.5, do

    glBegin(GL_POINTS);
    glVertex3f(300*pixwidth-viewport_width/2, 200*pixheight-viewport_height/2, -1.50001);
    glEnd();

    note that y-coords are upside-down.
    the -1.500001 is necessary becaus if you chose -1.5, some gfx drivers assume the point is actually behind your frustum

Similar Threads

  1. translation problem need help
    By deshan in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-10-2011, 04:46 AM
  2. problem with translation using glFrustrum
    By mccarun in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-07-2009, 06:36 AM
  3. Translation problem
    By Chuffy_345 in forum OpenGL: General
    Replies: 4
    Last Post: 02-20-2004, 09:12 AM
  4. Translation problem
    By Chuffy_345 in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 02-20-2004, 04:45 AM
  5. translation problem
    By coda in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-30-2003, 08:10 AM

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