本文介绍了如何在OpenGL中启用多重采样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我正在使用VS2008和库freeglut和glew编写C ++代码脚本.
我编写了以下代码(省略了不必要的代码行):

Hi everybody!

I''m writing a C++ code script using VS2008 and libraries freeglut and glew.
I wrote following code (I omit unnecessary code lines):

#include "stdafx.h"
#include "DrawingRegion.h"
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <gl\glew.h>
#pragma comment(lib, "glew32.lib")
#include <gl\freeglut.h>
#pragma comment(lib, "freeglut.lib")
BEGIN_MESSAGE_MAP(CDrawingRegion, CWnd)
	ON_WM_PAINT()
END_MESSAGE_MAP()
// CDrawingRegion message handlers
///////////////////////////////////
void CDrawingRegion::OnPaint()
{
	CPaintDC dc(this);
	GetClientRect(&cr);
	if (wglMakeCurrent(dc.m_hDC, hglrc) == FALSE)
	{
		CTime t = CTime::GetCurrentTime();
	}
	// C O D E

	if (SwapBuffers(wglGetCurrentDC()) == FALSE)
	{
		CTime t = CTime::GetCurrentTime();
	}
	if (wglMakeCurrent(NULL, NULL) == FALSE)
	{
		CTime t = CTime::GetCurrentTime();
	}
	glFlush();
}
void CDrawingRegion::PreSubclassWindow()
{
	// TODO: Add your specialized code here and/or call the base class
	PIXELFORMATDESCRIPTOR pfd;
	memset(&pfd, 0, sizeof(pfd));
	pfd.nSize = sizeof(pfd);
	pfd.nVersion = 1;
	pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
	pfd.iPixelType = PFD_TYPE_RGBA;
	pfd.iLayerType = PFD_MAIN_PLANE;
	pfd.cColorBits = 24;
	pfd.cDepthBits = 16;
  	CDC *pDC = GetDC();
	int iPixelFormat = ChoosePixelFormat(pDC->m_hDC, &pfd);
	if (iPixelFormat == 0)
	{
		CTime t = CTime::GetCurrentTime();
	}
	if (SetPixelFormat(pDC->m_hDC, iPixelFormat, &pfd) == FALSE)
	{
		CTime t = CTime::GetCurrentTime();
	}

	if ((hglrc = wglCreateContext(pDC->m_hDC)) == NULL)
	{
		CTime t = CTime::GetCurrentTime();
	}
	ReleaseDC(pDC);
	CWnd::PreSubclassWindow();
}</math.h></stdio.h></stdlib.h></windows.h>



如何在OpenGL中启用多重采样?谢谢!



How can I enable multisampling in OpenGL? Thanks!

推荐答案


这篇关于如何在OpenGL中启用多重采样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 15:29