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 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 |
#include<Windows.h> #include<d3d9.h> #include<d3dx9.h> #pragma comment(lib,"d3d9.lib") #pragma comment(lib,"d3dx9.lib") #define SCREEN_WIDTH 800 #define SCREEN_HEIGHT 600 bool GameRun = TRUE; LPDIRECT3D9 D3D; LPDIRECT3DDEVICE9 D3DDEV; LPDIRECT3DTEXTURE9 texture = NULL; LPD3DXSPRITE sprite = NULL; void Init(HWND hWnd); void Render(void); void Clean(void); LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); const char szAppName[] = "Tut"; int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow) { HWND hWnd; MSG msg; WNDCLASS wc; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hIcon = LoadIcon(NULL,IDI_APPLICATION); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.lpszClassName = szAppName; wc.lpszMenuName = NULL; RegisterClass(&wc); hWnd = CreateWindow(szAppName,szAppName,WS_OVERLAPPEDWINDOW,0,0,SCREEN_WIDTH,SCREEN_HEIGHT,NULL,NULL,hInstance,NULL); ShowWindow(hWnd,iCmdShow); UpdateWindow(hWnd); Init(hWnd); while(GameRun) { while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); if(msg.message == WM_QUIT) GameRun = FALSE; } Render(); } Clean(); return msg.wParam; } LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) { switch(message) { case WM_DESTROY: { PostQuitMessage(0); return 0; } } return DefWindowProc(hWnd,message,wParam,lParam); } void Init(HWND hWnd) { D3D = Direct3DCreate9(D3D_SDK_VERSION); D3DPRESENT_PARAMETERS D3DPP; ZeroMemory(&D3DPP,sizeof(D3DPP)); D3DPP.Windowed = TRUE; D3DPP.SwapEffect = D3DSWAPEFFECT_DISCARD; D3DPP.hDeviceWindow = hWnd; D3DPP.BackBufferFormat = D3DFMT_X8R8G8B8; D3DPP.BackBufferWidth = SCREEN_WIDTH; D3DPP.BackBufferHeight = SCREEN_HEIGHT; D3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&D3DPP,&D3DDEV); D3DXCreateTextureFromFile(D3DDEV,TEXT("texture.png"),&texture); D3DXCreateSprite(D3DDEV,&sprite); D3DDEV->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR ); D3DDEV->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR ); D3DDEV->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR ); } void Render(void) { D3DDEV->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,40,100),1.0f,0.0f); D3DDEV->BeginScene(); D3DXVECTOR3 pos; pos.x = 0.0f; pos.y = 0.0f; pos.z = 0.0f; sprite->Begin(D3DXSPRITE_ALPHABLEND); sprite->Draw(texture,NULL,NULL,&pos,D3DCOLOR_XRGB(255,255,255)); sprite->End(); D3DDEV->EndScene(); D3DDEV->Present(NULL,NULL,NULL,NULL); } void Clean(void) { D3D->Release(); D3DDEV->Release(); texture->Release(); } |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »BreakBlack« (11.08.2012, 13:55)
Administrator
C-/C++-Quelltext |
|
1 2 |
if (FAILED(D3DXCreateTextureFromFile(D3DDEV,TEXT("texture.png"),&texture))) MessageBox(hWnd,"Error","Error",MB_OKCANCEL); |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Delop« (11.08.2012, 15:17)
C-/C++-Quelltext |
|
1 2 |
HRESULT hvar; hvar = D3DXCreateTextureFromFile(D3DDEV,TEXT("texture.png"),&texture); Hier hab ich dann den BreakPoint gesetzt. |
Werbeanzeige