Ok, I'm trying to compile some C++ source with BlitzMax as I'm doing a little experimenting with DirectX. The C++ code compiles fine in C++ but when Imported into BlitzMax I get the error: Undefined Reference to Direct3DCreate9@4. <-- Bah No thats no a real E-Mail address...
I'm thinking this is because there's a missing Lib or something but I'm using other Direct3D commands and they aren't exibiting the same behavious. Unless it breaks the complimation at the first undefined reference. I have tried using: #pragma comment(lib, "libd3d9.a") with no luck at all.
What do I do, Im lost :( BTW Here's the code:
main.cpp
test.bmx
I'm also getting another error: undefined reference to `iGraphics3D' but Im assuming thats because its failing to link the Direct3DCreate9 function.
Also, Here are the libraries I am using. They are a Direct convert from the Visual Studio lib style library format into MinGW compatible .a format.
Thanks in Advance.
I'm thinking this is because there's a missing Lib or something but I'm using other Direct3D commands and they aren't exibiting the same behavious. Unless it breaks the complimation at the first undefined reference. I have tried using: #pragma comment(lib, "libd3d9.a") with no luck at all.
What do I do, Im lost :( BTW Here's the code:
main.cpp
#include "d3d9.h" struct D3DWindow { WNDCLASS wClass; HINSTANCE hInstance; }; struct D3DDevice { IDirect3D9 *m_Object; IDirect3DDevice9 *m_Device; HWND hWnd; }; LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); D3DDevice Device; D3DWindow Window; bool App_Run; void iMessagePump(void) { MSG Msg; while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } } void iCleanup(void) { if(Device.m_Device) Device.m_Device->Release(); if(Device.m_Object) Device.m_Object->Release(); if(Device.hWnd) DestroyWindow(Device.hWnd); } void iGraphics3D(int Width, int Height, int Depth, int Fullscreen) { DWORD Style; if(Fullscreen) Style = WS_POPUP | WS_VISIBLE; else Style = WS_OVERLAPPED | WS_SYSMENU | WS_VISIBLE; Window.hInstance = GetModuleHandle(0); Window.wClass.style = CS_OWNDC; Window.wClass.cbClsExtra = 0; Window.wClass.cbWndExtra = 0; Window.wClass.hInstance = Window.hInstance; Window.wClass.hIcon = LoadIcon(NULL,IDI_APPLICATION); Window.wClass.hCursor = LoadCursor(NULL,IDC_ARROW); Window.wClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); Window.wClass.lpszMenuName = NULL; Window.wClass.lpszClassName = "Engine"; Window.wClass.lpfnWndProc = WndProc; RegisterClass(&Window.wClass); Device.m_Object = Direct3DCreate9(D3D_SDK_VERSION); Device.hWnd = CreateWindow("Engine", "Test", Style, 150, 150, Width, Height, NULL, NULL, Window.hInstance, NULL); D3DPRESENT_PARAMETERS dParam; ZeroMemory(&dParam, sizeof(dParam)); dParam.BackBufferCount = 1; dParam.MultiSampleType = D3DMULTISAMPLE_NONE; dParam.MultiSampleQuality = 0; dParam.SwapEffect = D3DSWAPEFFECT_DISCARD; dParam.Flags = 0; dParam.hDeviceWindow = Device.hWnd; dParam.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; dParam.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; dParam.BackBufferFormat = D3DFMT_R5G6B5; dParam.EnableAutoDepthStencil = false; if(Fullscreen) { dParam.BackBufferWidth = Width; dParam.BackBufferHeight = Height; dParam.Windowed = false; ShowCursor(false); } else dParam.Windowed = true; Device.m_Object->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Device.hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &dParam, &Device.m_Device); App_Run = true; if(Device.m_Object = NULL) App_Run = false; if(Device.m_Device == NULL) App_Run = false; } void iRenderWorld() { Device.m_Device->Clear(0, NULL, D3DCLEAR_TARGET, 0x00000000, 1.0, 0); Device.m_Device->BeginScene(); Device.m_Device->EndScene(); } void iFlip(bool VWait = true) { Device.m_Device->Present(NULL, NULL, NULL, NULL); } LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_PAINT: break; case WM_DESTROY: App_Run = false; break; case WM_KEYDOWN: App_Run = false; break; } return DefWindowProc(hWnd, Message, wParam, lParam); }
test.bmx
Import "main.cpp" Extern Function iGraphics3D(Width, Height, Depth, Fullscreen) Function iMessagePump() Function iCleanup() Function iRenderWorld() Function iFlip(VSync:Int) End Extern iGraphics3D(800, 600, 32, 0)
I'm also getting another error: undefined reference to `iGraphics3D' but Im assuming thats because its failing to link the Direct3DCreate9 function.
Also, Here are the libraries I am using. They are a Direct convert from the Visual Studio lib style library format into MinGW compatible .a format.
Thanks in Advance.