예제 #1
0
WPARAM MainLoop()
{
	MSG msg;

	while(1)											// Do our infinite loop
	{													// Check if there was a message
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 
        { 
			if(msg.message == WM_QUIT)					// If the message wasn't to quit
				break;
            TranslateMessage(&msg);						// Find out what the message does
            DispatchMessage(&msg);						// Execute the message
        }
		else											// if there wasn't a message
		{ 
			// Render the scene every frame to update the rotating cube
			RenderScene();								
       } 
	}

	DestroyFont();										// This frees up our font display list									
	DeInit();											// Release memory and restore settings

	return(msg.wParam);									// Return from the program
}
예제 #2
0
void FontsDestroy(void)
{
   WORD i;

   /* Don't destroy system's stock font */
   for (i=0; i < MAXFONTS; i++)
      DestroyFont(i);
}
예제 #3
0
void
FreeLanderFont (PLANET_INFO *info)
{
	DestroyFont (info->LanderFont);
	info->LanderFont = NULL;
	DestroyDrawable (ReleaseDrawable (info->LanderFontEff));
	info->LanderFontEff = NULL;
}
예제 #4
0
/***
  * 功能:
        窗体FrmWiFi的退出函数,释放所有资源
  * 参数:
        1.void *pWndObj:    指向当前窗体对象
  * 返回:
        成功返回零,失败返回非零值
  * 备注:
***/
int FrmWiFiExit(void *pWndObj)
{
    //错误标志、返回值定义
    int iReturn = 0;
	int i = 0;

    GUIMESSAGE *pMsg = NULL;
    //得到当前窗体对象
    pFrmWiFi = (GUIWINDOW *) pWndObj;

	//清空消息队列中的消息注册项
    //***************************************************************/
    pMsg = GetCurrMessage();
    ClearMessageReg(pMsg);

    //从当前窗体中注销窗体控件
    //***************************************************************/
    ClearWindowComp(pFrmWiFi);

    //销毁窗体控件
    //***************************************************************/
    //销毁桌面背景图片
    DestroyPicture(&pWiFiBtnLeftBg);

	//销毁菜单
	DestroyPicture(&pWiFiMenuBg);

	for(i = 0;i < 5;i++)
	{
		DestroyPicture(&pWiFiMenu[i]);
		DestroyLabel(&pWiFiLblMenu[i]);
	}
	for(i = 0; i < WIFIITEM; i++)
	{
		DestroyPicture(&pWiFiItem[i]);
		DestroyLabel(&pWiFiLblItem[i]);
	}

    //销毁桌面上的控件
    DestroyPicture(&pWiFiBtnREnableOn);
	DestroyPicture(&pWiFiBtnREnableOff);
	DestroyPicture(&pWiFiBtnOnOffBg);
	DestroyPicture(&pWiFiBtnConnect);//victor

	//销毁窗体左上角窗体Label
	DestroyLabel(&pWiFiLblFrmName);
	DestroyLabel(&pWiFiLblOnOffInfo);
	DestroyLabel(&pWiFiLblConnecting);
	
	DestroyFont(&pWifiFntBlack);
	//释放文本资源
    //***************************************************************/
    WiFiTextRes_Exit(NULL, 0, NULL, 0);
	
    return iReturn;
}
예제 #5
0
static void
UninitKernel (BOOLEAN ships)
{
	UninitSpace ();

	DestroySound (ReleaseSound (MenuSounds));
	DestroyFont (MicroFont);
	DestroyStringTable (ReleaseStringTable (GameStrings));
	DestroyDrawable (ReleaseDrawable (StatusFrame));
	DestroyDrawable (ReleaseDrawable (ActivityFrame));
	DestroyFont (TinyFont);
	DestroyFont (StarConFont);

	UninitQueue (&race_q[0]);
	UninitQueue (&race_q[1]);

	if (ships)
		FreeMasterShipList ();
	
	ActivityFrame = 0;
}
예제 #6
0
//Destroy a DC object.
VOID DestroyDeviceContext(HANDLE hDC)
{
	__DC* pDC = (__DC*)hDC;

	if(pDC)
	{
		DestroyPen(pDC->pPen);
		DestroyBrush(pDC->pBrush);
		DestroyFont(pDC->pFont);
		KMemFree(pDC,KMEM_SIZE_TYPE_ANY,0);
	}
}
예제 #7
0
GLvoid Print3DFont::BuildFont(GLvoid)
{
	if (true == m_usingTex)
		m_tex.LoadTexture("mingzhuta.bmp");

	m_base = glGenLists(256);

	GenFont(); //3D字体只能显示TrueType字体!
	ApplyFont();

	wglUseFontOutlines(
		m_hDC,				//设置当前窗口设备描述表的句柄
		0,					//用于创建显示列表字体的第一个字符的ASCII值
		255,				//字符数
		m_base,				//一个显示列表的名称
		0.0f,				//字体的光滑度,越小越光滑,0.0为最光滑的状态
		0.2f,				//在z方向突出的距离
		WGL_FONT_POLYGONS,	//使用多边形来生成字符,每个顶点具有独立的法线
		m_gmf);				//一个接收字形度量数据的数组的地址,每个数组元素用它对应的显示列表字符的数据填充 

	DestroyFont();
}
예제 #8
0
/*
 * UserSelectFont:  Bring up font chooser dialog to allow user to change
 *   given font.
 */
void UserSelectFont(WORD font)
{
   CHOOSEFONT cf;
   LOGFONT newfont;

   if (font > MAXFONTS)
   {
      debug(("Illegal font #%u", font));
      return;
   }

   /* Get LOGFONT structure for current font; use default on failure */
   if (GetObject(fonts[font], sizeof(LOGFONT), &newfont) == 0)
      GetObject(hDefaultFont, sizeof(LOGFONT), &newfont);

   memset(&cf, 0, sizeof(CHOOSEFONT));
   cf.lStructSize = sizeof(CHOOSEFONT);
   cf.hwndOwner   = hMain;
   cf.lpfnHook    = ChooseFontHookProc;
   cf.lpLogFont   = &newfont;
   cf.Flags       = CF_SCREENFONTS | CF_ENABLEHOOK | CF_INITTOLOGFONTSTRUCT | CF_EFFECTS;
   if (ChooseFont(&cf) == 0)
      return;

   /* Make new font */
   DestroyFont(font);

   cf.lpLogFont->lfQuality = ANTIALIASED_QUALITY;
   SetFont(font, cf.lpLogFont);

   /* See if a module wants to intercept font change */
   if (ModuleEvent(EVENT_FONTCHANGED, font, cf.lpLogFont) == False)
      return;

   /* Update fonts on screen */
   MainChangeFont();
}
예제 #9
0
void dik_DeconstructApocalypticGarderOfEden()
// Free up memory and reset OpenGL environment.
{
	int i;

	// Free memory consumed by power up objects assigned locations.
	for(i = 0; i < NUMEFFECTS; i++)
		if(powerUpSphere[i] != NULL)
			gluDeleteQuadric(powerUpSphere[i]);

	// Free memory taken by player characters.
	for(i = 0; i < MAXPLAYERCHAINLENGTH; i++)
	{
		if(player1Chain[i] != NULL)
			gluDeleteQuadric(player1Chain[i]);
		if(player2Chain[i] != NULL)
			gluDeleteQuadric(player2Chain[i]);
		if(player3Chain[i] != NULL)
			gluDeleteQuadric(player3Chain[i]);
	}

	DisableTransparentsOGLFunctions();
	DestroyFont();
}
예제 #10
0
// Draw the full restart menu. Nothing is done with selections.
static void
DrawRestartMenuGraphic (MENU_STATE *pMS)
{
	RECT r;
	STAMP s;
	TEXT t; 
	char *Credit;
	UNICODE buf[64];

	// Re-load all of the restart menu fonts so the text shows in correct size after changing the resolution.
	if (optRequiresRestart || !PacksInstalled()) {	
		DestroyFont (TinyFont);
		DestroyFont (PlyrFont);
		DestroyFont (StarConFont);
	}	

	// DC: Load the different menus and fonts depending on the resolution factor	
	switch (resolutionFactor){
		case 1:
			if (optRequiresRestart || !PacksInstalled()) {
				TinyFont = LoadFont (TINY_FALLBACK_TO2X_FONT);
				PlyrFont = LoadFont (PLYR_FALLBACK_TO2X_FONT);
				StarConFont = LoadFont (SCON_FALLBACK_TO2X_FONT);
			}
			pMS->CurFrame = CaptureDrawable (LoadGraphic (RESTART_PMAP_ANIM2x));
			break;
		case 2:
			if (optRequiresRestart || !PacksInstalled()) {
				TinyFont = LoadFont (TINY_FALLBACK_TO4X_FONT);
				PlyrFont = LoadFont (PLYR_FALLBACK_TO4X_FONT);
				StarConFont = LoadFont (SCON_FALLBACK_TO4X_FONT);
			}
			pMS->CurFrame = CaptureDrawable (LoadGraphic (RESTART_PMAP_ANIM4x));
			break;
		case 0:
		default:
			if (optRequiresRestart || !PacksInstalled()) {
				TinyFont = LoadFont (TINY_FALLBACK_TO1X_FONT);
				PlyrFont = LoadFont (PLYR_FALLBACK_TO1X_FONT);
				StarConFont = LoadFont (SCON_FALLBACK_TO1X_FONT);
			}
			pMS->CurFrame = CaptureDrawable (LoadGraphic (RESTART_PMAP_ANIM));
			break;
	}

	s.frame = pMS->CurFrame;
	GetFrameRect (s.frame, &r);
	s.origin.x = (SCREEN_WIDTH - r.extent.width) >> 1;
	s.origin.y = (SCREEN_HEIGHT - r.extent.height) >> 1;
	
	SetContextBackGroundColor (BLACK_COLOR);
	BatchGraphics ();
	ClearDrawable ();
	FlushColorXForms ();
	DrawStamp (&s);

	// Put the version number in the bottom right corner.
	SetContextFont (TinyFont);
	t.pStr = buf;
	t.baseline.x = SCREEN_WIDTH - RES_SCALE(2);
	t.baseline.y = SCREEN_HEIGHT - RES_SCALE(2);
	t.align = ALIGN_RIGHT;
	t.CharCount = (COUNT)~0;
	sprintf (buf, "v%d.%d.%d %s", UQM_MAJOR_VERSION, UQM_MINOR_VERSION, UQM_PATCH_VERSION, UQM_EXTRA_VERSION);
	SetContextForeGroundColor (WHITE_COLOR);
	font_DrawText (&t);

	// Put the main menu music credit in the bottom left corner.
	memset(&buf[0], 0, sizeof(buf));
	t.baseline.x = RES_SCALE(2);
	t.baseline.y = SCREEN_HEIGHT - RES_SCALE(2);
	t.align = ALIGN_LEFT;
	Credit = (Rando == 0 ? "Saibuster" : (Rando == 1 ? "Rush AX" : "Mark Vera"));
	sprintf (buf, "Main Menu Music by %s", Credit);
	font_DrawText (&t);

	UnbatchGraphics ();
}
예제 #11
0
// Draw the full restart menu. Nothing is done with selections.
static void
DrawRestartMenuGraphic (MENU_STATE *pMS)
{
	RECT r;
	STAMP s;
	TEXT t;
	UNICODE buf[64];
	COUNT svn_revision = 0; // JMS

	//DC: Load the different menus depending on the resolution factor
	if (resolutionFactor < 1)
		s.frame = CaptureDrawable (LoadGraphic (RESTART_PMAP_ANIM));
	if (resolutionFactor == 1)
		s.frame = CaptureDrawable (LoadGraphic (RESTART_PMAP_ANIM2x));
	if (resolutionFactor > 1)
		s.frame = CaptureDrawable (LoadGraphic (RESTART_PMAP_ANIM4x));

	// Re-load the info box font so the text shows in correct size after changing the resolution.
	if (resFactorWasChanged)
	{	
		DestroyFont (StarConFont);
		
		if (resolutionFactor < 1)
			StarConFont = LoadFont (FALLBACK_TO1X_FONT);
		if (resolutionFactor == 1)
			StarConFont = LoadFont (FALLBACK_TO2X_FONT);
		if (resolutionFactor > 1)
			StarConFont = LoadFont (FALLBACK_TO4X_FONT);
	}
	
	pMS->CurFrame = s.frame;
	GetFrameRect (s.frame, &r);
	s.origin.x = (SCREEN_WIDTH - r.extent.width) >> 1;
	s.origin.y = (SCREEN_HEIGHT - r.extent.height) >> 1;
	
	SetContextBackGroundColor (BLACK_COLOR);
	BatchGraphics ();
	ClearDrawable ();
	FlushColorXForms ();
	LockMutex (GraphicsLock);
	DrawStamp (&s);

	// JMS: Hack for printing out the correct SVN revision number.
	{
		UNICODE svn_buf[64] = {0};
		char *colonPtr;
		
		strcpy(svn_buf, UQMHD_SVN_REVISION);
		colonPtr = strchr(svn_buf, ':');
		
		// The revision number is in format rXXX
		if (colonPtr == NULL)
		{
			// Let's just take the only number and be happy.
			svn_revision = atoi(svn_buf);
		}
		// the revision number is in format rXXX:ZZZ
		else
		{
			// Now we need to extract only the ZZZ number.
			UNICODE svn_buf2[10];
			strcpy(svn_buf2, colonPtr+1);
			svn_revision = atoi(svn_buf2);
		}
		
		// Think about this for a while ;)
		++svn_revision;
	}
	
	// Put the version number in the bottom right corner.
	SetContextFont (TinyFont);
	t.pStr = buf;
	t.baseline.x = SCREEN_WIDTH - 3;
	t.baseline.y = SCREEN_HEIGHT - 2;
	t.align = ALIGN_RIGHT;
	t.CharCount = (COUNT)~0;
	sprintf (buf, "v%d.%d.%d%s - SVN r%d", UQM_MAJOR_VERSION, UQM_MINOR_VERSION, UQM_PATCH_VERSION, UQM_EXTRA_VERSION, svn_revision);
	SetContextForeGroundColor (WHITE_COLOR);
	font_DrawText (&t);

	UnlockMutex (GraphicsLock);
	UnbatchGraphics ();
}
예제 #12
0
//Create a DC object.
HANDLE CreateDeviceContext(DWORD dwDCType,HANDLE hDevice,HANDLE hWnd,__REGION* pRegion)
{
	__DC* pDC         = NULL;
	HANDLE hPen       = NULL;
	HANDLE hBrush     = NULL;
	HANDLE hFont      = NULL;
	BOOL   bResult    = FALSE;
	__WINDOW* pWnd    = (__WINDOW*)hWnd;
	
	if(NULL == hDevice)
	{
		return NULL;
	}
	pDC = (__DC*)KMemAlloc(sizeof(__DC),KMEM_SIZE_TYPE_ANY);
	if(NULL == pDC) //Can not allocate memory.
	{
		goto __TERMINAL;
	}
	//Now create pen,font,brush objects.
	hPen = CreatePen(0,1,COLOR_BLACK);
	if(NULL == hPen)
	{
		goto __TERMINAL;
	}
	hFont = CreateFont(DEFAULT_FONT_WIDTH,DEFAULT_FONT_HEIGHT,
		DEFAULT_FONT_CHSPACE,DEFAULT_FONT_LNSPACE);
	if(NULL == hFont)
	{
		goto __TERMINAL;
	}
	hBrush = CreateBrush(FALSE,pWnd->clrBackground);
	if(NULL == hBrush)
	{
		goto __TERMINAL;
	}

	//Initialize DC object.
	pDC->dwDCType = dwDCType;
	pDC->pBrush   = (__BRUSH*)hBrush;
	pDC->pFont    = (__FONT*)hFont;
	pDC->hWindow  = hWnd;
	pDC->pPen     = (__PEN*)hPen;
	pDC->pRegion  = pRegion;
	if(dwDCType | DC_TYPE_SCREEN)
	{
		pDC->pVideo = (__VIDEO*)hDevice;
	}
	else
	{
		pDC->hOther = hDevice;
	}
	bResult = TRUE;
__TERMINAL:
	if(!bResult)
	{
		if(pDC)
		{
			KMemFree(pDC,KMEM_SIZE_TYPE_ANY,0);
		}
		if(hPen)
		{
			DestroyPen(hPen);
		}
		if(hBrush)
		{
			DestroyBrush(hBrush);
		}
		if(hFont)
		{
			DestroyFont(hFont);
		}
		pDC = NULL;
	}
	return (HANDLE)pDC;
}
예제 #13
0
LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	static HGLRC hRC;
	HDC hDC = NULL;
	int width, height;
	int x_screenLocation, y_screenLocation;
	static bool isMenu = true;

	const char RESHEADER[] = "Resolution";
	const char RESSAVEDHEADER[] = "Resolution Save...";
	const char RESWRTFAIL[] = "Game needs to be run from hard drive or other writeable media.";

	switch(message) {
		case WM_CREATE:
			hDC = GetDC(hwnd);			
			g_HDC = hDC;
			SetupPixelFormat(hDC);		
			hRC = wglCreateContext(hDC);
			wglMakeCurrent(hDC, hRC);

			// Initialise sphere chain to avoid crashes.
			for(counter = 0; counter < CHAINMAXLENGTH; counter++)
				ASphere[counter] = NULL;
			break;
		case WM_KEYDOWN:
			switch(wParam)
			{
				case VK_ESCAPE:
					switch(iFeatureIsInitialised)
					{
						case 1:
						case 2:
						case 3:
						case 4:
						case 5:
							currentMenu = 2;
							PostMessage(hwnd, ID_GAME_MENU, wParam, lParam);
							break;
						case 6:
						case 7:
						case 8:
							currentMenu = 3;
							PostMessage(hwnd, ID_GAME_MENU, wParam, lParam);
							break;
						case 9:
							currentMenu = 0;
							PostMessage(hwnd, ID_GAME_MENU, wParam, lParam);
							break;
						default:
							break;
					}
					break;
				case VK_F1:
					if(!isMenu)
					{
						if(WriteResFile(640, 480))
							MessageBox(NULL, "Game will now play at 640 x 480 resolution.", RESHEADER, MB_OK);
						else
							MessageBox(NULL, RESWRTFAIL, RESSAVEDHEADER, MB_OK);
						if(!CheckCurrentResolution(640, 480))
							ChangeScreenResolution(640, 480);
					}
					break;
				case VK_F2:
					if(!isMenu)
					{
						if(WriteResFile(800, 600))
							MessageBox(NULL, "Game will now play at 800 x 600 resolution.", RESHEADER, MB_OK);
						else
							MessageBox(NULL, RESWRTFAIL, RESSAVEDHEADER, MB_OK);
						if(!CheckCurrentResolution(800, 600))
							ChangeScreenResolution(800, 600);
					}
					break;
				case VK_F3:
					if(!isMenu)
					{
						if(WriteResFile(1024, 768))
							MessageBox(NULL, "Game will now play at 1024 x 768 resolution.", RESHEADER, MB_OK);
						else
							MessageBox(NULL, RESWRTFAIL, RESSAVEDHEADER, MB_OK);
						if(!CheckCurrentResolution(1024, 768))
							ChangeScreenResolution(1024, 768);
					}
					break;
				case VK_F4:
					if(!isMenu)
					{
						if(WriteResFile(1280, 1024))
							MessageBox(NULL, "Game will now play at 1280 x 1024 resolution.", RESHEADER, MB_OK);
						else
							MessageBox(NULL, RESWRTFAIL, RESSAVEDHEADER, MB_OK);
						if(!CheckCurrentResolution(1280, 1024))
							ChangeScreenResolution(1280, 1024);
					}
					break;
				default:
					break;
			}
			break;
		case WM_LBUTTONDOWN:
			Sleep(400);			// Retains mouse coords for 2/5 of a second to prevent filtering through to last menu.
			x_screenLocation = LOWORD(lParam); y_screenLocation = HIWORD(lParam);
			g_x_region = x_screenLocation; g_y_region = y_screenLocation;
			g_wParam = wParam; g_lParam = lParam;
			break;
		case ID_GAME_MENU:
			if(!CheckCurrentResolution(800, 600) && !windowed)
				ChangeScreenResolution(800, 600);
			DisablePriorOpenGLCommands();
			PlaySound(NULL, NULL, SND_NODEFAULT); // Stop previous sound!
			InitialiseAGUIMenu();
			PlayMenuMusic();
			iFeatureIsInitialised = 0;
			ShowCursor(true);
			isMenu = true;
			break;
		case SPHR_STANDARD:
			if(!windowed)
				FetchResolution();
			DisablePriorOpenGLCommands();
			dik_BuildStandardSphereChain();
			PlayStandardMusic();
			iFeatureIsInitialised = 1;
			ShowCursor(false);
			isMenu = false;
			break;
		case SPHR_SUPBLAST:
			if(!windowed)
				FetchResolution();
			DisablePriorOpenGLCommands();
			dik_BuildSphereChainWithPowerUp(0.0f, 0.0f, 0.7f, "supblast.bmp");
			PlaySupremeBlastMusic();
			iFeatureIsInitialised = 2;
			ShowCursor(false);
			isMenu = false;
			break;
		case SPHR_REBIRTH:
			if(!windowed)
				FetchResolution();
			DisablePriorOpenGLCommands();
			dik_BuildSphereChainWithPowerUp(0.7f, 0.0f, 0.0f, "rebirth.bmp");
			PlayRebirthMusic();
			iFeatureIsInitialised = 3;
			ShowCursor(false);
			isMenu = false;
			break;
		case SPHR_SBREBTH:
			if(!windowed)
				FetchResolution();
			DisablePriorOpenGLCommands();
			dik_BuildSphereChainWithPowerUp(0.7f, 0.0f, 0.7f, "sbrebirth.bmp");
			PlaySupaFlyMusic();
			iFeatureIsInitialised = 4;
			ShowCursor(false);
			isMenu = false;
			break;
		case SPHR_INVISIBL:
			if(!windowed)
				FetchResolution();
			DisablePriorOpenGLCommands();
			dik_BuildSphereChainWithPowerUp(0.7f, 0.0f, 0.7f, "invisibility.bmp");
			PlayInvisibilityMusic();
			iFeatureIsInitialised = 5;
			ShowCursor(false);
			isMenu = false;
			break;
		case PU_SUPBLAST:
			if(!windowed)
				FetchResolution();
			DisablePriorOpenGLCommands();
			dik_BuildPowerUp("supblast.bmp");
			PlaySupremeBlastMusic();
			iFeatureIsInitialised = 6;
			ShowCursor(false);
			isMenu = false;
			break;
		case PU_REBIRTH:
			if(!windowed)
				FetchResolution();
			DisablePriorOpenGLCommands();
			dik_BuildPowerUp("rebirth.bmp");
			PlayRebirthMusic();
			iFeatureIsInitialised = 7;
			ShowCursor(false);
			isMenu = false;
			break;
		case PU_INVISIBL:
			if(!windowed)
				FetchResolution();
			DisablePriorOpenGLCommands();
			dik_BuildPowerUp("invisibility.bmp");
			PlayInvisibilityMusic();
			iFeatureIsInitialised = 8;
			ShowCursor(false);
			isMenu = false;
			break;
		case ENV_PAGOE:
			if(!windowed)
				FetchResolution();
			DisablePriorOpenGLCommands();
			dik_InitialisePostApocalypticGarderOfEden();
			PlayPAGoEMusic();
			iFeatureIsInitialised = 9;
			ShowCursor(false);
			isMenu = false;
			break;
		case WM_SIZE:
			height = HIWORD(lParam);
			width = LOWORD(lParam);

			if(height == 0)				
				height = 1;
			
			glViewport(0, 0, width, height);
			glMatrixMode(GL_PROJECTION);	
			glLoadIdentity();			
			
			gluPerspective(54.0f, (GLfloat) width/(GLfloat) height, 1.0f, 3000.0f);

			glMatrixMode(GL_MODELVIEW);	
			glLoadIdentity();			

			return 0;
			break;
		case WM_DESTROY:
			CleanUpLoadTextures();
			FreeChainMemory();
			DeleteDirectSoundResources();
			DeleteDirectInputResources();
			DisablePriorOpenGLCommands();
			DestroyFont();
			wglMakeCurrent(hDC, NULL);
			wglDeleteContext(hRC);
			PostQuitMessage(0);
			break;
		case WM_QUIT:			
			DestroyWindow(hwnd);	
			break;
		default:
			return DefWindowProc(hwnd, message, wParam, lParam);
			break;
	}
	return DefWindowProc(hwnd, message, wParam, lParam);
}