gdi裝置獲取的源頭, 同樣是通過底層驅動來進行實現
pgraphics_device
ntapi
engpregistergraphicsdevice(
punicode_string pustrdevicename,
punicode_string pustrdiplaydrivers,
punicode_string pustrdescription,
pdevmodew pdmdefault)
/* try to open the driver */
// 找到gdi裝置獲取的初始源頭了,就是這裡
status = iogetdeviceobjectpointer(pustrdevicename,
file_read_data | file_write_data,
&pfileobject,
&pdeviceobject);
if (!nt_success(status))
/* enable the device */
engfilewrite(pfileobject, &benable, sizeof(bool), &cj);
/* copy the device and file object pointers */
pgraphicsdevice->deviceobject = pdeviceobject;
pgraphicsdevice->fileobject = pfileobject;
/* copy device name */
wcsncpy(pgraphicsdevice->szntdevicename,
pustrdevicename->buffer,
sizeof(pgraphicsdevice->szntdevicename) / sizeof(wchar));
/* create a win device name (fixme: virtual devices!) */
swprintf(pgraphicsdevice->szwindevicename, l"\\\\.\\video%d", (char)gidevnum);
/* allocate a buffer for the strings */
cj = pustrdiplaydrivers->length + pustrdescription->length + sizeof(wchar);
pwsz = exallocatepoolwithtag(pagedpool, cj, gditag_drvsup);
if (!pwsz)
/* copy display driver names */
pgraphicsdevice->pdiplaydrivers = pwsz;
rtlcopymemory(pgraphicsdevice->pdiplaydrivers,
pustrdiplaydrivers->buffer,
pustrdiplaydrivers->length);
/* copy description */
pgraphicsdevice->pwszdescription = pwsz + pustrdiplaydrivers->length / sizeof(wchar);
rtlcopymemory(pgraphicsdevice->pwszdescription,
pustrdescription->buffer,
pustrdescription->length + sizeof(wchar));
/* initialize the pdevmodeinfo list and default index */
pgraphicsdevice->pdevmodeinfo = null;
pgraphicsdevice->idefaultmode = 0;
pgraphicsdevice->icurrentmode = 0;
// fixme: initialize state flags
pgraphicsdevice->stateflags = 0;
/* loop through the driver names
* this is a reg_multi_sz string */
for (; *pwsz; pwsz += wcslen(pwsz) + 1)
/* get the mode list from the driver */
pdminfo = ldevobj_pdmigetmodes(pldev, pdeviceobject);
if (!pdminfo)
/* attach the mode info to the device */
pdminfo->pdminext = pgraphicsdevice->pdevmodeinfo;
pgraphicsdevice->pdevmodeinfo = pdminfo;
/* count devmodes */
pdmend = (devmodew*)((pchar)pdminfo->adevmode + pdminfo->cbdevmode);
for (pdm = pdminfo->adevmode;
pdm + 1 <= pdmend;
pdm = (devmodew*)((pchar)pdm + pdm->dmsize + pdm->dmdriverextra))
// fixme: release the driver again until it's used?
}if (!pgraphicsdevice->pdevmodeinfo || cmodes == 0)
/* allocate an index buffer */
pgraphicsdevice->cdevmodes = cmodes;
pgraphicsdevice->pdevmodelist = exallocatepoolwithtag(pagedpool,
cmodes * sizeof(devmodeentry),
gditag_gdevice);
if (!pgraphicsdevice->pdevmodelist)
/* loop through all devmodeinfos */
for (pdminfo = pgraphicsdevice->pdevmodeinfo, i = 0;
pdminfo;
pdminfo = pdminfo->pdminext)
/* initialize the entry */
pgraphicsdevice->pdevmodelist[i].dwflags = 0;
pgraphicsdevice->pdevmodelist[i].pdm = pdm;
i++;}}
/* lock loader */
engacquiresemaphore(ghsemgraphicsdevicelist);
/* insert the device into the global list */
pgraphicsdevice->pnextgraphicsdevice = gpgraphicsdevicelast;
gpgraphicsdevicelast = pgraphicsdevice;
if (!gpgraphicsdevicefirst)
gpgraphicsdevicefirst = pgraphicsdevice;
/* increment device number */
gidevnum++;
/* unlock loader */
engreleasesemaphore(ghsemgraphicsdevicelist);
dprint("prepared %ld modes for %ls\n", cmodes, pgraphicsdevice->pwszdescription);
return pgraphicsdevice;
}static bool isdirectdrawsupported()
dx9裡面的這個功能原來是直接呼叫 dc裡面的資訊來返回啊,哈哈
gdi和dx其實使用的是同乙個顯示驅動, 只不過由於gdi是專門為桌面系統而進行封裝的, 物件遊戲使用來說顯然效率、易用性方面還大大不足, 於是根據用途不同就分成了gdi和dx的區別
GDI 和GDI兩種方式畫線
hdc hdc paintstruct ps hpen hpen hpen hpenold hdc beginpaint hwnd,ps hpen createpen ps solid,3,rgb 255,0,0 hpenold hpen selectobject hdc,hpen movetoex...
GDI和GDI 的應用場合思考
gdi是微軟公司的著名的二維圖形引擎,gdi 則是微軟公司為了提高顯示效果而推出的一種新型圖形引擎。下面我就我的一些使用經驗闡述二者適用的應用場合 gdi基本能滿足一般的繪圖要求。我覺得gdi最令人詬病的是它畫出來的線顯示的鋸齒實在比較厲害,挑剔的客戶會不滿意 注 autocad的繪製二維線應該是使...
GDI和GDI 的應用場合思考
gdi是微軟公司的著名的二維圖形引擎,gdi 則是微軟公司為了提高顯示效果而推出的一種新型圖形引擎。下面我就我的一些使用經驗闡述二者適用的應用場合 gdi基本能滿足一般的繪圖要求。我覺得gdi最令人詬病的是它畫出來的線顯示的鋸齒實在比較厲害,挑剔的客戶會不滿意 注 autocad的繪製二維線應該是使...