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();
}
}