Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

1

08.07.2003, 12:10

Problem mit Header-Datei

Hi! Ich habe mit meiner DX9 Library folgendes Problem: Meine Library besteht derzeit aus folgenden 2 Dateien:

dxLibrary.h
dxLibrary.cpp

Aber wenn ich das ganze in meiner Engine-DLL (wird paralell entwickelt und benutzt die Library, Quellcodes der DLL sind hier nicht vorhanden), kommt folgender Fehler:

Zitat

c:\Dokumente und Einstellungen\AuzingLG\Eigene Dateien\SkyCraft Engine\SkyCraft\dxLibrary.cpp(71) : fatal error C1010: Unerwartetes Dateiende während der Suche nach der Direktive für die vorkompilierte Headerdatei
Hier die Quellcodes der Library.
dxLibrary.h (basierend auf den Buchdateien unter TriBase/Beispiele/Allgemein):

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <windows.h>
#include <D3D9.h>

HWND dxHWND;

#ifdef _INITDIRECT3D_CPP
#undef VAR
#define VAR
#else
#undef VAR
#define VAR extern
#endif

VAR PDIRECT3D9          g_pD3D;
VAR PDIRECT3DDEVICE9    g_pD3DDevice;

BOOL InitWindow(int iWidth, int iHeight, char* pcTitle, HICON hIcon);
BOOL InitD3D((SDirect3DParameters* pParameters, HWND hWnd);
Und hier die eigentliche Datei (teilweise basierend auf dem Kapitel 2 des Buchs):

Quellcode

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
#include "dxLibrary.h"

BOOL dxInitWindow(int iWidth, int iHeight, char* pcTitle, HICON hIcon)
{
    HWND hWnd;
    WNDCLASSEX wndclass = {sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0, 0, GetModuleHandle(NULL), hIcon, NULL, NULL, NULL,
        "DX Window", NULL};

    if (!RegisterClassEx(&wndclass))
    {
        MessageBox(hWnd, "ERROR DX11: An error encountered while registering WNDCLASS!", "ERROR DX11", MB_OK | MB_ICONSTOP);
        return FALSE;
    }

    dxHWND = CreateWindow("DX Window", pcTitle, WS_VISIBLE | WS_OVERLAPPEDWINDOW, GetSystemMetrics(SM_CXSCREEN),
        GetSystemMetrics(SM_CYSCREEN), iWidth, iHeight, NULL, NULL, GetModuleHandle(NULL), NULL);
    if (dxHWND == NULL)
    {
        MessageBox(hWnd, "ERROR DX12: Creating window failed!", "ERROR DX12", MB_OK | MB_ICONSTOP);
        return FALSE;
    }

    return TRUE;
}

BOOL dxInitD3D(SDirect3DParameters* pParameters, HWND hWnd)
{
    HRESULT hResult;
    D3DPRESENT_PARAMETERS PresentParams;

    if (pParameters == NULL)
    {
        MessageBox(hWnd, "ERROR DX21: Nullpointer!", "ERROR DX21", MB_OK | MB_ICONSTOP);
        return FALSE;
    }

    g_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
    if (g_pD3D == NULL)
    {
        MessageBox(hWnd, "ERROR DX22: Creating Direct3D Device failed!", "ERROR DX22", MB_OK | MB_ICONSTOP);
        return FALSE;
    }

    ZeroMemory(&PresentParams, sizeof(D3DPRESENT_PARAMETERS));
    PresentParams.BackBufferWidth = pParameters->VideoMode.Width;
    PresentParams.BackBufferHeight = pParameters->VideoMode.Height;
    PresentParams.BackBufferFormat = pParameters->BackBufferFormat;
    PresentParams.BackBufferCount = 1;
    PresentParams.MultiSampleType = pParameters->MultiSamplingType;
    PresentParams.MultiSampleQuality = pParameters->dwMultiSamplingQuality;
    PresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
    PresentParams.hDeviceWindow = hWnd;
    PresentParams.Windowed = pParameters->bWindowed;
    PresentParams.EnableAutoDepthStencil = TRUE;
    PresentParams.AutoDepthStencilFormat = pParameters->ZStencilBufferFormat;
    PresentParams.Flags = pParameters->ZStencilBufferFormat != D3DFMT_D16_LOCKABLE ? D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL : 0;
    PresentParams.FullScreen_RefreshRateInHz = pParameters->bWindowed ? D3DPRESENT_RATE_DEFAULT : pParameters->VideoMode.RefreshRate;
    PresentParams.PresentationInterval = pParametes->bWindowed ? D3DPRESENT_INTERVAL_DEFAULT : D3DPRESENT_INTERVAL_ONE;

    if (FAILED(hResult = g_pD3D->CreateDevice(pParameters->iAdapter, pParameters->DeviceType, hWnd, pParameters->dwFlags,
        &PresentParams, &g_pD3DDevuce)))
    {
        MessageBox(hWnd, "ERROR DX23: Creating Direct3D Device failed", "ERROR DX23", MB_OK | MB_ICONSTOP);
        return FALSE;
    }

    if (!pParameters->bWindowed) ShowCursor(FALSE);

    return TRUE;
}

2

08.07.2003, 12:43

Ich habe die Header-Datei jetzt geändert in:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <windows.h>
#include <D3D9.h>

#ifdef _DXLIBRARY_CPP
#undef VAR
#define VAR
#else
#undef VAR
#define VAR extern
#endif

HWND dxHWND;

VAR PDIRECT3D9          g_pD3D;
VAR PDIRECT3DDEVICE9    g_pD3DDevice;

BOOL InitWindow(int iWidth, int iHeight, char* pcTitle, HICON hIcon);
BOOL InitD3D((SDirect3DParameters* pParameters, HWND hWnd);