本文整理汇总了C++中LPDIRECTDRAW7::GetDisplayMode方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAW7::GetDisplayMode方法的具体用法?C++ LPDIRECTDRAW7::GetDisplayMode怎么用?C++ LPDIRECTDRAW7::GetDisplayMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTDRAW7
的用法示例。
在下文中一共展示了LPDIRECTDRAW7::GetDisplayMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vdraw_ddraw_init
/**
* vdraw_ddraw_init(): Initialize the DirectDraw video subsystem.
* @return 0 on success; non-zero on error.
*/
int vdraw_ddraw_init(void)
{
DDSURFACEDESC2 ddsd;
vdraw_ddraw_end();
mdp_render_t *rendMode = get_mdp_render_t();
const int scale = rendMode->scale;
// Determine the window size using the scaling factor.
if (scale <= 0)
return -1;
const int w = 320 * scale;
const int h = 240 * scale;
if (vdraw_get_fullscreen())
{
Res_X = w;
Res_Y = h;
}
// Return value.
int rval;
// Initialize DirectDraw.
// TODO: Initialize DirectDraw on the monitor with most of Gens/GS onscreen.
LPDIRECTDRAW lpDD_Init;
rval = DirectDrawCreate(NULL, &lpDD_Init, NULL);
if (FAILED(rval))
{
LOG_MSG(video, LOG_MSG_LEVEL_ERROR,
"DirectDrawCreate() failed: 0x%08X", rval);
return -2;
}
rval = lpDD_Init->QueryInterface(IID_IDirectDraw7, (LPVOID*)&lpDD);
if (FAILED(rval))
{
if (lpDD_Init)
lpDD_Init->Release();
LOG_MSG(video, LOG_MSG_LEVEL_ERROR,
"lpDD_Init->QueryInterface(IID_IDirectDraw4) failed: 0x%08X", rval);
LOG_MSG(video, LOG_MSG_LEVEL_ERROR,
"This can usually be fixed by upgrading DirectX.");
return -3;
}
// Free the DirectDraw initialization object.
lpDD_Init->Release();
// Set the cooperative level.
vdraw_ddraw_set_cooperative_level();
// TODO: 15-bit color override. ("Force 555" or "Force 565" in the config file.)
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
// TODO: Figure out what FS_No_Res_Change is for.
// TODO: Figure out if this is correct.
if (vdraw_get_fullscreen() /* && !FS_No_Res_Change*/)
{
// Use the color depth setting.
// NOTE: "15-bit" color requires 16-bit to be specified.
rval = lpDD->SetDisplayMode(Res_X, Res_Y, (bppOut == 15 ? 16 : bppOut), 0, 0);
if (FAILED(rval))
{
vdraw_ddraw_free_all(false);
LOG_MSG(video, LOG_MSG_LEVEL_ERROR,
"lpDD->SetDisplayMode() failed: 0x%08X", rval);
// If render mode is set to Normal, try using Double instead.
if (rendMode_FS == RenderMgr::begin() && rendMode_FS != RenderMgr::end())
{
LOG_MSG(video, LOG_MSG_LEVEL_ERROR,
"Renderer is set to Normal; attempting to use Double instead.");
rendMode_FS++;
vdraw_set_renderer(rendMode_FS);
vdraw_text_write("Normal rendering failed. Using Double.", 1500);
Sync_Gens_Window_GraphicsMenu();
}
return -4;
}
}
#if 0
// Check the current color depth.
unsigned char newBpp;
lpDD->GetDisplayMode(&ddsd);
switch (ddsd.ddpfPixelFormat.dwGBitMask)
{
case 0x03E0:
// 15-bit color.
newBpp = 15;
break;
//.........这里部分代码省略.........
示例2: dx_Initialise
//-----------------------------------------------------------------------------
// Name: dx_Initialise (...)
// Desc: Initialise et configure DirectX (DirectDraw)
//-----------------------------------------------------------------------------
bool dx_Initialise (uint8 pNombreSurfaces,
HWND pFenetre,
uint16 pResolutionX,
uint16 pResolutionY,
uint16 pBitsParPixel,
uint16 pFrequence,
bool pPleinEcran,
bool pTailleFenetre,
void (*pRestaure)())
{
// InitialiseDX a déjà été appelé
if (DirectDraw7 != NULL) {
return dx_Finalise (ERR_NO_UTILISATEUR);
}
dx_InitVars ();
// Initialise toutes les variables
Fenetre = pFenetre;
NombreSurfaces = pNombreSurfaces;
ResolutionX = pResolutionX;
ResolutionY = pResolutionY;
BitsParPixel = pBitsParPixel;
Frequence = pFrequence;
PleinEcran = pPleinEcran;
TailleFenetre = pTailleFenetre;
Restaure = pRestaure;
Surfaces = new LPDIRECTDRAWSURFACE7[NombreSurfaces];
// Initialisation de directdraw
ErrDd = DirectDrawCreateEx (0,(LPVOID*)&DirectDraw7,IID_IDirectDraw7,0);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_CREATION);
ModeCoop = PleinEcran ? COOP_PLEIN_ECRAN : COOP_FENETRE;
// Utilisation de la résolution active ou donnée
if (ResolutionX == 0 || ResolutionY == 0 ||
BitsParPixel == 0 || Frequence == 0)
{
DDSURFACEDESC2 ModeActif;
ZeroMemory (&ModeActif, sizeof(ModeActif));
ModeActif.dwSize = sizeof(ModeActif);
ErrDd = DirectDraw7->GetDisplayMode (&ModeActif);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_MODE_ACTIF);
if (ResolutionX == 0) ResolutionX = ModeActif.dwWidth;
if (ResolutionY == 0) ResolutionY = ModeActif.dwHeight;
if (BitsParPixel == 0) BitsParPixel = ModeActif.
ddpfPixelFormat.dwRGBBitCount;
if (Frequence == 0) Frequence = ModeActif.dwRefreshRate;
}
// Sélection du mode de coopération
ErrDd = DirectDraw7->SetCooperativeLevel (Fenetre, ModeCoop);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_COOPERATION);
ErrDd = DirectDraw7->SetDisplayMode (ResolutionX,
ResolutionY,BitsParPixel,0,0);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_MODE_AFFICHAGE);
// Création des surfaces d'affichage
SurfaceDesc.dwFlags = DDSD_CAPS;
SurfaceDesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (PleinEcran)
{ // Surface avec backbuffer
SurfaceDesc.dwFlags |= DDSD_BACKBUFFERCOUNT;
SurfaceDesc.ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX;
SurfaceDesc.dwBackBufferCount = 1;
}
ErrDd = DirectDraw7->CreateSurface (&SurfaceDesc,&SurfacePrimaire,NULL);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_PRIMAIRE);
if (PleinEcran)
{
SurfaceCaps.dwCaps = DDSCAPS_BACKBUFFER;
ErrDd = SurfacePrimaire->GetAttachedSurface (&SurfaceCaps,&SurfaceBack);
//.........这里部分代码省略.........