Results 1 to 2 of 2

Thread: question on my directx wrapper sll...

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2003
    Posts
    56

    question on my directx wrapper sll...

    ive got a dx wrapper using static link library

    this is the sll code
    Code:
    #include <windows.h>
    #include <stdio.h>
    #include <d3d9.h>
    #include <d3dx9.h>
    #include <d3dx9core.h>
    
    void ADrawText(LPDIRECT3DDEVICE9 a,LPD3DXFONT b )
    {
    	HDC hDC= GetDC( NULL );
        int nHeight= -( MulDiv( 12, GetDeviceCaps(hDC, LOGPIXELSY), 72 ) );
        ReleaseDC( NULL, hDC );
    
        HFONT hFont = CreateFont(nHeight, 
                            0, 0, 0,
                            500,
                            false, false, false,
                            DEFAULT_CHARSET,
                            OUT_DEFAULT_PRECIS,
                            CLIP_DEFAULT_PRECIS,
                            DEFAULT_QUALITY,
                            DEFAULT_PITCH | FF_DONTCARE,
                            "Times New Roman" );
    
    	 D3DXCreateFont( a, hFont, &b );
    	 DeleteObject( hFont );
    
    	RECT destRect1;
    	SetRect( &destRect1, 200, 30, 0, 0 );
    
    	b->DrawText("hi there, -1, &destRect1, DT_SINGLELINE, D3DCOLOR_XRGB(250,250,250) );
    }
    and this is how i run it in my program
    Code:
    ADrawText(g_pd3dDevice,g_pd3dxFont);
    My question is, is it possible to just have ADrawText();
    instead of having to tell it what the devices etc are?
    If so how would i go about it?
    i just realised i spelt my name wrong....

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You could let the library have references to global variables that are declared as extern in the library header file and then defined in your real app. This is extremly bad style however.

    Besides, your ADrawText has a leak: it never deletes the D3DX font, but creates a new one every call (which leaves you to delete the font - bad manner).
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width