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


C++ CDisplay::IOCtl方法代码示例

本文整理汇总了C++中CDisplay::IOCtl方法的典型用法代码示例。如果您正苦于以下问题:C++ CDisplay::IOCtl方法的具体用法?C++ CDisplay::IOCtl怎么用?C++ CDisplay::IOCtl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDisplay的用法示例。


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

示例1: Go

bool CGUI::Go()
{
	bool Fullscreen;
	/* restrict display */
	CDisplay *Disp = (CDisplay *)PPool->GetWellDefinedComponent(COMPONENT_DISPLAY);
	SDL_Surface *Front;

	/* map resources, installing palette, etc */

	/* get screen dimensions, generate two intermediate buffers */
	int ScrW, ScrH;

	Disp->IOCtl(DISPIOCTL_GETDBUF, this, 0);

	Front = Disp->GetFrontBuffer();
	ScrW = Front->w; ScrH = Front->h;
	Fullscreen = (Front->flags&SDL_FULLSCREEN) ? true : false;
	Disp->ReleaseFrontBuffer();

	StaticBuffer = OptimalSurface(ScrW, ScrH);

	MapResources();

	// prepare display
	SDL_Rect WholeDisplay;
	WholeDisplay.x = WholeDisplay.y = 0;
	WholeDisplay.w = ScrW; WholeDisplay.h = ScrH;
	GUIObject = new CGUIMainDlg(*this, StaticBuffer, WholeDisplay);

	MessagesPending = 0;
	MessageQueue = new CGUIMessage[16];

	int MouseX, MouseY, BState;
	BState = SDL_GetMouseState(&MouseX, &MouseY);

	QMessage = false;
	Quit = false;
	bool HaveMouse = true;
	while(!Quit)
	{
		// refresh buffer bwith all static elements
		Front = Disp->GetFrontBuffer();
		SDL_BlitSurface(StaticBuffer, NULL, Front, NULL);
		
		// get mouse state
		int NewMouseX, NewMouseY, NewBState;
		NewBState = SDL_GetMouseState(&NewMouseX, &NewMouseY);

		// draw display
		CGUIMessage DrawMessage;
		DrawMessage.Type = CGUIMessage::DRAW;
		DrawMessage.PositionX = 0; DrawMessage.PositionY = 0;
		DrawMessage.Data.Draw.Target = Front;
		GUIObject->Message(&DrawMessage);

		// add cursor if necessary
		if(	(SDL_ShowCursor(SDL_QUERY) != SDL_ENABLE) &&
			((SDL_GetAppState()&SDL_APPMOUSEFOCUS) || Fullscreen))
			AddGraphic(Front, GFX_CURSOR, NewMouseX, NewMouseY);

		// communicate mouse movements
		CGUIMessage MouseMessage;
		MouseMessage.PositionX = NewMouseX;
		MouseMessage.PositionY = NewMouseY;
		MouseMessage.Buttons = NewBState;
		MouseMessage.Data.Mouse.DeltaX = NewMouseX - MouseX;
		MouseMessage.Data.Mouse.DeltaY = NewMouseY - MouseY;
		MouseMessage.Type = CGUIMessage::MOUSEOVER;
		GUIObject->Message(&MouseMessage);

		MouseX = NewMouseX; MouseY = NewMouseY;

		// communicate button changes
		NewBState ^= BState; BState ^= NewBState;
		if(NewBState)
		{
			MouseMessage.Type = CGUIMessage::BUTTONS;
			MouseMessage.Data.Button.Changes = NewBState;
			GUIObject->Message(&MouseMessage);
		}

		// blit display, check it hasn't changed
//		SDL_BlitSurface(DisplayBuffer, NULL, Front, NULL);
		SDL_UpdateRect(Front, 0, 0, 0,0);
		Disp->ReleaseFrontBuffer();
		Disp->IOCtl(DISPIOCTL_FLIP, NULL, 0);

		// pump events
		SDL_PumpEvents();

		// post any pending messages
		while(MessagesPending--)
			GUIObject->Message(&MessageQueue[MessagesPending]);
		MessagesPending = 0;

		// get latest interesting keys, etc
		((CULA *)(PPool->GetWellDefinedComponent(COMPONENT_ULA)))->UpdateKeyTable();

		SDL_Event ev;
		while(SDL_PollEvent(&ev))
//.........这里部分代码省略.........
开发者ID:TomHarte,项目名称:ElectrEm,代码行数:101,代码来源:GUI.cpp


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