Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Direct2D factory

I am creating a Direct2D application and the API overview page says the first step is to create a factory... well I tried that with this function

D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &factory);

but it gives the error

Error   62  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

I am calling the D2D1CreateFactory function from within the WinMain function.

This is how I initialized the factory pointer

ID2D1Factory *factory;

These are the Include and Library Directories

C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86

I have experience with direct3D so I am familiar with devices and render targets, but I was under the impression that for direct2D the factory comes first so I haven't created any devices, render targets, etc...

Any help is appreciated.

like image 700
Display name Avatar asked Oct 19 '25 13:10

Display name


1 Answers

Try to add to your code this directive.

#pragma comment(lib, "d2d1.lib")

It will link d2d1.lib to your object code. You may use this directive to link to the other libs.

like image 62
Mykola Avatar answered Oct 21 '25 01:10

Mykola