View Full Version : draw circle in 3d and overlaying Font
11-26-2008, 05:15 AM
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 ;
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) ;
glEnd () ;
11-26-2008, 12:58 PM
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:
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.
11-26-2008, 06:32 PM
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...
11-28-2008, 05:58 AM
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.
09-04-2009, 04:08 AM
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.
09-19-2009, 10:38 PM
Stupid OPEN GL
OpenGL says retrieve origin coordinate of vertex using pushmatrix,popmatrix.
see the program
x=1.1; y=1.2; z=0.5;
glRotate(45,1,0,0); // x axis
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.
axis = 1;
glNewValue(angle,axis,x,y,z,&nx,&ny,&nz); // 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.
09-20-2009, 11:43 AM
GL is not what you think it is. Write your own code, steal it ( http://www.google.com/codesearch?hl=en&lr=&q=matrix4+cpp&sbtn=Search ) or use a library (I think GLM can be useful http://glm.g-truc.net/ ). Learn to love matrices.
09-21-2009, 01:31 AM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.