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
C-/C++-Quelltext |
|
1 2 3 4 5 6 |
#ifndef _MY_HEADER_H_
#define _MY_HEADER_H_
// alles was in den header gehört
#endif
|
C-/C++-Quelltext |
|
1 2 3 4 5 6 |
g_pWallModel = new tbModel; if(g_pWallModel->Init("wall.tbm","","")) { MessageBoxW(hWnd,L"Fehler beim laden des Wandmodells", "Fehler",MB_OK | MB_ICONEXCLAMATION); return 1; } |
C-/C++-Quelltext |
|
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
// Lieber Computer, // Bitte initialisiere die TriBase-Engine, initialisiere D3D und erstelle mir ein Fenster. Weiterhin wäre es mir recht, // wenn du mal eben ein .tbm Modell lädst. // Du brauchst noch nicht ein mal D3D herunterzufahren. Das machen wir später // Vielen Dank im voraus // (c) 2006 Frederik Simon // Nichts? // Na dann mach ich es halt selber. // Was braúch ma denn a weng? #define UNICODE #include <windows.h> #include <commdlg.h> #include <TriBase.h> #include <d3d9.h> // Funktionen LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ; bool InitDirect3D (::HWND hWnd, bool windowed); // Was willst de denn noch? // Globale Variablen ::HWND hWnd; ::WNDCLASS wndcls; ::MSG msg; bool windowed = TRUE; IDirect3DDevice9* direct3ddevice = NULL; // Modelle tbModel* g_pWallModel = NULL; // Wandmodell // Sodala dann mach ma mal los int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow) { // TriBase gib Gummi(D3D auch) tbInit(); InitDirect3D(hWnd,windowed); // Was brauch ma denn fürs Fensterla wndcls.cbClsExtra = 1; wndcls.cbWndExtra = 1; wndcls.hbrBackground = static_cast<HBRUSH>(::GetStockObject((int)WHITE_BRUSH)); wndcls.hCursor = NULL; wndcls.hIcon = LoadIcon(hInstance, IDI_APPLICATION); wndcls.hInstance = hInstance; wndcls.lpfnWndProc = WindowProc; wndcls.lpszClassName = L"app"; wndcls.lpszMenuName = NULL; // <= Menu rein wndcls.style = CS_HREDRAW | CS_VREDRAW; // Registrier ma die Fensterklasse if(!::RegisterClassW(&wndcls)) return -1; // Mach ma des Fenster hWnd = ::CreateWindowW( L"app", L"Level-Editor" , WS_OVERLAPPEDWINDOW, 0, 0, 1280, 783, ::GetDesktopWindow(), NULL, hInstance, NULL); // Bist du zu doof n' Fenster zu erstellen? if(!hWnd) return -1; // Zeig ma das Fenster an ::ShowWindow(hWnd, nCmdShow); ::UpdateWindow(hWnd); // Mach ma des ganze Zeug mit Nachrichten und so while(::GetMessageW(&msg, NULL, NULL, NULL)) { ::TranslateMessage(&msg); ::DispatchMessageW(&msg); } g_pWallModel = new tbModel; if(g_pWallModel->Init("test.tbm","","")) { MessageBoxW(hWnd,L"Fehler beim laden des Wandmodells", L"Fehler",MB_OK | MB_ICONEXCLAMATION); return 1; } // TriBase a Ruh is tbExit(); return 0; } LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_CLOSE: PostQuitMessage(0); return 0; } return ::DefWindowProcW(hwnd, uMsg, wParam, lParam); } // So dann mus jetzt D3D ran bool initDirect3D (::HWND hwnd, bool windowed) { // Halt des Zeug mit den 32Bit(burgern) D3DDISPLAYMODE display_mode; // Die wichtigen Dinge D3DPRESENT_PARAMETERS present_parameters; // GrKa und so D3DCAPS9 caps; // Alle Strukturen initialisieren ZeroMemory (&display_mode, sizeof(D3DDISPLAYMODE)); ZeroMemory (&present_parameters, sizeof(D3DPRESENT_PARAMETERS)); ZeroMemory (&caps, sizeof(D3DCAPS9)); // D3D Objekt erstellen PDIRECT3D9 direct3d = Direct3DCreate9 (D3D_SDK_VERSION); // Gab es einen Fehler? Wenn ja, liegt des net an mir if (direct3d == NULL) { MessageBoxW (NULL, L"Direct3DCreate9(); fehlgeschlagen! " L"Stellen Sie sicher das DirectX9 installiert ist.", L"Error:", MB_OK); return (false); } // Farbtiefe des Desktops holen (für Fenstermodus) if (direct3d->GetAdapterDisplayMode (D3DADAPTER_DEFAULT, &display_mode) != D3D_OK) { MessageBoxW (NULL, L"IDirect3D9::GetAdapterDisplayMode(); fehlgeschlagen!", L"Error:", MB_OK); return TB_ERROR; } // Features der Grafikkarte holen if (direct3d->GetDeviceCaps (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps) != D3D_OK) { MessageBoxW (NULL, L"IDirect3D9::GetDeviceCaps(); fehlgeschlagen!", L"Error:", MB_OK); return TB_ERROR; } // Darstellungsparameter setzen! present_parameters.Windowed = windowed; // Fenstermodus? present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD; // Swapeffect present_parameters.BackBufferCount = 1; // Anzahl Backbuffer present_parameters.EnableAutoDepthStencil = true; // DepthStencil? Wir sagen ja! present_parameters.AutoDepthStencilFormat = D3DFMT_D16; // DepthStencil Format. present_parameters.BackBufferWidth = 800; // Auflösung: Breite present_parameters.BackBufferHeight = 600; // Auflösung: Höhe present_parameters.BackBufferFormat = display_mode.Format; // Format des Desktops // Kleiner Puffer für die abfrage nach VertexProcessing unsigned long vp = D3DCREATE_HARDWARE_VERTEXPROCESSING; // Wird VertexProcessing von der GraKa unterstützt? Wenn nein: // Machen wir das per Software. if (caps.VertexProcessingCaps == 0) vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING; // Das Device erstellen! if (direct3d->CreateDevice (0, D3DDEVTYPE_HAL, hwnd, vp, &present_parameters, &direct3ddevice) != D3D_OK) { MessageBoxW (NULL, L"IDirect3D9::CreateDevice(); fehlgeschlagen!", L"Error:", MB_OK); return TB_ERROR; } // Alles erfolgreich! return TB_OK; } |
Quellcode |
|
1 2 3 |
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""bool __cdecl InitDirect3D(struct HWND__ *,bool)" (?InitDirect3D@@YA_NPAUHWND__@@_N@Z)" in Funktion "_WinMain@16". fatal error LNK1120: 1 nicht aufgelöste externe Verweise. |
Anonymous
unregistriert
Anonymous
unregistriert
Zitat von »"Fred"«
LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ;
bool InitDirect3D (::HWND hWnd, bool windowed);
::HWND hWnd;
::WNDCLASS wndcls;
::MSG msg;
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow)
if(!::RegisterClassW(&wndcls))
return -1;
::CreateWindowW( L"app", L"Level-Editor" , WS_OVERLAPPEDWINDOW, 0, 0, 1280, 783, ::GetDesktopWindow(), NULL, hInstance, NULL);
:howWindow(hWnd, nCmdShow);
::UpdateWindow(hWnd);
while(::GetMessageW(&msg, NULL, NULL, NULL))
{
::TranslateMessage(&msg);
:ispatchMessageW(&msg);
}
MessageBoxW(hWnd,L"Fehler beim laden des Wandmodells", L"Fehler",MB_OK | MB_ICONEXCLAMATION);
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return :efWindowProcW(hwnd, uMsg, wParam, lParam);
}
bool initDirect3D (::HWND hwnd, bool windowed)
{
// Halt des Zeug mit den 32Bit(burgern)
D3DDISPLAYMODE display_mode;
// Die wichtigen Dinge
D3DPRESENT_PARAMETERS present_parameters;
// GrKa und so
D3DCAPS9 caps;
ZeroMemory (&display_mode, sizeof(D3DDISPLAYMODE));
ZeroMemory (&present_parameters, sizeof(D3DPRESENT_PARAMETERS));
ZeroMemory (&caps, sizeof(D3DCAPS9));
Werbeanzeige