Welcome to Dream.In.Code
Become an Expert!

Join 149,609 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,847 people online right now. Registration is fast and FREE... Join Now!




Getting Direct X to Work On MinGW PLEAS HELP!

 
Reply to this topicStart new topic

Getting Direct X to Work On MinGW PLEAS HELP!, Configuring directx

HermosaBeach
2 Sep, 2007 - 11:45 PM
Post #1

New D.I.C Head
*

Joined: 30 Aug, 2007
Posts: 11


My Contributions
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


CODE


#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:


CODE

--------------------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)

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 12:15AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month