summaryrefslogtreecommitdiffhomepage
path: root/Stars45/GameWinDX9.cpp
blob: 2cd4fbe5999ca2c826be8788bc89e4921b666a7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*  Starshatter: The Open Source Project
    Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors
    Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
    Copyright (c) 1997-2006, Destroyer Studios LLC.
*/

#include "GameWinDX9.h"

#include "Game.h"
#include "MachineInfo.h"
#include "Panic.h"
#include "Types.h"


GameWinDX9::GameWinDX9()
{
}


GameWinDX9::~GameWinDX9()
{
}


bool
GameWinDX9::Init(HINSTANCE hi, HINSTANCE hpi, LPSTR cmdline, int nCmdShow)
{
    status = OK;
    hInst  = hi;

    Print("  Initializing Game\n");

    stats.Clear();

    if (!InitApplication(hInst)) {  // Initialize shared things
        Panic::Panic("Could not initialize the application.");
        status = INIT_FAILED;
    }

    if (status == OK && !video_settings) {
        Panic::Panic("No video settings specified");
        status = INIT_FAILED;
    }

    if (status == OK) {
        static int os_version = MachineInfo::GetPlatform();

        if (os_version == MachineInfo::OS_WIN95 || os_version == MachineInfo::OS_WIN98) {
            Panic::Panic("  Windows 95 and 98 are no longer supported. Please update to Windows XP or higher.");
            status = INIT_FAILED;
        } else if (os_version == MachineInfo::OS_WINNT) {
            Panic::Panic("  D3D not available under WinNT 4");
            status = INIT_FAILED;
        } else if (MachineInfo::GetDirectXVersion() < MachineInfo::DX_9) {
            Panic::Panic("  Insufficient DirectX detected (Dx9 IS REQUIRED)");
            status = INIT_FAILED;
        }

        Print("  Gamma Level = %d\n", gamma);
    }

    if (status == OK) {
        Print("\n  Initializing instance...\n");
        // Perform initializations that apply to a specific instance
        if (!InitInstance(hInst, nCmdShow)) {
            Panic::Panic("Could not initialize the instance.");
            status = INIT_FAILED;
        }
    }

    if (status != OK)
        return false;
    return Game::Init(hi, hpi, cmdline, nCmdShow);
}