OPENGL坐标变换的问题

icaohong icaohong 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我的代码如下:
void CWnd3D::OnPaint()
{
CPaintDC dc(this); // device context for painting

// TODO: Add your message handler code here
HDC hdc = ::GetDC(m_hWnd);
HGLRC hglrc;

// TODO: Add your message handler code here
glClearColor(0,0,0,0);
glColor3f(1, 1, 1);

if (hglrc = wglCreateContext(hdc))
{
// try to make it the thread's current rendering context
if(wglMakeCurrent(hdc, hglrc))
{
//render here
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(m_fRot[0], 1, 0, 0);
glRotatef(m_fRot[1], 0, 1, 0);

glScalef(200, 300, 256);/////注意这行!!

//画坐标轴
if (m_bAxis)
{
DrawAxis();
}


glPopMatrix();
// glFlush();


SwapBuffers(hdc);
}
}

wglMakeCurrent(NULL, NULL) ;
::ReleaseDC (m_hWnd, hdc) ;
wglDeleteContext(hglrc);

// Do not call CWnd::OnPaint() for painting messages
}


void CWnd3D::DrawAxis()
{
glBegin(GL_LINES);
glColor3f(1,0,0);//x轴
glVertex3f(0,0,0);
glVertex3f(1,0,0);
glColor3f(0,1,0);//y轴
glVertex3f(0,0,0);
glVertex3f(0,1,0);
glColor3f(0,0,1);//z轴
glVertex3f(0,0,0);
glVertex3f(0,0,1);
glEnd();
}

我想画坐标超过100的图元(如画线从(0,0,0)到(200,120,200)),怎么办?用glScalef()怎么没有反应???
...全文
评论 2
收藏 已收藏
分享
返回顶部
icaohong
VC/MFC 16,550 成员 421,606 内容