• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
cozzie

Checking d3d caps, best approach?

16 posts in this topic

Hi,

Like any other enthousiast, before releasing my top selling FPS game, I'd like to make my 3d engine/ apps hardware variants proof smile.png

I see doing this with the following steps:

1. Check top 5 items while creating device and select 'lower' value if a specific adapter or bufferformat is not available (same for MSAA). Let's call this the basics (i.e. if MSAA not available, though requested, I select no MSAA and let the user continue). In place today and working fine.

2. Create a list of D3D (related) caps that are needed for the current functionalities, and check if these are available.
For now not available means, too bad. Application quits. I keep these up to date as soon as I add new functionality in my engine.

3. Create backwards compability variances for situaties in '2' where a device doesn't meet the requirements.
Same for the vertex and pixel shaders.

Step 3 is something I'll postpone for now, since I'm using D3D9 and PS/VS 2.0, which most devices today support.

I really to hear your advice and tips to make step 2 more efficient, I've posted the code I have now
(accepting that I send away users with hardware that doesn't meet the requirements smile.png)

 

bool CD3d::CheckDeviceCaps()
{
	int nrReqDevCaps = 9;
	DWORD reqDevCaps[9] =	{	D3DDEVCAPS_DRAWPRIMTLVERTEX,	D3DDEVCAPS_HWRASTERIZATION,		D3DDEVCAPS_TLVERTEXSYSTEMMEMORY, 
								D3DDEVCAPS_TLVERTEXVIDEOMEMORY, D3DPRASTERCAPS_ZBUFFERLESSHSR,	D3DPRASTERCAPS_ZTEST,
								D3DDEVCAPS_EXECUTESYSTEMMEMORY, D3DDEVCAPS_EXECUTEVIDEOMEMORY,  D3DDEVCAPS_TEXTUREVIDEOMEMORY };
	int nrReqPresentCaps = 3;
	DWORD reqPresentCaps[3] = {	D3DPRESENT_INTERVAL_ONE,		D3DPRESENT_INTERVAL_TWO,		D3DPRESENT_INTERVAL_IMMEDIATE };
	int nrReqTexFilterCaps = 4; 
	DWORD reqTexFilterCaps[4]= {D3DPTFILTERCAPS_MAGFLINEAR,		D3DPTFILTERCAPS_MINFLINEAR,		D3DPTFILTERCAPS_MIPFLINEAR,
								D3DPTFILTERCAPS_MINFANISOTROPIC };
	int nrReqPrimMiscCaps =3;
	DWORD reqPrimMiscCaps[3] = {D3DPMISCCAPS_CULLNONE,			D3DPMISCCAPS_CULLCW,			D3DPMISCCAPS_CULLCCW };
	int nrReqTextureCaps = 2;
	DWORD reqTextureCaps[2] = {	D3DPTEXTURECAPS_MIPMAP,			D3DPTEXTURECAPS_ALPHA };		// CUBEMAP and VOLUMEMAP later
	int nrReqTexAddrCaps = 5;
	DWORD reqTexAddrCaps[5] = {	D3DPTADDRESSCAPS_BORDER,		D3DPTADDRESSCAPS_CLAMP,			D3DPTADDRESSCAPS_WRAP,
								D3DPTADDRESSCAPS_INDEPENDENTUV,	D3DPTADDRESSCAPS_MIRROR  };
	int nrReqRasterCaps = 2;
	DWORD reqRasterCaps[2] = {	D3DPRASTERCAPS_ANISOTROPY,		D3DPRASTERCAPS_DITHER };
	int nrReqShadeCaps = 3;
	DWORD reqShadeCaps[3] = {	D3DPSHADECAPS_ALPHAGOURAUDBLEND,D3DPSHADECAPS_SPECULARGOURAUDRGB,
								D3DPSHADECAPS_COLORGOURAUDRGB };
	
	if(mD3d != NULL)
	{
		D3DCAPS9	caps;
		if(D3D_OK != mD3d->GetDeviceCaps(D3DADAPTER_DEFAULT, mDevType, &caps)) return false;
		
		for(cc=0;cc<nrReqDevCaps;++cc)		{ if(!(caps.DevCaps & reqDevCaps[cc])) return false; }
		for(cc=0;cc<nrReqPresentCaps;++cc)	{ if(!(caps.PresentationIntervals & reqPresentCaps[cc])) return false; }
		for(cc=0;cc<nrReqTexFilterCaps;++cc){ if(!(caps.VertexTextureFilterCaps & reqTexFilterCaps[cc])) return false; }
		for(cc=0;cc<nrReqTexAddrCaps;++cc)	{ if(!(caps.TextureAddressCaps & reqTexAddrCaps[cc])) return false; }
		for(cc=0;cc<nrReqPrimMiscCaps;++cc) { if(!(caps.PrimitiveMiscCaps & reqPrimMiscCaps[cc])) return false; }
		for(cc=0;cc<nrReqRasterCaps;++cc)	{ if(!(caps.RasterCaps & reqRasterCaps[cc])) return false; }
		for(cc=0;cc<nrReqShadeCaps;++cc)	{ if(!(caps.ShadeCaps & reqShadeCaps[cc])) return false; }

		if(D3D_OK != mD3d->CheckDeviceFormat(D3DADAPTER_DEFAULT, mDevType, mAdapterFormat, D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_TEXTURE, D3DFMT_X8R8G8B8)) return false;
		if(!(caps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP)) return false;

		if(caps.VertexShaderVersion < D3DVS_VERSION(2,0)) return false;
		if(caps.PixelShaderVersion < D3DPS_VERSION(2,0)) return false;
		if(caps.MaxAnisotropy < 4) return false;
		if(caps.MaxTextureWidth < 256) return false;
		if(caps.MaxTextureHeight < 256) return false;
		if(caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) return false;

		return true;
	}
	else return false;
}

 

Can this be done, easier? (i.e. with an array of DWORD values / caps and the corresponding caps.'' etc.)

Edited by cozzie
0

Share this post


Link to post
Share on other sites

Use multimaps to store possible caps values for a particular d3dcap (Use d3dcap name as the key, if you please). It has several advantages.

 

1) No more iterations to find out a particular capacity. Just a "find" will do.

2) Easy to take different combinations from various multimaps to support different combos in future.

3) Looks much more systematic and better than static arrays and for loops. :-)

1

Share this post


Link to post
Share on other sites

Thanks, that sounds like something I could use.

Is this basically an error which says:

 

Col1                                        Col2

caps.DevCaps                        D3DDEVCAPS_.....

caps.DevCaps                        D3DDEVCAPS_....somethingelse

caps.PresentationsInverals    D3DPRESENT_...something

 

So I can loop through all of them?

 

Do you maybe have a simple example how multimaps would do the above?

Will also try to find out in the mean time (googling :))

0

Share this post


Link to post
Share on other sites

was bit too lazy I suppose, already made a bit of a start:

 

multimap <???, DWORD> capsTable;

 

capsTable.insert(pair<???, DWORD>(caps.DevCaps, D3DDEVCAPS_..something));

and so on

 

- what type should I use for caps.DevCaps? (it's basically also a DWORD I suppose)

- how do I 'use them'; like if(!(capsTable.1st col[0] & capsTable.2nd col[1]) ......

0

Share this post


Link to post
Share on other sites

Don't rush/panic buddy. Multimaps are very easy to figure out and there is tons of reference on google that will always do better than any of my explanations on the same.

As for your query about type of DevCaps, it is a DWORD like almost all other attributes of the structure. Still, MSDN lists all of them with their values. Best would be to define some key of your own. You might very well use a string as a key for different attributes to map and check.

Play around with this a bit, you will get a hang of it and eventually like it. :-)

0

Share this post


Link to post
Share on other sites

Thanks, I think you're right, it is kinda fun :)

 

Up till now I have:

void just4fun()
{
	D3DCAPS9	caps;
	std::multimap <DWORD, DWORD> capsTable;

	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_DRAWPRIMTLVERTEX));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_HWRASTERIZATION));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_TLVERTEXSYSTEMMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_TLVERTEXVIDEOMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DPRASTERCAPS_ZBUFFERLESSHSR));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DPRASTERCAPS_ZTEST));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_EXECUTESYSTEMMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_EXECUTEVIDEOMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_TEXTUREVIDEOMEMORY));

	capsTable.insert(std::make_pair(caps.PresentationIntervals, D3DPRESENT_INTERVAL_ONE));
	capsTable.insert(std::make_pair(caps.PresentationIntervals, D3DPRESENT_INTERVAL_TWO));
	capsTable.insert(std::make_pair(caps.PresentationIntervals, D3DPRESENT_INTERVAL_IMMEDIATE));

	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MAGFLINEAR));
	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MINFLINEAR));
	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MIPFLINEAR));
	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MINFANISOTROPIC));

	std::ofstream test("multimap.txt");

	for (std::multimap<DWORD, DWORD, std::less<DWORD> >::const_iterator iter =capsTable.begin();
      iter != capsTable.end(); ++iter )
	{
		test << iter->first << " " << iter->second << std::endl;
	}

The output though says that the "first" values are all the same..

Will play around to find how it works, maybe this is correct.

 

Output:

3435973836 1024
3435973836 524288
3435973836 64
3435973836 128
3435973836 32768
3435973836 16
3435973836 16
3435973836 32
3435973836 512
3435973836 1
3435973836 2
3435973836 2147483648
3435973836 33554432
3435973836 512
3435973836 131072
3435973836 1024
 

0

Share this post


Link to post
Share on other sites

This post is almost becoming a live chatbox ;-)

Got it working now, maybe not optimal yet, but the result is OK (Tested it by passing a faulty D3D caps value in the 2nd 'colom', and this gives a correct 'not found' back).

 

Here's the code:

void just4fun()
{
	LPDIRECT3D9	mD3d;

	mD3d = Direct3DCreate9(D3D_SDK_VERSION);

	D3DCAPS9	caps;
	mD3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps);

	std::multimap <DWORD, DWORD> capsTable;

	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_DRAWPRIMTLVERTEX));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_HWRASTERIZATION));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_TLVERTEXSYSTEMMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_TLVERTEXVIDEOMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DPRASTERCAPS_ZBUFFERLESSHSR));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DPRASTERCAPS_ZTEST));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_EXECUTESYSTEMMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_EXECUTEVIDEOMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_TEXTUREVIDEOMEMORY));

	capsTable.insert(std::make_pair(caps.PresentationIntervals, D3DPRASTERCAPS_ZTEST));
	capsTable.insert(std::make_pair(caps.PresentationIntervals, D3DPRESENT_INTERVAL_TWO));
	capsTable.insert(std::make_pair(caps.PresentationIntervals, D3DPRESENT_INTERVAL_IMMEDIATE));

	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MAGFLINEAR));
	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MINFLINEAR));
	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MIPFLINEAR));
	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MINFANISOTROPIC));

	std::ofstream test("multimap.txt");

	for (std::multimap<DWORD, DWORD, std::less<DWORD> >::const_iterator iter =capsTable.begin();
      iter != capsTable.end(); ++iter )
	{
//		test << iter->first << " " << iter->second << std::endl;
		if(iter->first & iter->second) MessageBox(NULL, L"Cap found", L"test", MB_OK);
		else MessageBox(NULL, L"Cap not found", L"Test", MB_OK);
	}
	mD3d->Release();
}

 

Maybe I'll put the definition of the capsTable and contents in my header file, to keep code/ function clean.

Thanks for your hints, really looks better and cleaner this way.

 

Any pointers on improving it more, always welcome ;)

0

Share this post


Link to post
Share on other sites

Like I mentioned earlier, you may define your multimap like this :

 

std::multimap <std::string, DWORD> capsTable;

 

This way your key values can be "DevCaps" or "PresentationIntervals" or "VertexTextureFilterCaps" or XYZ", with their associated values always mapped uniquely to them.

Currently you have just associated the structure reference, that's why all the key values came out to be the same.

 

Later on you can expand upon above multimap, by making several distinct multimaps for different attributes and then do some combos. Many ways to make this work elegantly now, its all upto how you want to design this.

0

Share this post


Link to post
Share on other sites

Thanks, I partially understand.

Say I make a multimap which holds i.e.:

 

DevCaps            D3DDEVCAP_something

 

And I want to to a comparison:

 

if(Caps.Devcaps & D3DDEVCAP_something)

 

I got it working now with the reference, but how do I add the D3DCAPS9 structure (say Caps) with a string, to be a valid member indication of Caps?

(Caps.Devcaps)?

0

Share this post


Link to post
Share on other sites

Ok, I will try to give you a use-case which has some real implication and should be in line with your requirements.

 

So what we want to achieve is a container that holds Device cap attributes and possible values for each of these capacities.

 

Now, multimap has a method called equal_range that returns all the values associated to a particular key.

 

Eg.

 

typedef std::multimap<std::string, DWORD> xyzMap;
xyzMap capsTable;

capsTable.insert(std::make_pair("PresentationIntervals", D3DPRASTERCAPS_ZTEST));
capsTable.insert(std::make_pair("PresentationIntervals", D3DPRESENT_INTERVAL_TWO));
capsTable.insert(std::make_pair("PresentationIntervals", D3DPRESENT_INTERVAL_IMMEDIATE));

std::pair<xyzMap::iterator, xyzMap::iterator> range;

range = capsTable.equal_range("PresentationIntervals");

for (xyzMap::iterator it = range.first; it != range.second; ++it)
{
    // Do something with PresentationIntervals values
}

 

 

As it is, you don't have to do anything with the attribute name itself, but the value it holds. So the way I have mentioned above, you can use and expand your implementation to dynamically hold, add and configure your Device cap attributes as you please.

0

Share this post


Link to post
Share on other sites

Thanks, that makes things clear on how to use multimaps.

I'll go play around with it.

 

The only thing I haven't figured out yet, is how I can make a link from the 'fírst' values, say PresentationsIntervals, to the real checking of the caps.

Example:

 

D3DCAPS9 caps;

GetDeviceCaps(&caps).

 

Before multimap:

if(!(caps.PresentationIntervals & D3DPRESENT_INTERVAL_TWO)) return false;

 

With multimap, I don't know how to link the 'caps' var with the member which is in the multimap:

if(!caps.iter->first & iter->lsecond)) return false;

 

The "caps.iter->first" will logically not compile..

Tried this to confirm/ test:

 

std::string test = "MaxAnisotropy";

if(mCaps.test & 4) return false;

0

Share this post


Link to post
Share on other sites

Can you try using some other conditional approach than this one :

if(!(caps.PresentationIntervals & D3DPRESENT_INTERVAL_TWO))

 

You're trying to design around your code, which is wrong. You should always code around your design.

0

Share this post


Link to post
Share on other sites

I believe I'm getting there, got it all working now, but probably not optimal yet.

The part where I go through the loops for checking each group of 'caps', just feels like it's possible to do it more efficient.


To be honest, code is not cleaner then when I filled the multimap with the references to the Caps var, but definitely this brings a lot more flexibility, also for future use.

What do you think?

 

Here are the 2 resulting functions:

 

/**************************************************************************************/
/***						SET REQUIRED DEVICE CAPS								***/
/*** ==> usage: during initalization, before creating d3d device and loading scene	***/
/*** ==> fill mReqCapsTable with all caps needed for existing functionality			***/
/**************************************************************************************/

void CD3d::SetRequiredDeviceCaps()
{
	mReqCapsTable.insert(std::make_pair("DevCaps",					D3DDEVCAPS_DRAWPRIMTLVERTEX));
	mReqCapsTable.insert(std::make_pair("DevCaps",					D3DDEVCAPS_HWRASTERIZATION));
	mReqCapsTable.insert(std::make_pair("DevCaps",					D3DDEVCAPS_TLVERTEXSYSTEMMEMORY));
	mReqCapsTable.insert(std::make_pair("DevCaps",					D3DDEVCAPS_TLVERTEXVIDEOMEMORY));
	mReqCapsTable.insert(std::make_pair("DevCaps",					D3DDEVCAPS_EXECUTESYSTEMMEMORY));
	mReqCapsTable.insert(std::make_pair("DevCaps",					D3DDEVCAPS_EXECUTEVIDEOMEMORY));
	mReqCapsTable.insert(std::make_pair("DevCaps",					D3DDEVCAPS_TEXTUREVIDEOMEMORY));
	mReqCapsTable.insert(std::make_pair("RasterCaps",				D3DPRASTERCAPS_ANISOTROPY));
	mReqCapsTable.insert(std::make_pair("RasterCaps",				D3DPRASTERCAPS_DITHER));
	mReqCapsTable.insert(std::make_pair("RasterCaps",				D3DPRASTERCAPS_ZTEST));
	mReqCapsTable.insert(std::make_pair("PrimitiveMiscCaps",		D3DPMISCCAPS_CULLNONE));
	mReqCapsTable.insert(std::make_pair("PrimitiveMiscCaps",		D3DPMISCCAPS_CULLCW));
	mReqCapsTable.insert(std::make_pair("PrimitiveMiscCaps",		D3DPMISCCAPS_CULLCCW));
	mReqCapsTable.insert(std::make_pair("PrimitiveMiscCaps",		D3DPMISCCAPS_BLENDOP));
	mReqCapsTable.insert(std::make_pair("PresentationIntervals",	D3DPRESENT_INTERVAL_ONE));
	mReqCapsTable.insert(std::make_pair("PresentationIntervals",	D3DPRESENT_INTERVAL_TWO));
	mReqCapsTable.insert(std::make_pair("PresentationIntervals",	D3DPRESENT_INTERVAL_IMMEDIATE));

	mReqCapsTable.insert(std::make_pair("VertexTextureFilterCaps",	D3DPTFILTERCAPS_MAGFLINEAR));
	mReqCapsTable.insert(std::make_pair("VertexTextureFilterCaps",	D3DPTFILTERCAPS_MINFLINEAR));
	mReqCapsTable.insert(std::make_pair("VertexTextureFilterCaps",	D3DPTFILTERCAPS_MIPFLINEAR));
	mReqCapsTable.insert(std::make_pair("VertexTextureFilterCaps",	D3DPTFILTERCAPS_MINFANISOTROPIC));
	mReqCapsTable.insert(std::make_pair("TextureCaps",				D3DPTEXTURECAPS_MIPMAP));
	mReqCapsTable.insert(std::make_pair("TextureCaps",				D3DPTEXTURECAPS_ALPHA));
	mReqCapsTable.insert(std::make_pair("TextureAddressCaps",		D3DPTADDRESSCAPS_BORDER));
	mReqCapsTable.insert(std::make_pair("TextureAddressCaps",		D3DPTADDRESSCAPS_CLAMP));
	mReqCapsTable.insert(std::make_pair("TextureAddressCaps",		D3DPTADDRESSCAPS_WRAP));
	mReqCapsTable.insert(std::make_pair("TextureAddressCaps",		D3DPTADDRESSCAPS_INDEPENDENTUV));
	mReqCapsTable.insert(std::make_pair("TextureAddressCaps",		D3DPTADDRESSCAPS_MIRROR));

	mReqCapsTable.insert(std::make_pair("ShadeCaps",				D3DPSHADECAPS_ALPHAGOURAUDBLEND));
	mReqCapsTable.insert(std::make_pair("ShadeCaps",				D3DPSHADECAPS_SPECULARGOURAUDRGB));
	mReqCapsTable.insert(std::make_pair("ShadeCaps",				D3DPSHADECAPS_COLORGOURAUDRGB));
}

/**************************************************************************************/
/***						CHECK DEVICE CAPS										***/
/*** ==> usage: during initalization, before creating d3d device and loading scene	***/
/*** ==> check if device meets required caps for current functionality				***/
/**************************************************************************************/

bool CD3d::CheckDeviceCaps()
{
	if(mD3d != NULL)
	{
		if(D3D_OK != mD3d->GetDeviceCaps(D3DADAPTER_DEFAULT, mDevType, &mCaps)) return false;
		std::pair<CapsTable::iterator, CapsTable::iterator> range;
		
		range = mReqCapsTable.equal_range("DevCaps");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.DevCaps & it->second)) return false;
		range = mReqCapsTable.equal_range("RasterCaps");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.RasterCaps & it->second)) return false;
		range = mReqCapsTable.equal_range("PrimitiveeMiscCaps");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.PrimitiveMiscCaps & it->second)) return false;
		range = mReqCapsTable.equal_range("PresentationIntervals");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.PresentationIntervals & it->second)) return false;
		range = mReqCapsTable.equal_range("VertexTextureFilterCaps");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.VertexTextureFilterCaps & it->second)) return false;
		range = mReqCapsTable.equal_range("TextureCaps");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.TextureCaps & it->second)) return false;
		range = mReqCapsTable.equal_range("TextureAddressCaps");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.TextureAddressCaps & it->second)) return false;
		range = mReqCapsTable.equal_range("ShadeCaps");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.ShadeCaps & it->second)) return false;
		
		if(D3D_OK != mD3d->CheckDeviceFormat(D3DADAPTER_DEFAULT, mDevType, mAdapterFormat, D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_TEXTURE, D3DFMT_X8R8G8B8)) return false;
		if(!(mCaps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP)) return false;

		if(mCaps.VertexShaderVersion < D3DVS_VERSION(2,0)) return false;
		if(mCaps.PixelShaderVersion < D3DPS_VERSION(2,0)) return false;
		if(mCaps.MaxAnisotropy < 4) return false;
		if(mCaps.MaxTextureWidth < 256) return false;
		if(mCaps.MaxTextureHeight < 256) return false;	
		return true;
	}
	else return false;
}
1

Share this post


Link to post
Share on other sites

I can still see a lot of ways in which this can be made cleaner, but then it won't be your code. :-)

Still if it helps, this does look much better than before.

I would say that now your initial query is solved and what remains is how well you can utilise the solution.

Have fun!

0

Share this post


Link to post
Share on other sites

Will work on it :)

To be honest I'm really in a flow with my engine, will be posting more.

Next is playing around with skyboxes using cubemap textures.

 

Thanks again for the help.

0

Share this post


Link to post
Share on other sites
Hi, Could you maybe give me some direction? Been thinking about it, but there must be a way to prevent/clean the part where i loop through all types of 'caps'. Maybe seeking for unique values or something, in the first 'column'.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0