Hello,
i am trying to handle problem with directX 9 and code:blocks.
i searched the internet and after installing the sdk properly and used a tutorial to compile the directx code in an static control window of my winapi program. The IDE doesn't give an error, but instead of compiling a grey window the code only does a black window over the other dialog elements, who won't be compiled properly on screen. The programm doesn't shutdown and the window bar still is in function.
Does anyone knows what's to do?
Here ist the code in cuts:
void initD3D(HWND hDlg30)
{
d3d = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hDlg30;
d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hDlg30,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);
}
HRESULT CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags,
D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DDevice9 **ppReturnedDeviceInterface);
void render_frame(void)
{
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(70, 70, 70), 1.0f, 0);
d3ddev->BeginScene();
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
}
void cleanD3D(void)
{
d3ddev->Release();
d3d->Release();
}
And this is the dialog code so far:
BOOL CALLBACK RaumkarteProc(HWND hDlg30, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
HDC hdcZeichnung;
RECT rect;
static HWND hwndRaumkarteAktion1, hwndRaumkarteAktion2,
hwndRaumkarteHScroll, hwndRaumkarteVScroll, hwndRaum;
int AnzahlGegner;
static int rightWidth=1100;
static int lowerHeight=650;
static int leftWidth=300;
static int upperHeight=50;
bool Kartezeichnen=true;
static int iAktions1index;
static int Aktion1auslesen;
static char Aktion1auswahl[100];
int Kartenmobilanzahl;
Kartenmobilanzahl=Zufallsgegner_Raum.size();
hwndRaum=GetDlgItem(hDlg30,ID_RAUMKARTE31);
initD3D(hDlg30);
switch (message)
{
case WM_INITDIALOG:
{
SendDlgItemMessage(hDlg30, ID_RAUMKARTEAKTIONSLISTE34,LB_ADDSTRING,NULL,(LPARAM)"Flug");
SendDlgItemMessage(hDlg30, ID_RAUMKARTEAKTIONSLISTE34,LB_ADDSTRING,NULL,(LPARAM)"Feuergefecht");
SendDlgItemMessage(hDlg30, ID_RAUMKARTEAKTIONSLISTE34,LB_ADDSTRING,NULL,(LPARAM)"Planet");
SendDlgItemMessage(hDlg30, ID_RAUMKARTEAKTIONSLISTE34,LB_ADDSTRING,NULL,(LPARAM)"Handelsdock/ Basis");
SendDlgItemMessage(hDlg30, ID_RAUMKARTEAKTIONSLISTE34,LB_ADDSTRING,NULL,(LPARAM)"Kom Kanal");
SendDlgItemMessage(hDlg30, ID_RAUMKARTEAKTIONSLISTE34,LB_ADDSTRING,NULL,(LPARAM)"Scan");
SendDlgItemMessage(hDlg30, ID_RAUMKARTEAKTIONSLISTE34,LB_ADDSTRING,NULL,(LPARAM)"Ladung abwerfen");
SendDlgItemMessage(hDlg30, ID_RAUMKARTEAKTIONSLISTE34,LB_ADDSTRING,NULL,(LPARAM)"Ladung tauschen");
SendDlgItemMessage(hDlg30, ID_RAUMKARTEAKTIONSLISTE34,LB_ADDSTRING,NULL,(LPARAM)"Runde abschließen");
return FALSE;
};
case WM_PAINT:
{
if (Kartezeichnen==true)
{
render_frame();
}
}
break;
case WM_COMMAND:
switch (LOWORD (wParam))
{
case WM_KEYDOWN:
{
return FALSE;
}
case WM_SIZE:
{
return FALSE;
}
case VK_ESCAPE:
{
cleanD3D();
EndDialog(hDlg30,0);
return TRUE;
}
case ID_RAUMKARTEAKTIONSLISTE34:
{
if (LOWORD(wParam)==ID_RAUMKARTEAKTIONSLISTE34&&HIWORD(wParam)==LBN_DBLCLK)
{
iAktions1index=SendMessage(GetDlgItem(hDlg30, ID_RAUMKARTEAKTIONSLISTE34), LB_GETCURSEL,0,0);
Aktion1auslesen=SendMessage(GetDlgItem(hDlg30, ID_RAUMKARTEAKTIONSLISTE34),LB_GETTEXT,iAktions1index,(LPARAM)Aktion1auswahl);
if (strcmp(Aktion1auswahl, "Flug")==0)
{
Zielfadenkreuz==true;
UpdateWindow(hDlg30);
SendDlgItemMessage(hDlg30, ID_RAUMKARTEWAHLAKTIONSLISTE35,LB_ADDSTRING,NULL,(LPARAM)"Flug ausfuehren");
SendDlgItemMessage(hDlg30, ID_RAUMKARTEWAHLAKTIONSLISTE35,LB_ADDSTRING,NULL,(LPARAM)"Flugmodus beenden");
return FALSE;
}
else if (strcmp(Aktion1auswahl, "Runde abschließen")==0)
{
cleanD3D();
EndDialog(hDlg30,0);
return TRUE;
}
}
return FALSE;
}
}
break;
}
return FALSE;
}
|