📄 graphics.cpp
字号:
//___________________________________________________________________
#include "graphics.h"
//___________________________________________________________________
void GLGraphics::WindowMove( HWND hwnd )
{
#ifndef USE_FULLSCREEN
if (!image) return;
RECT testArea;
int xOffset, yOffset;
testArea.left = 0;
testArea.right = 0;
testArea.top = 0;
testArea.bottom = 0;
AdjustWindowRectEx (&testArea, GetWindowLong( hwnd, GWL_STYLE ), FALSE, NULL);
xOffset = -testArea.left;
yOffset = -testArea.top;
GetWindowRect( hwnd, &testArea );
xOffset += testArea.left;
yOffset += testArea.top;
image -> MoveFrontWindow( xOffset, yOffset );
#endif
}
/*
Return:
7 - can not setup 3dr
*/
GLint GLGraphics::Setup (HWND hwnd, GLint width, GLint height, GLint depth)
{
#ifdef USE_FULLSCREEN
BOOL fullscreen = TRUE;
#else
BOOL fullscreen = FALSE;
#endif
// set up the device and image buffer
//___________________________________________________________________
devmgr.Setup();
int DeviceNumber = devmgr.ChooseDevice();
device = devmgr.GetDevice( DeviceNumber, width, height, fullscreen, TRUE, hwnd );
image = device->GetImageBuffer();
// set up 3dr
//___________________________________________________________________
if (!context.Setup( (DWORD)image -> targetSurface(),
(DWORD)image -> GetDisplayDevice()->GetMPRdevice() ) ) {
return 7;
}
return 0; // successful
}
void GLGraphics::Cleanup ()
{
context.Cleanup();
devmgr.ReleaseDevice( device );
devmgr.Cleanup();
}
void GLGraphics::StartFrame (GLint zflag)
{
context.StartFrame( image -> targetSurface() );
if (zflag)
context.ClearBuffers (MPR_CI_DRAW_BUFFER | MPR_CI_ZBUFFER);
else context.ClearBuffers (MPR_CI_DRAW_BUFFER);
}
void GLGraphics::FlipBuffer ()
{
context.FinishFrame( image -> targetSurface(), NULL);
image -> SwapBuffers(context.rc);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -