OPENGL坐标变换的问题
我的代码如下:
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()怎么没有反应???
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()怎么没有反应???
...全文
相关推荐
基于opengl的三维场景
**OpenGL**:OpenGL是一个开放标准的图形库,提供了一组用于绘制3D和2D图形的函数。它包括用于坐标变换、颜色设置、几何体绘制等功能的API。3.
VC++ OpenGL三维物体建模--雨伞的绘制(含详细注释)
接下来,坐标变换是OpenGL中的核心概念之一。为了在三维空间中移动、旋转和缩放物体,我们需要应用平移、旋转和缩放矩阵。
基于OpenGL的管线三维显示方法研究.pdf
#### 结论综上所述,本文介绍了一种基于OpenGL的管线三维显示方法,该方法结合了坐标变换、剪切变换以及STL库的优势,有效解决了管线三维显示的问题。
【OPENGL】opengl房子设计1
在调试过程中,开发者可能遇到了各种问题,如坐标变换错误、渲染顺序不当导致的重影或丢失物体部分、光照效果不理想等。
openGL电梯运动
通过这样的实验,开发者不仅可以掌握图形编程技术,还能锻炼问题解决和项目管理能力。如果你对这个项目感兴趣,可以深入学习OpenGL教程,逐步理解并实现类似的效果。


