موضوع : بدست آوردن مشخصات و تواناييهاي گرافيکي يک سيستم توسط DirectX-Graphic
1 - شمارش تعداد آداپتورهاي گرافيکي يک سيستم : فرض کنيد متغير nAdapters متغيري از نوع long باشد . همچنين شي D3DADAPTER_IDENTIFIER8 يک ساختار است که اطلاعات مربوط به آداپتور را نگه مي دارد . در اينصورت روتين enumerateAdapters بصورت زير خواهد بود : Dim adapterinfo as D3DADAPTER_IDENTIFIER8 Private Sub EnumerateAdapters Dim i as integer nadapters=D3D.Getadaptercount
براي بدست آوردن جزئيات آداپبورها بصورت زير عمل مي کنيم : for i=0 to nadapters-1 D3D.GetadapterIdentifier i ,0,adapterinfo نام اين آداپتور بصورت ليستي از کدهاي اسکي است که بايستي آنها را درون يک string قرار دهيم : for j=0 to 511 name=name & chr$(adapterinfo.description(j)) x next j name=replace(name,chr$(0),'' '') x end sub بنابراين در متغير name نام آداپتور قرار خواهد گرفت .
? - مشخص کردن نوع Rendering : فرض کنيد شي D3DCAPS8 توانايي rendering آداپتور را نشان دهد . در اينصورت روتين EnumerateDevices بصورت زير خواهد بود : Private EnumerateDevices On Local Error resume next Dim Caps as D3DCAPS8 deviceindex=0 'For Example D3D.Getdevicecaps deviceindex,D3DDEVTYPE_HAL,caps if err.number=D3DERR_NOTAVAILABLE then
اگر آداپتور امکان رندر سخت افزاري نداشته باشد در اينصورت : MsgBox(''Reference Rasterizer(REF)'') x else MsgBox(''Hardware Acceleration(HAL)+Reference Rasterizer(REF)'') x end if end sub
3 - شمارش تعداد Mode نمايشي آداپتور : فرض کنيد در صورت REF بودن امکان رندر ، متغير r=2 و در غيراينصورت r=1 باشد . همچنين شي D3DDISPLAYMODE اطلاعات مدهاي نمايشي را در خود دارد . همچنين فرض کنيد متغير nModes از نوع longباشد . در اينصورت روتين enumeratedispmodes بصورت زير خواهد بود : Private Sub EnumerateDispModes(r as Long,n as Long) x Dim i as integer Dim mode_tmp as D3DDISPLAYMODE deviceindex=0 'For Example nModes=D3D.Getadaptermodecount(deviceindex) x for i=0 to nModes-1 D3D.EnumAdapterModes(deviceindex,i,mode_tmp) x ابتدا Mode ها را به دو گروه ?? بيتي و ?? بيتي تقسيم مي کنيم : if mode_tmp.format=D3DFMT_R8G8B8 or mode_tmp=D3DFMT_X8R8G8B8 or mode_tmp=D3DFMT_A8R8G8B8 then حال چک مي کنيم که device قابل پذيرش و معتبر است يا نه : if D3D.checkdevicetype(deviceindex,r,mode_tmp.format,mode_tm p.format,Flase)>=0 then MsgBox(mode_tmp.width & ''X'' & mode_tmp.height & ''32 Bit FMT:'' & mode_tmp.format ) x & '' end if else if D3D.checkdevicetype(deviceindex,r,mode_tmp.format,mode_tm p.format,Flase)>=0 then MsgBox(mode_tmp.width & ''X'' & mode_tmp.height & ''16 BitFMT:'' & mode_tmp.format ) x & end if end if next i
4 - مشخص کردن توانايي هاي آداپتور گرافيکي : فرض کنيد در صورت REF بودن امکان رندر ، متغير r=2 و در غيراينصورت r=1 باشد : Private Sub EnumerateHardware(r as long) x Dim caps as D3DCAPS8 D3D.Getdevicecaps deviceindex,r,caps If Caps.MaxActiveLights = -1 Then MsgBox ''Maximum Active Lights: Unlimited'' x Else MsgBox ''Maximum Active Lights: '' & Caps.MaxActiveLights End If MsgBox ''Maximum Point Vertex size: '' & Caps.MaxPointSize MsgBox ''Maximum Texture Size: '' & Caps.MaxTextureWidth & ''X'' & Caps.MaxTextureHeight MsgBox ''Maximum Primatives in one call: '' & Caps.MaxPrimitiveCount If Caps.TextureCaps And D3DPTEXTURECAPS_SQUAREONLY Then MsgBox ''Textures must always be square'' x End If If Caps.TextureCaps And D3DPTEXTURECAPS_CUBEMAP Then MsgBox ''Device Supports Cube Mapping'' x End If If Caps.TextureCaps And D3DPTEXTURECAPS_VOLUMEMAP Then MsgBox ''Device Supports Volume Mapping'' x End If If Caps.DevCaps And D3DDEVCAPS_PUREDEVICE Then MsgBox ''Device supports the Pure Device Option'' x End If If Caps.DevCaps And D3DDEVCAPS_HWTRANSFORMANDLIGHT Then MsgBox ''Device supports hardware transform and lighting'' x End If If Caps.DevCaps And D3DDEVCAPS_HWRASTERIZATION Then MsgBox ''Device can use Hardware Rasterization'' x End If If Caps.Caps2 And D3DCAPS2_CANCALIBRATEGAMMA Then MsgBox ''Device can Calibrate Gamma'' x End If If Caps.Caps2 And D3DCAPS2_CANRENDERWINDOWED Then MsgBox ''Device can Render in Windowed Mode'' x End If If Caps.Caps2 And D3DCAPS2_FULLSCREENGAMMA Then MsgBox ''Device can calibrate gamma in fullscreen mode'' x End If If Caps.RasterCaps And D3DPRASTERCAPS_FOGRANGE Then MsgBox ''Device supports range based fog calculations'' x End If If Caps.RasterCaps And D3DPRASTERCAPS_ANISOTROPY Then MsgBox ''Device supports Anisotropic Filtering'' x End If If Caps.RasterCaps And D3DPRASTERCAPS_ZBUFFERLESSHSR Then MsgBox ''Device does not require a Z-Buffer/Depth Buffer'' x End If
|