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 7 8 9 10 11 12 13 14 15 16 17 18 19 |
void beginRender(D3DCOLOR backgroundColor) { if( NULL == direct3dDevice ) return; direct3dDevice ->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, backgroundColor, 1.0f, 0); direct3dDevice ->BeginScene(); } void endRender() { direct3dDevice ->EndScene(); direct3dDevice ->Present( NULL, NULL, NULL, NULL ); } |
Zitat von »"CoB-Twister"«
Oder muss ich nach dem Switchen bestimmte Dinge neu initialisieren?
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 |
direct3dDevice = NULL; direct3d = Direct3DCreate9( D3D_SDK_VERSION ); D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = false; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_R5G6B5; d3dpp.BackBufferCount = 1; d3dpp.BackBufferHeight = wndHeight; d3dpp.BackBufferWidth = wndWidth; d3dpp.hDeviceWindow = wndHandle; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; direct3d->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, wndHandle, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &direct3dDevice); direct3dDevice ->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE); |
C-/C++-Quelltext |
|
1 2 3 4 5 6 |
if(D3D_OK!=direct3d->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, wndHandle, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &direct3dDevice)) MessageBox(0,"fehlgeschlagen","Fehler",0); |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = false; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_R5G6B5; d3dpp.BackBufferCount = 1; d3dpp.BackBufferHeight = wndHeight; d3dpp.BackBufferWidth = wndWidth; d3dpp.hDeviceWindow = wndHandle; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; direct3dDevice->Reset(&d3dpp); |
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 |
void beginRender(D3DCOLOR backgroundColor) { HRESULT r = direct3dDevice->TestCooperativeLevel(); if( r == D3DERR_DEVICELOST){ D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = false; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_R5G6B5; d3dpp.BackBufferCount = 1; d3dpp.BackBufferHeight = wndHeight; d3dpp.BackBufferWidth = wndWidth; d3dpp.hDeviceWindow = wndHandle; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; direct3dDevice->Reset(&d3dpp);} direct3dDevice ->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, backgroundColor, 1.0f, 0); direct3dDevice ->BeginScene(); } |
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 |
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { init(hInstance, "Mein Fenster", 800, 600, false); MSG msg; ZeroMemory( &msg, sizeof(msg) ); while( msg.message!=WM_QUIT ) { if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } else { beginRender(0x309932CC); endRender(); } } releaseDX(); return (int) msg.wParam; } |
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 |
init(HINSTANCE hInstance,std::string WndName, ULONG WndWidth, ULONG WndHeight, bool windowed) { WNDCLASSEX wcex; wndWidth = WndWidth; wndHeight = WndHeight; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = 0; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = WndName.c_str(); wcex.hIconSm = 0; RegisterClassEx(&wcex); DWORD style=WS_POPUP|WS_VISIBLE; style = WS_OVERLAPPEDWINDOW; wndHandle = CreateWindow(WndName.c_str(), WndName.c_str(), style, CW_USEDEFAULT, CW_USEDEFAULT, WndWidth, WndHeight, NULL, NULL, hInstance, NULL); hInst = hInstance; ShowWindow(wndHandle, SW_SHOW); UpdateWindow(wndHandle); direct3d = NULL; direct3dDevice = NULL; direct3d = Direct3DCreate9( D3D_SDK_VERSION ); D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = windowed; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; d3dpp.BackBufferCount = 1; d3dpp.BackBufferHeight = WndHeight; d3dpp.BackBufferWidth = WndWidth; d3dpp.hDeviceWindow = wndHandle; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; direct3d->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, wndHandle, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &direct3dDevice); direct3dDevice ->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);} |
C-/C++-Quelltext |
|
1 2 3 4 5 6 |
LPDIRECT3D9 direct3d; LPDIRECT3DDEVICE9 direct3dDevice; HWND wndHandle; HINSTANCE hInst; int wndWidth; int wndHeight; |
Werbeanzeige