Results 1 to 6 of 6

Thread: Text Picking

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2002
    Location
    Bangalore, India
    Posts
    14

    Text Picking

    I am drawing text using the OpenGL bitmaps(glBitmap) on to the drawing area created using X-Motif. I want to pick that text using the mouse as like any other geometric objects. So, please give me the coding details using OpenGL.

  2. #2
    V-man
    Guest

    Re: Text Picking

    OpenGL has the selection buffer and that can be used for picking. You need to determine the dimensions of the glBitmap to be drawn and render a invisible primitive in the exact location.

    Or better yet, just use textured primitives for your text and use those for the selection buffer as well.

    V-man

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2002
    Location
    Bangalore, India
    Posts
    14

    Re: Text Picking

    Hi,
    Thanks alot,
    But , how to find the dimensions of a bitmap character.So that , I can draw a rectangle around that bitmap , then I can pick.
    Please , give me an idea.
    Thank you
    Sadhu

  4. #4
    V-man
    Guest

    Re: Text Picking

    The glBitmap will be a raster operation, so you know for certain which pixels are gone get rendered to.

    You need to know the current raster position. Its also best for this case to use a ortho projection, and to have ortho be the size of your screen.

    glOrtho(0, width, 0, height, -1.0, 1.0);

    Now call
    glRaster2i(rasterX, rasterY);

    The primitive can be
    glBegin(GL_TRIANGLE_STRIP);
    glVertex2f(rasterX, rasterY);
    glVertex2f(rasterX, rasterY+height_of_glBitmap);
    glVertex2f(rasterX+width_of_glBitmap, rasterY);
    glVertex2f(rasterX+width_of_glBitmap, rasterY+height_of_glBitmap);
    glEnd();

    I hope this is correct. You can do a test and see. Also, there are the rasterization rules of opengl that may effect the exact pixels that get rendered too (something about a tiny offset needed in glVertex calls - 0.375 I think)

    PS: cross your fingers!
    V-man

  5. #5
    V-man
    Guest

    Re: Text Picking

    That may need to be

    glBegin(GL_TRIANGLE_STRIP);
    glVertex2f(rasterX, rasterY);
    glVertex2f(rasterX, rasterY-height_of_glBitmap);
    glVertex2f(rasterX+width_of_glBitmap, rasterY);
    glVertex2f(rasterX+width_of_glBitmap, rasterY-height_of_glBitmap);
    glEnd();

    V-man

  6. #6
    Junior Member Newbie
    Join Date
    Jan 2002
    Location
    Bangalore, India
    Posts
    14

    Re: Text Picking

    Hi V-man,
    thank you very much.


    Regards.
    sadhu

Similar Threads

  1. Text rendering class does not draw text
    By th0masr0ss in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-23-2015, 09:10 PM
  2. Glut picking and text
    By Digga in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 08-09-2013, 02:47 PM
  3. Z-buffer picking, gluUnProject picking not working
    By Icetigris in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-29-2008, 10:38 AM
  4. Picking Icosahedra and 3D Text
    By Tokage in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-07-2004, 08:10 AM
  5. Replies: 0
    Last Post: 11-15-2002, 02:58 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