Пример #1
0
GHOST_TSuccess GHOST_WindowWin32::initMultisample(PIXELFORMATDESCRIPTOR pfd)
{
	int pixelFormat;
	bool success = FALSE;
	UINT numFormats;
	HDC hDC = GetDC(getHWND());
	float fAttributes[] = {0, 0};
	UINT nMaxFormats = 1;

	// The attributes to look for
	int iAttributes[] = {
		WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
		WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
		WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
		WGL_COLOR_BITS_ARB, pfd.cColorBits,
		WGL_DEPTH_BITS_ARB, pfd.cDepthBits,
		WGL_ALPHA_BITS_ARB, pfd.cAlphaBits,
		WGL_STENCIL_BITS_ARB, pfd.cStencilBits,
		WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
		WGL_SAMPLE_BUFFERS_ARB, GL_TRUE,
		WGL_SAMPLES_ARB, m_multisample,
		0, 0
	};

	// Get the function
	PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");

	if (!wglChoosePixelFormatARB)
	{
		m_multisampleEnabled = GHOST_kFailure;
		return GHOST_kFailure;
	}

	// iAttributes[17] is the initial multisample. If not valid try to use the closest valid value under it.
	while (iAttributes[17] > 0) {
		// See if the format is valid
		success = wglChoosePixelFormatARB(hDC, iAttributes, fAttributes, nMaxFormats, &pixelFormat, &numFormats);
		GHOST_PRINTF("WGL_SAMPLES_ARB = %i --> success = %i, %i formats\n", iAttributes[17], success, numFormats);

		if (success && numFormats >= 1 && m_multisampleEnabled == GHOST_kFailure) {
			GHOST_PRINTF("valid pixel format with %i multisamples\n", iAttributes[17]);
			m_multisampleEnabled = GHOST_kSuccess;
			m_msPixelFormat = pixelFormat;
		}
		iAttributes[17] -= 1;
		success = GHOST_kFailure;
	}
	if (m_multisampleEnabled == GHOST_kSuccess) {
		return GHOST_kSuccess;
	}
	GHOST_PRINT("no available pixel format\n");
	return GHOST_kFailure;
}
Пример #2
0
void GHOST_NDOFManager::setDeadZone(float dz)
{
	if (dz < 0.0f) {
		// negative values don't make sense, so clamp at zero
		dz = 0.0f;
	}
	else if (dz > 0.5f) {
		// warn the rogue user/developer, but allow it
		GHOST_PRINTF("ndof: dead zone of %.2f is rather high...\n", dz);
	}
	m_deadZone = dz;

	GHOST_PRINTF("ndof: dead zone set to %.2f\n", dz);
}