PDA

View Full Version : auxSolidCylinder & glutSolidCylinder woes



SpaceGhost
05-07-2003, 06:28 AM
Here, I am plotting a series of shapes, and I am having problems glut and aux SolidCylinders. If I use Spheres I am OK, but I don't want to use them. When I use cylinders, I only get 1 cylinder instead of multiple cylinders.

glPushMatrix();
glTranslated(x[i],y[i],z[i]);
glutSolidSphere(.006f, 10, 10);
//auxSolidCylinder(.006f,.25f);//why not ?
glPopMatrix();

Why is it that I only get 1 cylinder but multiple spheres, and what am I doing wrong?

thank you,

SpaceGhost

nexusone
05-07-2003, 06:31 AM
You have to call the sphere routine each time you want to draw a new one.

Also are you drawing them all in the same place?

Now about a little bit more code?


Originally posted by SpaceGhost:
Here, I am plotting a series of shapes, and I am having problems glut and aux SolidCylinders. If I use Spheres I am OK, but I don't want to use them. When I use cylinders, I only get 1 cylinder instead of multiple cylinders.

glPushMatrix();
glTranslated(x[i],y[i],z[i]);
glutSolidSphere(.006f, 10, 10);
//auxSolidCylinder(.006f,.25f);//why not ?
glPopMatrix();

Why is it that I only get 1 cylinder but multiple spheres, and what am I doing wrong?

thank you,

SpaceGhost

SpaceGhost
05-07-2003, 06:56 AM
Uh no, I am translating to draw each shape in a diff place. My results are just fine with the Sphere, and I get what I am expecting. When I use the Cylinder I get the wrong results.

-SG
Here is my source:

int CDialogGLDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;

HWND hWnd = GetSafeHwnd();
HDC hDC = ::GetDC(hWnd);

if(SetWindowPixelFormat(hDC)==FALSE)
return 0;

if(CreateViewGLContext(hDC)==FALSE)
return 0;

COLORREF color = ::GetSysColor(COLOR_3DFACE);
glClearColor((float)GetRValue(color)/255.0f,
(float)GetGValue(color)/255.0f,
(float)GetBValue(color)/255.0f,
1.0);

glPolygonMode(GL_FRONT,GL_FILL);
glPolygonMode(GL_BACK,GL_FILL);

// Gouraud
glShadeModel(GL_SMOOTH);

BuildList();

SetTimer(0,10,NULL);
return 0;
}
void CDialogGLDlg::BuildList()
{
imax = nInputFileCoord_ctr;//these coords are read when dialog is opened
::glNewList(1,GL_COMPILE_AND_EXECUTE);
glColor3f(0.0f,0.5f,0.5f);
for (int i = 0; i< imax;i++)
{
glPushMatrix();
glTranslated(x[i],y[i],z[i]);
glutSolidSphere(.006f, 10, 10);
//auxSolidCylinder(.006f,.25f);//why not ?
glPopMatrix();
}
::glEndList();
}

void CDialogGLDlg::RenderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glPushMatrix();

// Position / translation (mouse rotation)
glTranslated(0.0,0.0,-8.0);
glRotated(m_xRotate, 1.0, 0.0, 0.0);
glRotated(m_yRotate, 0.0, 1.0, 0.0);
glScalef(m_ScaleX,m_ScaleY,m_ScaleZ);

// Only one list, the box
::glCallList(1);

glPopMatrix();
}

void CDialogGLDlg::OnPaint()
{
if (IsIconic())
{
//here typical MFC code for this case
}
else
{
CPaintDC dc(this); // device context for painting
RenderScene();
SwapBuffers(dc.m_ps.hdc);
CDialog::OnPaint();

}
}

SpaceGhost
05-07-2003, 06:58 AM
The timer just changes x and y rotation/member variables.
-SG

SpaceGhost
05-07-2003, 08:48 AM
Anybody know the answer to this question?

I have complied and supplied the necessary source code as requested.

What is so diff about glutSolidCylinder() and glutSolidSphere()???

-SG

shinpaughp
05-07-2003, 10:15 AM
Are you using glutSolidCylinder or auxSolidCylinder? I found all kinds of web sites with glutSolidCylinder and yet I have no definitions in my glut headers or libs. If you do have them in yours, please let me know where I can get a newer version of glut as I just downloaded the latest (to the best of my knowledge) from Nate Robbin's site.

Anyway, I have no clue. Seems extremely odd that it doesn't work properly, but my only advice would be to use gluCylinder instead of aux. Always prefer anything else over GLaux. It is outdated and unsupported and probably the reason why it doesn't work properly if it does with the glut spheres and all the rest of the code unchanged. My opinion at least.

SpaceGhost
05-07-2003, 10:26 AM
Yes Shin, I too came to that conclusion after a visit ironically to the Microsoft site. Last I heard though, they were getting ready to claim OpenGL as deprecated.
article entitled:

Is Microsoft poised to open a brawl on the graphics front?
http://www.directx.com/home.htm


PS here is my new code.

glTranslated(x[i],y[i],z[i]);
double diff = 0;
if (fabs(z[i]) > fabs(z[i-1]))
diff = fabs(z[i]) - fabs(z[i-1]);
else
diff = fabs(z[i-1]) - fabs(z[i-1]);
GLUquadricObj* qobj1 = gluNewQuadric( );
gluCylinder(
qobj1,
.006,
.006,
diff,
10,
10 );
gluDeleteQuadric(qobj1);

SpaceGhost
05-07-2003, 10:27 AM
and thank you everybody for your replies.
-SG

nexusone
05-07-2003, 11:55 AM
I have worried about openGL when SGI sold some of its 3D IP to MicroSoft.
(SGI is the founder of OpenGL)
Since they could use it to kill, openSource ports of openGL, like what is used for Linux.

I bet when SGI sold the IP to them, they covered their butt's to keep use withing there systems, but maybe not outside.

Now also there has been talk of Microsoft making some type of OpenGL class to work within Direct-X, so that OpenGL call would be made directly through direct X.

On the cylinder, unlike sphere where the axis is at the center, on the cylinder object the axis is defaulted at the starting end of the cylinder.


Originally posted by SpaceGhost:
Yes Shin, I too came to that conclusion after a visit ironically to the Microsoft site. Last I heard though, they were getting ready to claim OpenGL as deprecated.
article entitled:

Is Microsoft poised to open a brawl on the graphics front?
http://www.directx.com/home.htm


PS here is my new code.

glTranslated(x[i],y[i],z[i]);
double diff = 0;
if (fabs(z[i]) > fabs(z[i-1]))
diff = fabs(z[i]) - fabs(z[i-1]);
else
diff = fabs(z[i-1]) - fabs(z[i-1]);
GLUquadricObj* qobj1 = gluNewQuadric( );
gluCylinder(
qobj1,
.006,
.006,
diff,
10,
10 );
gluDeleteQuadric(qobj1);

SpaceGhost
05-09-2003, 05:29 AM
If it is any consolation, I got my version of glut from Nate Robbin's site 'glut for win32' as well.

-SG


Originally posted by shinpaughp:
[B]Are you using glutSolidCylinder or auxSolidCylinder? I found all kinds of web sites with glutSolidCylinder and yet I have no definitions in my glut headers or libs. If you do have them in yours, please let me know where I can get a newer version of glut as I just downloaded the latest (to the best of my knowledge) from Nate Robbin's site.
[B]

SpaceGhost
05-09-2003, 05:39 AM
Originally posted by nexusone:
I have worried about openGL when SGI sold some of its 3D IP to MicroSoft.
(SGI is the founder of OpenGL)
Since they could use it to kill, openSource ports of openGL, like what is used for Linux.

I bet when SGI sold the IP to them, they covered their butt's to keep use withing there systems, but maybe not outside.

Now also there has been talk of Microsoft making some type of OpenGL class to work within Direct-X, so that OpenGL call would be made directly through direct X.

On the cylinder, unlike sphere where the axis is at the center, on the cylinder object the axis is defaulted at the starting end of the cylinder.




Hmm,

Although I find it distasteful to call OpenGL from MS DirectX...that may be a perserving feature for OpenGL.

-SG