mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 17:17:09 -04:00
Split up D3D9 device creation from Gfx_Init
This commit is contained in:
parent
29a719d68b
commit
aec759153f
@ -389,8 +389,8 @@ static void Game_Load(void) {
|
||||
Game_UserViewDistance = 512;
|
||||
Game_Fov = 70;
|
||||
|
||||
Gfx_Init();
|
||||
Game_UpdateDimensions();
|
||||
Gfx_Init();
|
||||
LoadOptions();
|
||||
|
||||
Event_RegisterVoid(&WorldEvents.NewMap, NULL, HandleOnNewMap);
|
||||
|
@ -365,21 +365,19 @@ static void D3D9_FillPresentArgs(int width, int height, D3DPRESENT_PARAMETERS* a
|
||||
args->Windowed = true;
|
||||
}
|
||||
|
||||
void Gfx_Init(void) {
|
||||
static void TryCreateDevice(void) {
|
||||
cc_result res;
|
||||
D3DCAPS9 caps;
|
||||
|
||||
Gfx.MinZNear = 0.05f;
|
||||
HWND winHandle = (HWND)WindowInfo.Handle;
|
||||
d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
|
||||
FindCompatibleViewFormat();
|
||||
FindCompatibleDepthFormat();
|
||||
D3DPRESENT_PARAMETERS args = { 0 };
|
||||
D3D9_FillPresentArgs(640, 480, &args);
|
||||
|
||||
/* Try to create a device with as much hardware usage as possible. */
|
||||
res = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, winHandle, createFlags, &args, &device);
|
||||
/* Another running fullscreen application might prevent creating device */
|
||||
/*if (res == D3DERR_DEVICELOST) { Gfx.LostContext = true; return; } */
|
||||
|
||||
/* Fallback with using CPU for some parts of rendering */
|
||||
if (res) {
|
||||
createFlags = D3DCREATE_MIXED_VERTEXPROCESSING;
|
||||
res = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, winHandle, createFlags, &args, &device);
|
||||
@ -388,20 +386,29 @@ void Gfx_Init(void) {
|
||||
createFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
|
||||
res = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, winHandle, createFlags, &args, &device);
|
||||
}
|
||||
if (res) Logger_Abort2(res, "Creating Direct3D9 device");
|
||||
|
||||
if (res) Logger_Abort2(res, "Creating Direct3D9 device");
|
||||
res = IDirect3DDevice9_GetDeviceCaps(device, &caps);
|
||||
if (res) Logger_Abort2(res, "Getting Direct3D9 capabilities");
|
||||
|
||||
Gfx.MaxTexWidth = caps.MaxTextureWidth;
|
||||
Gfx.MaxTexHeight = caps.MaxTextureHeight;
|
||||
Gfx.CustomMipmapsLevels = true;
|
||||
|
||||
CommonInit();
|
||||
Gfx_RestoreState();
|
||||
totalMem = IDirect3DDevice9_GetAvailableTextureMem(device) / (1024.0f * 1024.0f);
|
||||
}
|
||||
|
||||
void Gfx_Init(void) {
|
||||
d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
FindCompatibleViewFormat();
|
||||
FindCompatibleDepthFormat();
|
||||
|
||||
Gfx.MinZNear = 0.05f;
|
||||
Gfx.CustomMipmapsLevels = true;
|
||||
CommonInit();
|
||||
TryCreateDevice();
|
||||
}
|
||||
|
||||
cc_bool Gfx_TryRestoreContext(void) {
|
||||
D3DPRESENT_PARAMETERS args = { 0 };
|
||||
cc_result res;
|
||||
|
@ -108,8 +108,8 @@ static int Program_Run(int argc, char** argv) {
|
||||
#ifdef _MSC_VER
|
||||
/* NOTE: Make sure to comment this out before pushing a commit */
|
||||
//String rawArgs = String_FromConst("UnknownShadow200 fffff 127.0.0.1 25565");
|
||||
//String rawArgs = String_FromConst("UnknownShadow200");
|
||||
//argsCount = String_UNSAFE_Split(&rawArgs, ' ', args, 4);
|
||||
String rawArgs = String_FromConst("UnknownShadow200");
|
||||
argsCount = String_UNSAFE_Split(&rawArgs, ' ', args, 4);
|
||||
#endif
|
||||
|
||||
if (argsCount == 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user