0 Replies - 2658 Views - Last Post: 03 September 2007 - 12:45 AM Rate Topic: -----

#1 HermosaBeach  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 30-August 07

Getting Direct X to Work On MinGW PLEAS HELP!

Post icon  Posted 03 September 2007 - 12:45 AM

OK , aside from my prior topic of getting opengl to work , Im trying to get direct x 9 to work on MinGW. I almost have it . Hers what I got



#include <windows.h>
#include <d3d9.h>

HWND hWnd;
LPDIRECT3D9 pD3D;
LPDIRECT3DDEVICE9 pDevice; 

LRESULT CALLBACK WndProc( HWND hWnd , UINT message , 
	WPARAM wParam , LPARAM lParam){
	switch(message){ 
	case WM_CLOSE: 
		PostQuitMessage(0); 
		return 0; 
	} 
	return DefWindowProc(hWnd,message,wParam,lParam); 
}

bool CreateSimpWindow(int width, int height){

	// Create A Window Class Structure 
	WNDCLASSEX wc;
	wc.cbClsExtra = 0;
	wc.cbSize = sizeof(wc); 
	wc.cbWndExtra = 0; 
	wc.hbrBackground = NULL;
	wc.hCursor = NULL; 
	wc.hIcon = NULL; 
	wc.hIconSm = NULL; 
	wc.hInstance = GetModuleHandle(NULL);
	wc.lpfnWndProc = WndProc;
	wc.lpszClassName = "X3D"; 
	wc.lpszMenuName = NULL;
	wc.style = CS_VREDRAW|CS_HREDRAW|CS_OWNDC;

	// Register Window Class
	RegisterClassEx(&wc); 

	// Create Window 
	hWnd = CreateWindowEx(0, 
	   "X3D", "X3D Direct3D Tutorial 1", 
	   WS_OVERLAPPEDWINDOW|WS_VISIBLE, 100,100,width,height,
	   NULL,NULL,wc.hInstance,0);

	return true;
}

bool InitD3D(){
	if((pD3D = Direct3DCreate9(D3D_SDK_VERSION))==NULL){
		return false;
	}
	D3DDISPLAYMODE d3ddm;
	pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);
	D3DPRESENT_PARAMETERS d3dpp;
	ZeroMemory(&d3dpp, sizeof(d3dpp));
	d3dpp.BackBufferFormat = d3ddm.Format;
	d3dpp.Windowed = true;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	if(FAILED(pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
	hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice))){
		return false;
	}
	return true;
} 

void RenderD3DScene(){
	pDevice->Clear(0,NULL,D3DCLEAR_TARGET,0,1,0);
	pDevice->Present(NULL,NULL,NULL,NULL);
} 

void MessageLoop(){
	MSG msg; 
	while(true){
		RenderD3DScene();
		if(PeekMessage(&msg,hWnd,0,0,PM_REMOVE)){
			 if(msg.message==WM_QUIT)return;
			 TranslateMessage(&msg); 
			 DispatchMessage(&msg); 
		}
	} 
}

INT WINAPI WinMain( HINSTANCE , HINSTANCE , LPSTR , INT ){

	if(!CreateSimpWindow(400, 400))return 1;

	if(!InitD3D())return 2; 

	MessageLoop(); 
	
	
	return 0;
} 



HERES THE ERRORS:


--------------------Configuration: DirectxTEST - Debug--------------------
Compiling source file(s)...
Direct.cpp
Direct.cpp:92:3: warning: no newline at end of file
Linking...
C:\Documents and Settings\R-A-C\Desktop\test\Debug\Direct.o: In function `Z7InitD3Dv':
C:\Documents and Settings\R-A-C\Desktop\test\Direct.cpp:48: undefined reference to `Direct3DCreate9@4'
collect2: ld returned 1 exit status

DirectxTEST.exe - 1 error(s), 1 warning(s)



Is This A Good Question/Topic? 0
  • +

Page 1 of 1