OpenGL 多重采样 抗锯齿

xiuhao1011 2012-10-16 10:39:26
想利用OpenGL多重采样实现抗锯齿的功能,但是按照OpenGL超级宝典的描述,利用代码:


::glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH|GLUT_MULTISAMPLE);
::glEnable(GLUT_MULTISAMPLE);
不能实现最终结果。
有什么要注意的地方我没有注意吗?
谢谢指点!
我的显卡应该支持多重采样
...全文
764 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
the_venus 2012-11-04
  • 打赏
  • 举报
回复
看代码:
GLint pixel_format_attrib_required[]=
{
WGL_DRAW_TO_WINDOW_ARB,1,
WGL_ACCELERATION_ARB,1
WGL_SUPPORT_OPENGL_ARB,1
WGL_DOUBLE_BUFFER_ARB,1
WGL_DEPTH_BITS_ARB,24,
WGL_STENCIL_BITS_ARB,8,
WGL_TYPE_RGBA_ARB,1
WGL_SAMPLES_ARB,4,//我这里用4重采样
WGL_SAMPLE_BUFFERS_ARB,1,//一个多重采样缓冲区
0,0
};
int num_formats_returned;
UINT format_returned;
PIXEL_FORMAT_DESCRIPTOR pfd;
HDC hdc;
HGLRC hglrc;

hdc = GetDC(hWnd);
if(hdc == NULL)
{
   error("Failed to get dc:%d...",GetLastError());
   return ERROR;   
}

if(!wglChoosePixelFormatARB(pixel_format_attrib_required,NULL,1,&num_formats_returned,&format_returned) || num_formats_returned == 0)
{
   error("Failed to choose pixel format:%d..",GetLastError());//错误处理
    return ERROR;
}

ZeroMemroy(&pfd,sizeof(PIXEL_FORMAT_DESCRIPTOR));

if(!DescribePixelFormat(hdc,format_returned,&pfd))
{
   error("Failed to describe pixel format:%d...,",GetLastError());
   return ERROR;
}

if(!SetPixelFormat(hdc,format_returned,&pfd))
{
   error("Failed to set pixel format:%d...",GetLastError());
   return ERROR;
}

hglrc =wglCreateContext(hdc);
if(hglrc == NULL)
{
   error("Failed to create context:%d...",GetLastError());
   return ERROR;
}
if(!wglMakeCurrent(hdc,hglrc))
{
   error("Failed to make current context:%d...",GetLastError());
   return ERROR;
}
...
glEnable(GL_MULTISAMPLE_ARB);
xiuhao1011 2012-10-20
  • 打赏
  • 举报
回复
没有人知道吗。。。。。。。。?

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧