Forum » Programiranje » DirectX, neki ne gre
DirectX, neki ne gre

Monster ::
ejte folk ka je narobe vkodi.. Mamm directX8 SDK p winXP matrox g400
vrne external eror niki z dx
sm kodo poglejte pa probite popravt please
*********************
/*inicializacija directX in barvanje ekrana na crno*/
//glavne datoteke
#include "windows.h"
#include "d3d8.h"
//globlne spremenljivke
HINSTANCE g_hInst;
HWND g_hWnd;
bool g_bFullscreen;
//direckX zadevice
IDirect3D8 *g_pDirect3D;
IDirect3DDevice8 *g_pDevice;
//rezultati(backi) funkcij
HRESULT g_hr;
//inicializacijska funkcija
bool Direct3DInit()
{
g_pDirect3D=Direct3DCreate8(D3D_SDK_VERSION);
if(g_pDirect3D==NULL)
return false;
//z lstnosti ekrana
D3DDISPLAYMODE displayMode;
if(g_bFullscreen==false)
{
g_hr=g_pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &displayMode);
if(FAILED(g_hr))
return false;
}
else
{
displayMode.Width=640;
displayMode.Height=480;
displayMode.RefreshRate=0;
displayMode.Format=D3DFMT_R5G6B5;
}
D3DPRESENT_PARAMETERS presentParameters;
memset(&presentParameters, 0, sizeof(D3DPRESENT_PARAMETERS));
if(g_bFullscreen==false)
{
presentParameters.Windowed=true;
}
else
{
presentParameters.Windowed=false;
}
presentParameters.SwapEffect=D3DSWAPEFFECT_DISCARD;
presentParameters.BackBufferFormat=displayMode.Format;
presentParameters.BackBufferWidth=displayMode.Width;
presentParameters.BackBufferHeight=displayMode.Height;
g_hr=g_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &presentParameters, &g_pDevice);
if(FAILED(g_hr))
return false;
return true;
}
void DrawScene()
{
g_pDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f , 0);
g_pDevice->BeginScene();
g_pDevice->EndScene();
g_pDevice->Present(NULL,NULL,NULL,NULL);
}
void Direct3DRelease()
{
if(g_pDevice)
g_pDevice->Release();
g_pDevice=NULL;
if(g_pDirect3D)
g_pDirect3D->Release();
g_pDirect3D=NULL;
}
LRESULT CALLBACK WndProc(HWND wpHWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}
return DefWindowProc(wpHWnd, msg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS wc;
MSG msg;
g_hInst=hInstance;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = g_hInst;
wc.lpfnWndProc = WndProc;
wc.lpszClassName ="tt";
wc.lpszMenuName = NULL;
wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wc);
//sm okno
g_hWnd = CreateWindow("tt","Direct X ",
WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_VISIBLE,
0,0,640,480,
NULL,NULL,g_hInst, NULL);
if(Direct3DInit()==false)
{
Direct3DRelease();
return 0;
}
while(1)
{
while(PeekMessage(&msg, NULL, 0,0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
if(msg.message==WM_QUIT)
break;
}
if(msg.message==WM_QUIT)
break;
if(GetAsyncKeyState(VK_ESCAPE))
PostQuitMessage(0);
DrawScene();
}
Direct3DRelease();
return 0;
}
**********************
Hvala v naprej
vrne external eror niki z dx
sm kodo poglejte pa probite popravt please
*********************
/*inicializacija directX in barvanje ekrana na crno*/
//glavne datoteke
#include "windows.h"
#include "d3d8.h"
//globlne spremenljivke
HINSTANCE g_hInst;
HWND g_hWnd;
bool g_bFullscreen;
//direckX zadevice
IDirect3D8 *g_pDirect3D;
IDirect3DDevice8 *g_pDevice;
//rezultati(backi) funkcij
HRESULT g_hr;
//inicializacijska funkcija
bool Direct3DInit()
{
g_pDirect3D=Direct3DCreate8(D3D_SDK_VERSION);
if(g_pDirect3D==NULL)
return false;
//z lstnosti ekrana
D3DDISPLAYMODE displayMode;
if(g_bFullscreen==false)
{
g_hr=g_pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &displayMode);
if(FAILED(g_hr))
return false;
}
else
{
displayMode.Width=640;
displayMode.Height=480;
displayMode.RefreshRate=0;
displayMode.Format=D3DFMT_R5G6B5;
}
D3DPRESENT_PARAMETERS presentParameters;
memset(&presentParameters, 0, sizeof(D3DPRESENT_PARAMETERS));
if(g_bFullscreen==false)
{
presentParameters.Windowed=true;
}
else
{
presentParameters.Windowed=false;
}
presentParameters.SwapEffect=D3DSWAPEFFECT_DISCARD;
presentParameters.BackBufferFormat=displayMode.Format;
presentParameters.BackBufferWidth=displayMode.Width;
presentParameters.BackBufferHeight=displayMode.Height;
g_hr=g_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &presentParameters, &g_pDevice);
if(FAILED(g_hr))
return false;
return true;
}
void DrawScene()
{
g_pDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f , 0);
g_pDevice->BeginScene();
g_pDevice->EndScene();
g_pDevice->Present(NULL,NULL,NULL,NULL);
}
void Direct3DRelease()
{
if(g_pDevice)
g_pDevice->Release();
g_pDevice=NULL;
if(g_pDirect3D)
g_pDirect3D->Release();
g_pDirect3D=NULL;
}
LRESULT CALLBACK WndProc(HWND wpHWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}
return DefWindowProc(wpHWnd, msg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS wc;
MSG msg;
g_hInst=hInstance;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = g_hInst;
wc.lpfnWndProc = WndProc;
wc.lpszClassName ="tt";
wc.lpszMenuName = NULL;
wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wc);
//sm okno
g_hWnd = CreateWindow("tt","Direct X ",
WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_VISIBLE,
0,0,640,480,
NULL,NULL,g_hInst, NULL);
if(Direct3DInit()==false)
{
Direct3DRelease();
return 0;
}
while(1)
{
while(PeekMessage(&msg, NULL, 0,0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
if(msg.message==WM_QUIT)
break;
}
if(msg.message==WM_QUIT)
break;
if(GetAsyncKeyState(VK_ESCAPE))
PostQuitMessage(0);
DrawScene();
}
Direct3DRelease();
return 0;
}
**********************
Hvala v naprej
Ka zaboga...

Monster ::
aja madona.. nisem ne ko mi je setup neki napisu da mi bo dal t not automatic :)). Hvala pebi... Kaje mooče še keri lib za not dat tk da ni spet kej askal...
Ka zaboga...

Senitel ::
Ja libe rabiš potem za vsako komponento posebej... dsound.lib za DirectSound, d3dx8.lib za helper komponento...

Monster ::
aham sm kk to da setup ni dal tole auto not, ko prej na WinMe win9x mi je dal ne.. Na XP-jih pa ne ...
Ka zaboga...
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | C++ programirane v Open GL oz. Direct xOddelek: Programiranje | 3016 (2287) | Vesoljc |
» | OpenGL problemOddelek: Programiranje | 2508 (2074) | Gundolf |
» | Win32 API in C++Oddelek: Programiranje | 1594 (1465) | Monster |
» | OpenGL orr v ansi cOddelek: Programiranje | 1674 (1462) | igor12 |