Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


sujandasmahapatra

Member Since 14 Apr 2009
Offline Last Active Nov 03 2014 10:53 PM

Posts I've Made

In Topic: rotating 2 objects 1 remains static problem opengl

05 March 2013 - 07:11 AM

Please help me


In Topic: rotating 2 objects 1 remains static problem opengl

05 March 2013 - 05:25 AM

If I put drawLine below the transformation the everything is rotating axes and line both, check below the code. How can I make only the axis should rotate and line remains fixed. Please help.

 

void CopenGLCoordView::DrawScene(CDC *pDC)
{
    wglMakeCurrent(pDC->m_hDC, m_hrc);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);    
    glEnable(GL_DEPTH_TEST);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
 
    glPushMatrix();
    glLoadIdentity();
    glRotatef(rot[0], 1.0f, 0.0f, 0.0f);
    glRotatef(rot[1], 0.0f, 1.0f, 0.0f);
    glRotatef(rot[2], 0.0f, 0.0f, 1.0f);
    drawAxes();
    glPrintX("X");
    glPrintY("Y");
    glPrintZ("Z");
    glPopMatrix();
 
    drawLine();
 
    glFlush();
    SwapBuffers(pDC->m_hDC);    
    wglMakeCurrent(NULL, NULL);
}

In Topic: rotating 2 objects 1 remains static problem opengl

05 March 2013 - 05:13 AM

 
void CopenGLCoordView::drawAxes()
{
 
    CDC* pDC = GetDC();
    wglMakeCurrent(pDC->m_hDC, m_hrc);
    glBegin(GL_LINES);
    glVertex3f(0.0f, 0.0f, 0.0f); // origin of the line
    glVertex3f(5.0f, 0.0f, 0.0f); // ending point of the 
    glEnd();
       glBegin(GL_LINES);
    glVertex3f(0.0f, 0.0f, 0.0f); // origin of the line
    glVertex3f(0.0f, 5.0f, 0.0f); // ending point of the 
    glEnd();
       glBegin(GL_LINES);
    glVertex3f(0.0f, 0.0f, 0.0f); // origin of the line
    glVertex3f(0.0f, 0.0f, 5.0f); // ending point of the 
    glEnd();
    wglMakeCurrent(NULL,NULL); 
    ReleaseDC(pDC);
}
 
void CopenGLCoordView::drawLine()
{
    CDC* pDC = GetDC();
    wglMakeCurrent(pDC->m_hDC, m_hrc);
    glBegin(GL_LINES);
        glVertex3f(10,0,0);
        glVertex3f(20,0,0);
    glEnd();
    wglMakeCurrent(NULL,NULL);
 
}

These are my drawaxes and drawLine code. Now my drawscene looks like this

 
void CopenGLCoordView::DrawScene(CDC *pDC)
{
    wglMakeCurrent(pDC->m_hDC, m_hrc);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);    
    glEnable(GL_DEPTH_TEST);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
 
    drawLine();
 
    glPushMatrix();
    glLoadIdentity();
    glRotatef(rot[0], 1.0f, 0.0f, 0.0f);
    glRotatef(rot[1], 0.0f, 1.0f, 0.0f);
    glRotatef(rot[2], 0.0f, 0.0f, 1.0f);
    drawAxes();
    glPrintX("X");
    glPrintY("Y");
    glPrintZ("Z");
    glPopMatrix();
 
    
 
    glFlush();
    SwapBuffers(pDC->m_hDC);    
    wglMakeCurrent(NULL, NULL);
}

 

I have made the glPushMatrix() before glLoadIdentity().......Nothing is rotating...I want only the axes should rotate, line remains fixed in space. Pls help.


PARTNERS