Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows API
  4. Direct2d dilemma

Direct2d dilemma

Scheduled Pinned Locked Moved Windows API
helpc++visual-studiocomtutorial
12 Posts 4 Posters 23 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Ben Aldhouse
    wrote on last edited by
    #1

    I've been trying to get the example code at https://msdn.microsoft.com/en-us/library/windows/desktop/dd370994%28v=vs.85%29.aspx[^] to work for me. It's a struggle for me. One problem I think I've narrowed down is with the line

    	// Create the window.
        m\_hwnd = CreateWindow(
            L"D2DDemoApp",
            L"Direct2D Demo App",
            WS\_OVERLAPPEDWINDOW,
            CW\_USEDEFAULT,
            CW\_USEDEFAULT,
            static\_cast(ceil(640.f \* \*dpiX / 96.f)),
            static\_cast(ceil(480.f \* \*dpiY / 96.f)),
            NULL,
            NULL,
            HINST\_THISCOMPONENT,
            this
            );
    

    I think I am getting unstuck on the paramaters which call the ceil function... The compiler gives...

    c:\users\ben\dropbox\programming\direct2d\usingdirect2d\usingdirect2d\usingdirect2d\usingdirect2d.cpp(405): error C2100: illegal indirection

    Any ideas welcome! Cheers

    S L B 3 Replies Last reply
    0
    • B Ben Aldhouse

      I've been trying to get the example code at https://msdn.microsoft.com/en-us/library/windows/desktop/dd370994%28v=vs.85%29.aspx[^] to work for me. It's a struggle for me. One problem I think I've narrowed down is with the line

      	// Create the window.
          m\_hwnd = CreateWindow(
              L"D2DDemoApp",
              L"Direct2D Demo App",
              WS\_OVERLAPPEDWINDOW,
              CW\_USEDEFAULT,
              CW\_USEDEFAULT,
              static\_cast(ceil(640.f \* \*dpiX / 96.f)),
              static\_cast(ceil(480.f \* \*dpiY / 96.f)),
              NULL,
              NULL,
              HINST\_THISCOMPONENT,
              this
              );
      

      I think I am getting unstuck on the paramaters which call the ceil function... The compiler gives...

      c:\users\ben\dropbox\programming\direct2d\usingdirect2d\usingdirect2d\usingdirect2d\usingdirect2d.cpp(405): error C2100: illegal indirection

      Any ideas welcome! Cheers

      S Offline
      S Offline
      Shao Voon Wong
      wrote on last edited by
      #2

      Is dpiX a ptr? If not, remove the asterisk. static_cast(ceil(640.f * dpiX / 96.f)),

      B 1 Reply Last reply
      0
      • B Ben Aldhouse

        I've been trying to get the example code at https://msdn.microsoft.com/en-us/library/windows/desktop/dd370994%28v=vs.85%29.aspx[^] to work for me. It's a struggle for me. One problem I think I've narrowed down is with the line

        	// Create the window.
            m\_hwnd = CreateWindow(
                L"D2DDemoApp",
                L"Direct2D Demo App",
                WS\_OVERLAPPEDWINDOW,
                CW\_USEDEFAULT,
                CW\_USEDEFAULT,
                static\_cast(ceil(640.f \* \*dpiX / 96.f)),
                static\_cast(ceil(480.f \* \*dpiY / 96.f)),
                NULL,
                NULL,
                HINST\_THISCOMPONENT,
                this
                );
        

        I think I am getting unstuck on the paramaters which call the ceil function... The compiler gives...

        c:\users\ben\dropbox\programming\direct2d\usingdirect2d\usingdirect2d\usingdirect2d\usingdirect2d.cpp(405): error C2100: illegal indirection

        Any ideas welcome! Cheers

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        How did your copy/paste manage to add the extra asterisks before dpiX and dpiY?

        B 1 Reply Last reply
        0
        • L Lost User

          How did your copy/paste manage to add the extra asterisks before dpiX and dpiY?

          B Offline
          B Offline
          Ben Aldhouse
          wrote on last edited by
          #4

          Good point. Bad pointer operator placement.

          1 Reply Last reply
          0
          • S Shao Voon Wong

            Is dpiX a ptr? If not, remove the asterisk. static_cast(ceil(640.f * dpiX / 96.f)),

            B Offline
            B Offline
            Ben Aldhouse
            wrote on last edited by
            #5

            Thanks for this. I'd clearly been messing around trying to get it to work when it was probably something else.

            1 Reply Last reply
            0
            • B Ben Aldhouse

              I've been trying to get the example code at https://msdn.microsoft.com/en-us/library/windows/desktop/dd370994%28v=vs.85%29.aspx[^] to work for me. It's a struggle for me. One problem I think I've narrowed down is with the line

              	// Create the window.
                  m\_hwnd = CreateWindow(
                      L"D2DDemoApp",
                      L"Direct2D Demo App",
                      WS\_OVERLAPPEDWINDOW,
                      CW\_USEDEFAULT,
                      CW\_USEDEFAULT,
                      static\_cast(ceil(640.f \* \*dpiX / 96.f)),
                      static\_cast(ceil(480.f \* \*dpiY / 96.f)),
                      NULL,
                      NULL,
                      HINST\_THISCOMPONENT,
                      this
                      );
              

              I think I am getting unstuck on the paramaters which call the ceil function... The compiler gives...

              c:\users\ben\dropbox\programming\direct2d\usingdirect2d\usingdirect2d\usingdirect2d\usingdirect2d.cpp(405): error C2100: illegal indirection

              Any ideas welcome! Cheers

              B Offline
              B Offline
              Ben Aldhouse
              wrote on last edited by
              #6

              I've taken away the extra asterisks. Now I get a problem which produces the compiler error

              1>UsingDirect2D.obj : error LNK2019: unresolved external symbol _D2D1CreateFactory@16 referenced in function "long __cdecl D2D1CreateFactory(enum D2D1_FACTORY_TYPE,struct _GUID const &,void * *)" (?D2D1CreateFactory@@YAJW4D2D1_FACTORY_TYPE@@ABU_GUID@@PAPAX@Z)

              This is where I call D2D1CreateFactory(...)

              HRESULT DemoApp::CreateDeviceIndependentResources(){
              HRESULT hr = S_OK;

              // Create a Direct2D factory.
              hr = D2D1CreateFactory(D2D1\_FACTORY\_TYPE\_SINGLE\_THREADED, &m\_pDirect2dFactory);
              
              return hr;
              

              }

              And I do have

              #include

              at the top of the file. Cheers for any help.

              L 1 Reply Last reply
              0
              • B Ben Aldhouse

                I've taken away the extra asterisks. Now I get a problem which produces the compiler error

                1>UsingDirect2D.obj : error LNK2019: unresolved external symbol _D2D1CreateFactory@16 referenced in function "long __cdecl D2D1CreateFactory(enum D2D1_FACTORY_TYPE,struct _GUID const &,void * *)" (?D2D1CreateFactory@@YAJW4D2D1_FACTORY_TYPE@@ABU_GUID@@PAPAX@Z)

                This is where I call D2D1CreateFactory(...)

                HRESULT DemoApp::CreateDeviceIndependentResources(){
                HRESULT hr = S_OK;

                // Create a Direct2D factory.
                hr = D2D1CreateFactory(D2D1\_FACTORY\_TYPE\_SINGLE\_THREADED, &m\_pDirect2dFactory);
                
                return hr;
                

                }

                And I do have

                #include

                at the top of the file. Cheers for any help.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                That is a linker error, as identified by the LNKxxx message, nothing to do with header files. A header file merely contains the definitions for external functions, classes etc. The actual implementation will be in an external library (or DLL) that also needs to be included in your build; in your case D2d1.lib.

                B 1 Reply Last reply
                0
                • L Lost User

                  That is a linker error, as identified by the LNKxxx message, nothing to do with header files. A header file merely contains the definitions for external functions, classes etc. The actual implementation will be in an external library (or DLL) that also needs to be included in your build; in your case D2d1.lib.

                  B Offline
                  B Offline
                  Ben Aldhouse
                  wrote on last edited by
                  #8

                  That looks like good advice. Sorry for pestering you with what must look silly questions to you. I really appreciate your help! I did a search for d2d1.lib and found four instances on my computer. I chose one and have tried to add it into my project dependencies under 'Linker/input/additional dependencies' but get an error

                  1>LINK : fatal error LNK1104: cannot open file ',.obj'

                  Here is the string I have got in that field...

                  kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;dwrite.lib;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64\d2d1.lib;%(AdditionalDependencies),

                  Is this the right place to add a library file include for the build? If so I guess it's a formatting problem or the wrong file or something... Thanks

                  L J 2 Replies Last reply
                  0
                  • B Ben Aldhouse

                    That looks like good advice. Sorry for pestering you with what must look silly questions to you. I really appreciate your help! I did a search for d2d1.lib and found four instances on my computer. I chose one and have tried to add it into my project dependencies under 'Linker/input/additional dependencies' but get an error

                    1>LINK : fatal error LNK1104: cannot open file ',.obj'

                    Here is the string I have got in that field...

                    kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;dwrite.lib;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64\d2d1.lib;%(AdditionalDependencies),

                    Is this the right place to add a library file include for the build? If so I guess it's a formatting problem or the wrong file or something... Thanks

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    I think you need to remove that comma after %(AdditionalDependencies). I also tend to put only the 'bare' library names in the additional dependencies field. If a library is in a non-standard directory then I add that directory to the list in the "Additional Library Directories" field in the General Linker properties. Try that and see if it now builds OK.

                    B 1 Reply Last reply
                    0
                    • B Ben Aldhouse

                      That looks like good advice. Sorry for pestering you with what must look silly questions to you. I really appreciate your help! I did a search for d2d1.lib and found four instances on my computer. I chose one and have tried to add it into my project dependencies under 'Linker/input/additional dependencies' but get an error

                      1>LINK : fatal error LNK1104: cannot open file ',.obj'

                      Here is the string I have got in that field...

                      kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;dwrite.lib;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64\d2d1.lib;%(AdditionalDependencies),

                      Is this the right place to add a library file include for the build? If so I guess it's a formatting problem or the wrong file or something... Thanks

                      J Offline
                      J Offline
                      Jochen Arndt
                      wrote on last edited by
                      #10

                      If you don't want to edit your project settings you can also specify the library in one of your source files by using:

                      #pragma comment( lib, "d2d1" )

                      But this still requires that the library is located in a directory that is part of the library search paths. So you should add the path if necessary as suggested by Richard (which is generally a good idea for Windows SDKs like in your case).

                      B 1 Reply Last reply
                      0
                      • L Lost User

                        I think you need to remove that comma after %(AdditionalDependencies). I also tend to put only the 'bare' library names in the additional dependencies field. If a library is in a non-standard directory then I add that directory to the list in the "Additional Library Directories" field in the General Linker properties. Try that and see if it now builds OK.

                        B Offline
                        B Offline
                        Ben Aldhouse
                        wrote on last edited by
                        #11

                        That was another good suggestion. That must have got left in from some old attempt to edit the string. In the end I used the

                        #pragma comment( lib, "d2d1" )

                        line that someone else suggested. At last I've got this thing to compile and run! Thanks again for your help.

                        1 Reply Last reply
                        0
                        • J Jochen Arndt

                          If you don't want to edit your project settings you can also specify the library in one of your source files by using:

                          #pragma comment( lib, "d2d1" )

                          But this still requires that the library is located in a directory that is part of the library search paths. So you should add the path if necessary as suggested by Richard (which is generally a good idea for Windows SDKs like in your case).

                          B Offline
                          B Offline
                          Ben Aldhouse
                          wrote on last edited by
                          #12

                          Thanks, Jochen. This did the trick.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups