Ejemplo n.º 1
0
void dd_Close()
{
	std::vector<dd_Window*> deletes;
	for(std::vector<dd_Window*>::iterator it = dd_windows.begin(); it != dd_windows.end(); it++)
		deletes.push_back(*it);

	for(std::vector<dd_Window*>::iterator it = deletes.begin(); it != deletes.end(); it++)
		(*it)->dispose();

	DX_RELEASE(dx_ps);
	DX_RELEASE(dx_win_ps);
	DX_RELEASE(dx_dd);
}
Ejemplo n.º 2
0
/*!
@brief フォントを解放する。
@par   関数説明
生成したフォントを解放する。
@return 0を返す。
*/
int DirectXDraw9::FontCleanUp( void )
{
	unsigned int f;

	for ( f = 0; f < fontmax; ++f )
	{
		DX_RELEASE( fontdata[ f ].D3DFont );
	}

	return 0;
}
Ejemplo n.º 3
0
bool Texture::clearTexture() 
{
	DX_RELEASE(pTexture);
	return true;
}
Ejemplo n.º 4
0
void GraphicsDevice::shutdown() 
{
	DX_RELEASE(pSprite); 
	DX_RELEASE(pd3dDevice);
	DX_RELEASE(pd3d);
}
Ejemplo n.º 5
0
//////////////////////////////////////////////////////////////////////////////////
/// Frees the Font object.
void Font::freeFont()
{
	DX_RELEASE(pFont);
}
Ejemplo n.º 6
0
//must be the game window
int dd_Window::set_fullscreen(int w, int h, int bpp)
{
	_ASSERTE(bGameWindow);

	quad ws;
	HRESULT hr;


	DX_RELEASE(dx_os);
	DX_RELEASE(dx_ps);
	DX_RELEASE(dx_win_ps);

	hr = dx_dd->SetCooperativeLevel(hMainWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
	if (hr != DD_OK)
	{
		return 0;
	}

	//hack for 320x200 letterboxing
	if(w == 320 && h == 200)
		dx_dd->SetDisplayMode(320, 240, bpp);
	else
		dx_dd->SetDisplayMode(w, h, bpp);


	hr = dx_dd->CreateSurface(&dx_psd, &dx_ps, NULL);
	if (hr != DD_OK)
	{
		return 0;
	}


	dx_osd.dwWidth=w;
	dx_osd.dwHeight=h;
	hr=dx_dd->CreateSurface(&dx_osd,&dx_os,NULL);
	if(hr!=DD_OK)
	{
		return 0;
	}
	hr = dx_ps->GetAttachedSurface(&dx_bsd.ddsCaps, &dx_bs);
	if (hr != DD_OK)
	{
		DX_RELEASE(dx_os);
		return 0;
	}

	ws = GetWindowLong(hwnd, GWL_STYLE);
	ws &= ~WS_OVERLAPPEDWINDOW;
	ws |= WS_POPUP;
	SetWindowLong(hwnd, GWL_STYLE, ws);
	SetWindowPos(hwnd,0,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED | SWP_NOZORDER);

	//make window take up entire screen
	//choose one or the other
	//SetWindowPos(hwnd,0,0,0,w,h,SWP_NOACTIVATE | SWP_NOZORDER);
	ShowWindow(hwnd,SW_SHOWMAXIMIZED);

	//set pixelformat parameters
	{
		DDPIXELFORMAT ddpf;
		ddpf.dwSize = sizeof(ddpf);
		ddpf.dwFlags = DDPF_RGB;
		hr = dx_ps->GetPixelFormat(&ddpf);
		if (hr != DD_OK) err("Could not get pixel format!");
		//if (ddpf.dwRBitMask == 0x7C00 && bpp == 16)
		//	vid_bpp = 15, vid_bytesperpixel = 2;
		//else
		//	vid_bpp = bpp, vid_bytesperpixel = bpp / 8;
		vid_bpp = 32;
	}


	if(img) delete img;
	img = new image();
	img->shell = true;

	SetHandleImage(1,img);
	screen = img;

//	img->alphamap = 0;
	img->width = w;
	img->height = h;
	img->cx1 = 0;
	img->cx2 = w-1;
	img->cy1 = 0;
	img->cy2 = h-1;
	img->data=0;

	flip_fullscreen();

	return 1;
}
Ejemplo n.º 7
0
int dd_Window::set_win(int w, int h, int bpp)
{
//	RECT r, r2;
	HRESULT hr;

	shutdown_win();

	dx_win_bsd.dwWidth = w;
	dx_win_bsd.dwHeight = h;
	hr = dx_dd->CreateSurface(&dx_win_bsd, &dx_win_bs, NULL);
	if (hr != DD_OK)
	{
		return 0;
	}
	hr = dx_win_bs->Lock(0, &dx_win_bsd, 0, 0);
	if (hr != DD_OK)
	{
		DX_RELEASE(dx_win_bs);
		return 0;
	}
	dx_win_bs->Unlock(0);
	hr = dx_dd->CreateClipper(0, &clipper, 0);
	if (hr != DD_OK)
	{
		DX_RELEASE(dx_win_bs);
		return 0;
	}
	hr = clipper->SetHWnd(0, hwnd);
	if (hr != DD_OK)
	{
		DX_RELEASE(dx_win_bs);
		DX_RELEASE(clipper);
		return 0;
	}

	if(bGameWindow)
	{
		int ws = GetWindowLong(hwnd,GWL_STYLE);
		ws &= ~WS_POPUP;
		ws |= WS_OVERLAPPEDWINDOW | WS_THICKFRAME;
		SetWindowLong(hwnd, GWL_STYLE, ws);
	}

	//set pixelformat parameters
	//if(bGameWindow)
	//{
	//	DDPIXELFORMAT ddpf;
	//	ddpf.dwSize = sizeof(ddpf);
	//	ddpf.dwFlags = DDPF_RGB;
	//	hr = dx_win_ps->GetPixelFormat(&ddpf);
	//	if (hr != DD_OK) err("Could not get pixel format!");
	//	//if (ddpf.dwRBitMask == 0x7C00 && bpp == 16)
	//	//	vid_bpp = 15, vid_bytesperpixel = 2;
	//	//else
	//	//	vid_bpp = bpp, vid_bytesperpixel = bpp / 8;
	//}

	delete img;
	img = new image();
	img->width = w;
	img->height = h;
	img->cx1 = 0;
	img->cx2 = w-1;
	img->cy1 = 0;
	img->cy2 = h-1;
	
	if(vid_bpp == DesktopBPP) {
		img->shell = true;
		img->data = (quad*)dx_win_bsd.lpSurface;
		img->pitch = dx_win_bsd.lPitch / vid_bytesperpixel;
	} else {
		img->alloc_data();
	}

	SetHandleImage(imgHandle,img);
	if(bGameWindow)
	{
		SetHandleImage(1,img);
		screen = img;
	}
	

	return 1;
}
Ejemplo n.º 8
0
void dd_Window::shutdown_win()
{
	DX_RELEASE(dx_win_bs);
}
Ejemplo n.º 9
0
int dd_SetMode(int xres, int yres, int bpp, bool windowflag)
{
	HRESULT hr;

	if (!dd_initd)
		dd_init();

	//do this now for the gamewindow, because this is the first time we know what size to make the gamewindow
	if(!dd_bGameWindowRectInitialized)
	{
		RECT r;
		dd_gameWindow->adjust(xres,yres,&r);

		int base_win_x_res = getInitialWindowXres();
		int base_win_y_res = getInitialWindowYres();

		/// this is for the windowsize verge.cfg vars.
		if( base_win_x_res > 0 && base_win_y_res > 0 ) {
			int win_offset_x = (r.right-r.left) - xres;
			int win_offset_y = (r.bottom-r.top) - yres;

			dd_gameWindow->winw = win_offset_x+base_win_x_res;
			dd_gameWindow->winh = win_offset_y+base_win_y_res;
		
		} else {
			dd_gameWindow->winw = r.right-r.left;
			dd_gameWindow->winh = r.bottom-r.top;
		}

		WINDOWPLACEMENT wp;
		wp.length = sizeof(WINDOWPLACEMENT);
		GetWindowPlacement(dd_gameWindow->hwnd,&wp);
		wp.rcNormalPosition.left = GetSystemMetrics(SM_CXSCREEN)/2-xres/2;
		wp.rcNormalPosition.top = GetSystemMetrics(SM_CYSCREEN)/2-yres/2;
		wp.rcNormalPosition.right = wp.rcNormalPosition.left + dd_gameWindow->winw;
		wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + dd_gameWindow->winh;
		SetWindowPlacement(dd_gameWindow->hwnd,&wp);

		dd_bGameWindowRectInitialized = true;
	}

	//must deactivate all auxwindows
	if(vid_window && !windowflag)
		for(std::vector<dd_Window*>::iterator it = dd_windows.begin(); it != dd_windows.end(); it++)
		{
			if(!(*it)->bGameWindow)
				(*it)->deactivate();
		}

	if (!windowflag)
	{
		//if we are switching into fullscreen, we are going to lose these sizes and positions
		//save them now so we can restore them when we flip back to windowmode
		if(vid_window)
		{
			WINDOWPLACEMENT wp;
			wp.length = sizeof(WINDOWPLACEMENT);
			GetWindowPlacement(dd_gameWindow->hwnd,&wp);
			dd_gameWindow->winx = wp.rcNormalPosition.left;
			dd_gameWindow->winy = wp.rcNormalPosition.top;
			dd_gameWindow->winw = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
			dd_gameWindow->winh = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
			dd_bWasMaximized = (wp.showCmd == SW_SHOWMAXIMIZED);
		}

		//ShowWindow(dd_gameWindow->hwnd,SW_SHOWMAXIMIZED);
		ShowWindow(dd_gameWindow->hwnd,SW_HIDE);

		int ret = dd_gameWindow->set_fullscreen(xres,yres,bpp);
		if(!ret)
			return 0;

		ShowWindow(dd_gameWindow->hwnd,SW_SHOW);

		dd_gameWindow->xres = xres;
		dd_gameWindow->yres = yres;

		vid_xres = xres;
		vid_yres = yres;
		vid_window = false;
		dd_bHasBeenFullscreen = true;

		dd_RegisterBlitters();
		return ret;
	}
	else
	{
		DX_RELEASE(dx_ps);
		DX_RELEASE(dx_win_ps);

		if (bpp != DesktopBPP) return 0;
		if (!vid_window)
			dx_dd->RestoreDisplayMode();
		dx_dd->SetCooperativeLevel(dd_gameWindow->hwnd, DDSCL_NORMAL);

		hr = dx_dd->CreateSurface(&dx_win_psd, &dx_win_ps, NULL);
		if (hr != DD_OK)
		{
			return 0;
		}

		int ret = dd_gameWindow->set_win(xres,yres,bpp);
		if(!ret)
			return 0;


		if(dd_bHasBeenFullscreen)
		{
			WINDOWPLACEMENT wp;
			wp.length = sizeof(WINDOWPLACEMENT);
			GetWindowPlacement(dd_gameWindow->hwnd,&wp);
			wp.rcNormalPosition.left = dd_gameWindow->winx;
			wp.rcNormalPosition.top = dd_gameWindow->winy;
			wp.rcNormalPosition.right = wp.rcNormalPosition.left + dd_gameWindow->winw;
			wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + dd_gameWindow->winh;
			SetWindowPlacement(dd_gameWindow->hwnd,&wp);

			if(dd_bWasMaximized)
				ShowWindow(dd_gameWindow->hwnd,SW_SHOWMAXIMIZED);
		}

		//must activate all auxwindows
		if(!vid_window)
			for(std::vector<dd_Window*>::iterator it = dd_windows.begin(); it != dd_windows.end(); it++)
				if(!(*it)->bGameWindow)
					(*it)->activate();

		//bring the gamewindow back to the front
		SetWindowPos(dd_gameWindow->hwnd,HWND_TOP,0,0,0,0,SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);

		dd_gameWindow->xres = xres;
		dd_gameWindow->yres = yres;

		vid_xres = xres;
		vid_yres = yres;
		vid_window = true;

		dd_RegisterBlitters();
		return 1;
	}
	return 0;
}