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 8 of 8

Thread: draw circle in 3d and overlaying Font

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2008
    Posts
    23

    draw circle in 3d and overlaying Font

    Hi,
    I draw circle using OpenGL in MFC. it was in 2d only .I want to draw 3d. ho i do.? and also i overlay that circle and Font like (0,30,60,..) in an image. here it was shown in ovelaying circle and Font an image .But font didn't overlaying some Pc.
    plz consider my problem.
    reply as soon as possible.
    thanks in advance
    following is an circle coding in 2d

    #define GL_PI 3.141592654
    #define GL_PI_2 GL_PI * 2
    float fRadius = m_fControlRadius / 2 ;
    glLineWidth(1.5);
    glBegin (GL_LINE_LOOP);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST) ;
    for (float pheta = 0.0f; pheta - GL_PI_2 < .001; pheta +=fAngleIncr)
    {
    float x = fRadius * cos (pheta) ;
    float y = fRadius * sin (pheta) ;
    glVertex2f(x,y) ;
    }
    glEnd () ;

  2. #2
    Junior Member Newbie
    Join Date
    Sep 2008
    Posts
    4

    Re: draw circle in 3d and overlaying Font

    You can use gluSphere to draw a sphere in the viewing volume. First create a Quadric object using gluNewQuadric(void), then call gluSphere(GLUquadricObj*,GLdouble,GLint,GLint) to create the sphere:

    Code :
    GLUquadricObj* sphere_quad = gluNewQuadric( void ) ;
     
    // Draw a sphere with a radius of 10.0 using 10 longitudinal
    // subdivisions, and 10 lattitudinal subdivisions. These
    // predicate the level of detail (i.e. how smooth) your 
    // sphere will be.
    gluSphere( sphere_quad, 10.0, 10, 10 ) ;

    Look into gluQuadricTexture to map a texture onto this surface.

  3. #3
    Intern Contributor
    Join Date
    Jan 2001
    Posts
    84

    Re: draw circle in 3d and overlaying Font

    First off, here is an article on how to draw circles very quickly without using sin and cos for every vertex: http://slabode.exofire.net/circle_draw.shtml This is extremely fast and efficient, requiring only four additions, four multiplies and one negation in the the main loop.

    Second, you really cannot draw a circle in 3D and have it remain a circle. A circle is strictly a 2D entity. To do what you want, use glVertex3f instead of 2f and place the x and y coordinates in the correct spot for the plane you want to draw it in. For instance, use glVertex3f(0.0,x,y) to draw the circle in the y-z plane.

    A better and faster way would be to simply draw it in the x-y plane as you are and then rotate it with glRotate3f.

    Sorry, cannot help with the font thing...

  4. #4
    Junior Member Newbie
    Join Date
    Nov 2008
    Posts
    23

    Re: draw circle in 3d and overlaying Font

    Hi
    Thanks for all. i solved that font problem.
    But i did'nt solve the circle which it is not make as a 3d.
    ok it's no problem.
    Thanks.

  5. #5
    Junior Member Newbie
    Join Date
    Sep 2009
    Posts
    4

    Re: draw circle in 3d and overlaying Font


    Ok dude, drawing sphare (gluSphare) is easy, and its draws. But mere drawing sphare is useless, can you help me in the following

    1. If on click, it should tell which lattitude and longtitude it is clicked.

    2. Identity or marking of each lattitude or longtitude (of course other which it is useless) and of course showing the values of it on the screen.

    Waiting for your positive answer.

  6. #6
    Junior Member Newbie
    Join Date
    Sep 2009
    Posts
    4

    Re: draw circle in 3d and overlaying Font

    Stupid OPEN GL

    OpenGL says retrieve origin coordinate of vertex using pushmatrix,popmatrix.
    How stupid.

    see the program

    double x,y,z;
    x=1.1; y=1.2; z=0.5;
    glRotate(45,1,0,0); // x axis

    glBegin(GL_POINTS)
    glVertex3d(x,y,z);
    glEnd

    I can print x,y,z value (hardcoded) Why push and pop is required
    Instead, It should give function to find new cordinate after rotation.

    orignal value of vertex x,y,z (no function needed it is hardcoded
    i.e. 1.1, 1.2 and 0.5

    what is value after rotation.

    say function
    angle=45
    axis = 1;
    double nx,ny,nz;
    glNewValue(angle,axis,x,y,z,&amp;nx,&amp;ny,&amp;n z); // something like that
    (THIS IS IMAGINARY FUNCTION)

    so new value (WHICH IS NOT AVAILABLE,WHAT GLROTATE MODIFY X,Y,Z IS NOT KNOWN, SHOULD MAKE KNOWN) AND NOT WHAT IS KNOWN MAKE KNOWN
    AGAIN WITH PUSH AND POP.

    Regards

  7. #7
    Member Regular Contributor remdul's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands
    Posts
    335

    Re: draw circle in 3d and overlaying Font

    GL is not what you think it is. Write your own code, steal it ( http://www.google.com/codesearch?hl=...mp;sbtn=Search ) or use a library (I think GLM can be useful http://glm.g-truc.net/ ). Learn to love matrices.

  8. #8
    Junior Member Newbie
    Join Date
    Sep 2009
    Posts
    4

    Re: draw circle in 3d and overlaying Font

    Thanks for your help.

    I have developed very small small prog. I am requiring a small help. When I move a mouse, 3d cordinate of whatever it points i can retrieve. (glUnproject...) I draw a sphare. and when i click on sphare, it shows the clicked point by small red cross.
    BUT. when i rotate, or zoom (glRotate or glscale) and then try to click to see a point, My click is somewhere else and it shows red cross somewhere else. (now glUnproject not working properly)




    Please help me.




Posting Permissions

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