Original Post
Ok, for some strange reason, Direct3D can't be created. I made a lib with a class inside it. everything compiled fine. i made a window and put the renderer in it. but for some reason, i get the message box that i programmed into it to tell me about Direct3D not being created. Do you see ANYTHING wrong with this code? what do you think it could be that stops Direct3D9 from being created?
#include "Cor_Direct3D9.h"
int Cor_Direct3DRenderer::Cor_InitializeDirect3D9(HWND hwnd, int width, int height, bool fullscreen)
{
//check and see if Direct3D9 is ok.
Cor_Direct3D9 = Direct3DCreate9(D3D_SDK_VERSION);
//If it couldn't work, display MessageBox
if(Cor_Direct3D9 != D3D_OK)
{
MessageBoxA(NULL,"Direct3D Could not be created","Error",MB_OK);
return 0;
}
HRESULT result = Cor_Direct3D9->CheckDeviceType(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,D3DFMT_X8R8G8B8,D3DFMT_X8R8G8B8,true);
if(FAILED(result))
{
MessageBoxA(NULL,"The device type could not be created","Error",MB_OK);
return 0;
}
ZeroMemory(&Cor_PresentParams,sizeof(Cor_PresentParams));
Cor_PresentParams.Windowed = (!fullscreen);
Cor_PresentParams.BackBufferCount = 3;
Cor_PresentParams.SwapEffect = D3DSWAPEFFECT_COPY;
Cor_PresentParams.BackBufferWidth = width;
Cor_PresentParams.BackBufferHeight = height;
Cor_PresentParams.BackBufferFormat = D3DFMT_X8R8G8B8;
Cor_PresentParams.hDeviceWindow = hwnd;
result = Cor_Direct3D9->CreateDevice(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hwnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&Cor_PresentParams,
&Cor_Direct3DDevice9);
if(FAILED(result))
{
MessageBoxA(NULL,"Could not create the device","Error",MB_OK);
return 0;
}
Cor_Direct3DDevice9->Clear(0,0,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0);
Cor_Direct3DDevice9->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&Cor_BackBuffer);
return 1;
}
int Cor_Direct3DRenderer::Cor_Sync()
{
if(Cor_Direct3DDevice9->BeginScene())
{
Cor_Direct3DDevice9->EndScene();
}
Cor_Direct3DDevice9->Present(NULL,NULL,NULL,NULL);
return 1;
}