PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Frage zu DirectX


Gast
2008-08-24, 15:34:09
Hi,

Ich wollte gerade anfangen, DirectX 9 zu lernen. Hab dann einfach mal Code aus einem Tutorial kopiert, und in Visual Studio (2008) eingefügt.
DirectX SDK ist natürlich auch installiert, und ich hab Visual Studio soweit eingestellt, dass er es schafft es zu kompilieren. Aber da erscheint nur für den Bruchteil einer Sekunde ein Fenster mit der Überschrift "DirectX Wiki - D3D9 Tutorial 1", und geht dann sofort wieder weg.
Hier ist der Code:

//Every windows application needs to include this
#include "windows.h"
//Every Direct3D application this
#include "d3d9.h"
#include <iostream>

bool g_bContinue = true;

//Besides the main function, there must be a message processing function
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_DESTROY:
PostQuitMessage( 0 );
g_bContinue = false;
return 0;
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
//The entry point of a windows application is the WinMain function
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
//Create a window class.
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"Direct3D Window", NULL };
//Register the window class.
RegisterClassEx( &wc );
//Create the application's window.
std::cout << "TEST1" << std::endl;
HWND hWnd = CreateWindow( "Direct3D Window", "DirectX Wiki - D3D9 Tutorial 1",
WS_OVERLAPPEDWINDOW, 100, 100, 400, 400,
GetDesktopWindow(), NULL, wc.hInstance, NULL );
std::cout << "TEST1" << std::endl;
ShowWindow(hWnd,SW_SHOW);
std::cout << "TEST1" << std::endl;
//Create the Direct3D Object
LPDIRECT3D9 pD3D = NULL;
std::cout << "TEST1" << std::endl;
if( NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
return E_FAIL;
std::cout << "TEST2" << std::endl;
//Setup the device presentation parameters
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
//The final step is to use the IDirect3D9::CreateDevice method to create the Direct3D device, as illustrated in the
//following code example.
LPDIRECT3DDEVICE9 pd3dDevice = NULL;
if( FAILED( pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp, &pd3dDevice ) ) )
{
pD3D->Release();
pD3D = NULL;
return E_FAIL;
}
MSG msg;
while( g_bContinue )
{
//Clear render region with blue
pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
//before rendering something, you have to call this
pd3dDevice->BeginScene();
//rendering of scene objects happens here
//after the scene call
pd3dDevice->EndScene();
//Screen update
pd3dDevice->Present(NULL, NULL, NULL, NULL);
// A window has to handle its messages.
TranslateMessage( &msg );
DispatchMessage( &msg );
PeekMessage(&msg, 0, 0, 0, PM_REMOVE);
}

//Do not forget to clean up here
pd3dDevice->Release();
pd3dDevice = NULL;
pD3D->Release();
pD3D = NULL;
return 0;
}


Wie man sieht hab ich sogar "cout"s eingebaut, aber die erscheinen auch gar nicht auf der Standardausgabe.
Was ist da los?

Gast
2008-08-24, 16:29:52
Hat sich erledigt. Lag daran das mein Grafikchip kein Hardwarevertexprocessing kann.

TheGamer
2008-08-24, 17:13:32
Hat sich erledigt. Lag daran das mein Grafikchip kein Hardwarevertexprocessing kann.

Bitte was?

Was hast du denn fuer einen?

Gast
2008-08-24, 17:17:38
Intel.

TheGamer
2008-08-24, 17:27:04
Intel.

Ah ok