当前位置: 首页>>代码示例>>C++>>正文


C++ SetDeviceGammaRamp函数代码示例

本文整理汇总了C++中SetDeviceGammaRamp函数的典型用法代码示例。如果您正苦于以下问题:C++ SetDeviceGammaRamp函数的具体用法?C++ SetDeviceGammaRamp怎么用?C++ SetDeviceGammaRamp使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetDeviceGammaRamp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateGamma

// Called from GLimp_SetGamma() and AppActivate()
static void UpdateGamma()
{
	if (!gammaValid) return;
#if 0
	DebugPrintf("updata gamma\n");
	if (!SetDeviceGammaRamp(gl_hDC, newGamma))
		DebugPrintf("Cannot update gamma!\n");
#else
	SetDeviceGammaRamp(gl_hDC, newGamma);
#endif
}
开发者ID:RkShaRkz,项目名称:Quake2,代码行数:12,代码来源:gl_win.cpp

示例2: Win_Activate

static void Win_Activate( WPARAM wParam ) {
    active_t active;

    if( HIWORD( wParam ) ) {
        // we don't want to act like we're active if we're minimized
        active = ACT_MINIMIZED;
    } else {
        if( LOWORD( wParam ) ) {
            active = ACT_ACTIVATED;
        } else {
            active = ACT_RESTORED;
        }
    }

    CL_Activate( active );

    if( win_noalttab->integer ) {
        if( active == ACT_ACTIVATED ) {
            Win_EnableAltTab();
        } else {
            Win_DisableAltTab();
        }
    }

    if( win.flags & QVF_GAMMARAMP ) {
        if( active == ACT_ACTIVATED ) {
            SetDeviceGammaRamp( win.dc, win.gamma_cust );
        } else {
            SetDeviceGammaRamp( win.dc, win.gamma_orig );
        }
    }

    if( win.flags & QVF_FULLSCREEN ) {
        if( active == ACT_ACTIVATED ) {
            ShowWindow( win.wnd, SW_RESTORE );
        } else {
            ShowWindow( win.wnd, SW_MINIMIZE );
        }

        if( vid_flip_on_switch->integer ) {
            if( active == ACT_ACTIVATED ) {
                ChangeDisplaySettings( &win.dm, CDS_FULLSCREEN );
            } else {
                ChangeDisplaySettings( NULL, 0 );
            }
        }
    }

    if( active == ACT_ACTIVATED ) {
        SetForegroundWindow( win.wnd );
    }
}
开发者ID:Bad-ptr,项目名称:q2pro,代码行数:52,代码来源:vid_win.c

示例3: RestoreGamma

// Called from GLimp_Shutdown() and AppActivate()
static void RestoreGamma()
{
	if (!gammaStored) return;
	HWND hwnd = GetDesktopWindow();
	HDC hdc = GetDC(hwnd);
#if 0
	DebugPrintf("restore gamma\n");
	if (!SetDeviceGammaRamp(hdc, gammaRamp))
		DebugPrintf("Cannot restore gamma!\n");
#else
	SetDeviceGammaRamp(hdc, gammaRamp);
#endif
	ReleaseDC(hwnd, hdc);
}
开发者ID:RkShaRkz,项目名称:Quake2,代码行数:15,代码来源:gl_win.cpp

示例4: alwaysAssertM

void SDLWindow::setGammaRamp(const Array<uint16>& gammaRamp) {
    alwaysAssertM(gammaRamp.size() >= 256, "Gamma ramp must have at least 256 entries");

    Log* debugLog = Log::common();

    uint16* ptr = const_cast<uint16*>(gammaRamp.getCArray());
    #ifdef WIN32
        // On windows, use the more reliable SetDeviceGammaRamp function.
        // It requires separate RGB gamma ramps.
        uint16 wptr[3 * 256];
        for (int i = 0; i < 256; ++i) {
            wptr[i] = wptr[i + 256] = wptr[i + 512] = ptr[i]; 
        }
        BOOL success = SetDeviceGammaRamp(wglGetCurrentDC(), wptr);
    #else
        bool success = (SDL_SetGammaRamp(ptr, ptr, ptr) != -1);
    #endif

    if (! success) {
        if (debugLog) {debugLog->println("Error setting gamma ramp!");}

        #ifdef WIN32
            debugAssertM(false, "Failed to set gamma ramp");
        #else
            if (debugLog) {debugLog->println(SDL_GetError());}
            debugAssertM(false, SDL_GetError());
        #endif
    }
}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:29,代码来源:SDLWindow.cpp

示例5: WG_GetOldGammaRamp

/*
** WG_GetOldGammaRamp
**
*/
void WG_GetOldGammaRamp(void)
{
	HDC			hDC;

	hDC = GetDC(GetDesktopWindow());
	GetDeviceGammaRamp(hDC, s_oldHardwareGamma);
	ReleaseDC(GetDesktopWindow(), hDC);


	/*
	** GLimp_SetGamma
	**
	*/
	void GLimp_SetGamma(unsigned char red[256], unsigned char green[256], unsigned char blue[256]) {
		unsigned short table[3][256];
		int i;

		if (!glw_state.hDC) {
			return;
		}

		for (i = 0; i < 256; i++) {
			table[0][i] = (((unsigned short) red[i]) << 8) | red[i];
			table[1][i] = (((unsigned short) green[i]) << 8) | green[i];
			table[2][i] = (((unsigned short) blue[i]) << 8) | blue[i];
		}

		if (!SetDeviceGammaRamp(glw_state.hDC, table)) {
			common->Printf("WARNING: SetDeviceGammaRamp failed.\n");
		}
	}
开发者ID:AreaScout,项目名称:dante-doom3-odroid,代码行数:35,代码来源:win_gamma.cpp

示例6: GLimp_SetGammaRamp

/*
** GLimp_SetGammaRamp
*/
void GLimp_SetGammaRamp( size_t stride, unsigned short *ramp )
{
	if( qwglGetDeviceGammaRamp3DFX )
		qwglSetDeviceGammaRamp3DFX( glw_state.hDC, ramp );
	else
		SetDeviceGammaRamp( glw_state.hDC, ramp );
}
开发者ID:Racenet,项目名称:racesow,代码行数:10,代码来源:win_glw.c

示例7: _glfwPlatformSetGammaRamp

void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
{
    HDC dc;
    WORD values[768];
    DISPLAY_DEVICE display;

    if (ramp->size != 256)
    {
        _glfwInputError(GLFW_PLATFORM_ERROR,
                        "Win32: Gamma ramp size must be 256");
        return;
    }

    memcpy(values +   0, ramp->red,   256 * sizeof(unsigned short));
    memcpy(values + 256, ramp->green, 256 * sizeof(unsigned short));
    memcpy(values + 512, ramp->blue,  256 * sizeof(unsigned short));

    ZeroMemory(&display, sizeof(DISPLAY_DEVICE));
    display.cb = sizeof(DISPLAY_DEVICE);
    EnumDisplayDevices(monitor->win32.name, 0, &display, 0);

    dc = CreateDC(L"DISPLAY", display.DeviceString, NULL, NULL);
    SetDeviceGammaRamp(dc, values);
    DeleteDC(dc);
}
开发者ID:Cloudef,项目名称:glfw,代码行数:25,代码来源:win32_gamma.c

示例8: DIB_SetGammaRamp

int DIB_SetGammaRamp(_THIS, Uint16 *ramp)
{
#ifdef NO_GAMMA_SUPPORT
	SDL_SetError("SDL compiled without gamma ramp support");
	return -1;
#else
	HDC hdc;
	BOOL succeeded;

	/* Set the ramp for the display */
	if ( ! gamma_saved ) {
		gamma_saved = (WORD *)malloc(3*256*sizeof(*gamma_saved));
		if ( ! gamma_saved ) {
			SDL_OutOfMemory();
			return -1;
		}
		hdc = GetDC(SDL_Window);
		GetDeviceGammaRamp(hdc, gamma_saved);
		ReleaseDC(SDL_Window, hdc);
	}
	if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
		hdc = GetDC(SDL_Window);
		succeeded = SetDeviceGammaRamp(hdc, ramp);
		ReleaseDC(SDL_Window, hdc);
	} else {
		succeeded = TRUE;
	}
	return succeeded ? 0 : -1;
#endif /* !NO_GAMMA_SUPPORT */
}
开发者ID:Goettsch,项目名称:game-editor,代码行数:30,代码来源:SDL_dibvideo.c

示例9: GetDC

BOOL CGammaRamp::SetBrightness(WORD wBrightness, HDC hDC)
{
	BOOL bReturn = FALSE;
	HDC hGammaDC = hDC;

	if (hDC == NULL)
		hGammaDC = GetDC(NULL);

	if (hGammaDC != NULL)
	{
		WORD GammaArray[3][256];

		for (int iIndex = 0; iIndex < 256; iIndex++)
		{
			int iArrayValue = iIndex * (wBrightness + 128);

			if (iArrayValue > 65535)
				iArrayValue = 65535;

			GammaArray[0][iIndex] = 
			GammaArray[1][iIndex] = 
			GammaArray[2][iIndex] = (WORD)iArrayValue;
			
		}

		bReturn = SetDeviceGammaRamp(hGammaDC, GammaArray);
	}

	if (hDC == NULL)
		ReleaseDC(NULL, hGammaDC);

	return bReturn;
}
开发者ID:dranger003,项目名称:GammaRamp,代码行数:33,代码来源:GammaRamp.cpp

示例10: GLimp_SetGamma

/*
** GLimp_SetGamma
**
** This routine should only be called if glConfig.deviceSupportsGamma is TRUE
*/
void GLimp_SetGamma( unsigned char red[256], unsigned char green[256], unsigned char blue[256] ) {
	unsigned short table[3][256];
	int		i, j;
	int		ret;
	OSVERSIONINFO	vinfo;

	if ( !glConfig.deviceSupportsGamma || r_ignorehwgamma->integer || !glw_state.hDC ) {
		return;
	}

//mapGammaMax();

	for ( i = 0; i < 256; i++ ) {
		table[0][i] = ( ( ( unsigned short ) red[i] ) << 8 ) | red[i];
		table[1][i] = ( ( ( unsigned short ) green[i] ) << 8 ) | green[i];
		table[2][i] = ( ( ( unsigned short ) blue[i] ) << 8 ) | blue[i];
	}

	// Win2K puts this odd restriction on gamma ramps...
	vinfo.dwOSVersionInfoSize = sizeof(vinfo);
	GetVersionEx( &vinfo );
	if ( vinfo.dwMajorVersion == 5 && vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT ) {
		Com_DPrintf( "performing W2K gamma clamp.\n" );
		for ( j = 0 ; j < 3 ; j++ ) {
			for ( i = 0 ; i < 128 ; i++ ) {
				if ( table[j][i] > ( (128+i) << 8 ) ) {
					table[j][i] = (128+i) << 8;
				}
			}
			if ( table[j][127] > 254<<8 ) {
				table[j][127] = 254<<8;
			}
		}
	} else {
		Com_DPrintf( "skipping W2K gamma clamp.\n" );
	}

	// enforce constantly increasing
	for ( j = 0 ; j < 3 ; j++ ) {
		for ( i = 1 ; i < 256 ; i++ ) {
			if ( table[j][i] < table[j][i-1] ) {
				table[j][i] = table[j][i-1];
			}
		}
	}


	if ( qwglSetDeviceGammaRamp3DFX )
	{
		qwglSetDeviceGammaRamp3DFX( glw_state.hDC, table );
	}
	else
	{
		ret = SetDeviceGammaRamp( glw_state.hDC, table );
		if ( !ret ) {
			Com_Printf( "SetDeviceGammaRamp failed.\n" );
		}
	}
}
开发者ID:AHPlankton,项目名称:Quake-III-Arena,代码行数:64,代码来源:win_gamma.c

示例11: SWimp_RestoreHWGamma

void SWimp_RestoreHWGamma()
{
	if( sw_state.hw_gamma_supported )
	{
		HDC desktop_hdc = GetDC( GetDesktopWindow() );
		SetDeviceGammaRamp( desktop_hdc, old_gamma );
		ReleaseDC( GetDesktopWindow(), desktop_hdc );
	}
}
开发者ID:Panzerschrek,项目名称:Q2PR,代码行数:9,代码来源:rw_imp.c

示例12: GLW_RestoreGamma

static void GLW_RestoreGamma()
{
	if (!glConfig.deviceSupportsGamma)
		return;

	HDC hDC = GetDC( GetDesktopWindow() );
	SetDeviceGammaRamp( hDC, s_oldHardwareGamma );
	ReleaseDC( GetDesktopWindow(), hDC );
}
开发者ID:DaTa-,项目名称:cnq3x,代码行数:9,代码来源:win_glimp.cpp

示例13: SetGammaRamp

static void APIENTRY SetGammaRamp (Uint16 *redtable, Uint16 *greentable, Uint16 *bluetable)
#endif
{
#ifndef unix
	SetDeviceGammaRamp(m_hDC, ramp);
#else
	SDL_SetGammaRamp(redtable, greentable, bluetable);
#endif
}
开发者ID:ddraigcymraeg,项目名称:gzscoredoom,代码行数:9,代码来源:r_opengl.cpp

示例14: VG_SetGamma

/*
** VG_SetGamma
**
** This routine should only be called if deviceSupportsGamma is TRUE
*/
void VG_SetGamma( unsigned char red[256], unsigned char green[256], unsigned char blue[256] )
{
	unsigned short table[3][256];
	int		i, j;
	int		ret;
	OSVERSIONINFO	vinfo;
	HDC hDC;

	hDC = GetDC(GetDesktopWindow());

	if (!deviceSupportsGamma || !hDC)
		return;

	for ( i = 0; i < 256; i++ ) {
		table[0][i] = ( ( ( unsigned short ) red[i] ) << 8 ) | red[i];
		table[1][i] = ( ( ( unsigned short ) green[i] ) << 8 ) | green[i];
		table[2][i] = ( ( ( unsigned short ) blue[i] ) << 8 ) | blue[i];
	}

	// Win2K puts this odd restriction on gamma ramps...
	vinfo.dwOSVersionInfoSize = sizeof(vinfo);
	GetVersionEx( &vinfo );
	if ( vinfo.dwMajorVersion == 5 && vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT )
	{
		ri.Con_Printf(PRINT_DEVELOPER, "performing Windows 2000 gamma clamp.\n");
		for ( j = 0 ; j < 3 ; j++ ) {
			for ( i = 0 ; i < 128 ; i++ ) {
				if ( table[j][i] > ( (128+i) << 8 ) ) {
					table[j][i] = (128+i) << 8;
				}
			}
			if ( table[j][127] > 254<<8 ) {
				table[j][127] = 254<<8;
			}
		}
	}
	else
	{
		ri.Con_Printf(PRINT_DEVELOPER, "skipping Windows 2000 gamma clamp.\n");
	}

	// enforce constantly increasing
	for ( j = 0 ; j < 3 ; j++ ) {
		for ( i = 1 ; i < 256 ; i++ ) {
			if ( table[j][i] < table[j][i-1] ) {
				table[j][i] = table[j][i-1];
			}
		}
	}

	ret = SetDeviceGammaRamp( hDC, table );
	if (!ret)
		ri.Con_Printf(PRINT_ALL, "SetDeviceGammaRamp failed.\n");

	ReleaseDC( GetDesktopWindow(), hDC );
}
开发者ID:jacqueskrige,项目名称:uqe-quake2,代码行数:61,代码来源:gl_gamma.c

示例15: setGammaRamp

void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer) {
	HDC screenDC;
	WORD *gammaRamp = (WORD *)(*env)->GetDirectBufferAddress(env, gammaRampBuffer);

	screenDC = GetDC(NULL);
	if (SetDeviceGammaRamp(screenDC, gammaRamp) == FALSE) {
		throwException(env, "Failed to set device gamma.");
	}
	ReleaseDC(NULL, screenDC);
}
开发者ID:AndroWibowo,项目名称:computer-graphics,代码行数:10,代码来源:display.c


注:本文中的SetDeviceGammaRamp函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。