{"id":2293,"date":"2015-04-19T09:09:59","date_gmt":"2015-04-19T09:09:59","guid":{"rendered":"http:\/\/anthroponaute.fr\/blog-informatique\/?p=2293"},"modified":"2015-12-22T16:16:27","modified_gmt":"2015-12-22T16:16:27","slug":"debugguez-vos-fichiers-fx-avec-linterface-id3d10blob","status":"publish","type":"post","link":"https:\/\/www.la-porte-des-nebuleuses.net\/blog-informatique\/?p=2293","title":{"rendered":"Debugguez vos fichiers .FX avec l&rsquo;interface ID3D10Blob"},"content":{"rendered":"<p><a href=\"https:\/\/anthropoya.cluster014.ovh.net\/blog-informatique\/wp-content\/uploads\/2015\/03\/AMD_6990.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone  wp-image-1364\" src=\"https:\/\/anthropoya.cluster014.ovh.net\/blog-informatique\/wp-content\/uploads\/2015\/03\/AMD_6990.jpg\" alt=\"AMD_6990\" width=\"346\" height=\"282\" srcset=\"https:\/\/www.la-porte-des-nebuleuses.net\/blog-informatique\/wp-content\/uploads\/2015\/03\/AMD_6990.jpg 1024w, https:\/\/www.la-porte-des-nebuleuses.net\/blog-informatique\/wp-content\/uploads\/2015\/03\/AMD_6990-300x244.jpg 300w, https:\/\/www.la-porte-des-nebuleuses.net\/blog-informatique\/wp-content\/uploads\/2015\/03\/AMD_6990-624x508.jpg 624w\" sizes=\"(max-width: 346px) 100vw, 346px\" \/><\/a><\/p>\n<p><strong>Intro :<\/strong><\/p>\n<p>Quand on compile un effet shader .fx, on a besoin de savoir o\u00f9 se situe l&rsquo;erreur de compilation lorsque la compilation a \u00e9chou\u00e9e.<\/p>\n<p><strong>Explications :<\/strong><\/p>\n<p>Voici comment proc\u00e9der avec le bout de code suivant :<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#define ShowMessageBoxDXError(hr) char buf[2048]; \\\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 sprintf(buf, &quot;Error: %s error description: %s\\n&quot;, DXGetErrorStringA(hr), \\\r\n       DXGetErrorDescriptionA(hr)); \\\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 MessageBoxA(nullptr, buf, &quot;Erreur&quot;, MB_ICONHAND | MB_OK);\r\n\r\nDWORD dwShaderFlags = D3D10_SHADER_ENABLE_STRICTNESS;\r\n\r\n#if defined( DEBUG ) || defined( _DEBUG )\r\n\/\/ Permet d'afficher les \u00e9ventuelles erreurs de la compilation d'un shader\r\ndwShaderFlags |= D3D10_SHADER_DEBUG;\r\n#endif\r\n\r\n#define SAFE_RELEASE(x) if (x != nullptr) { x-&gt;Release(); x = nullptr; }\r\n\r\nID3D10Blob* pBlob = nullptr;\r\n\/\/ Pour la cr\u00e9ation du shader, on le compile\r\nHRESULT hr = D3DX10CreateEffectFromFile(L&quot;Effet.fx&quot;, NULL, NULL, &quot;fx_4_0&quot;, dwShaderFlags, 0,\r\n                                D3D10_RENDERER-&gt;GetDevice(), NULL,\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0NULL, &amp;m_pEffect, &amp;pBlob, NULL);\r\n\r\nif (FAILED(hr))\r\n{\r\n\u00a0\u00a0 \u00a0if (pBlob)\r\n\u00a0\u00a0 \u00a0{\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\/\/ Affiche l'erreur de compilation du shader\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0MessageBoxA(NULL, (PCSTR)pBlob-&gt;GetBufferPointer(), &quot;Erreur dans le fichier shader&quot;, MB_ICONHAND | MB_OK);\r\n\u00a0\u00a0 \u00a0}\r\n\u00a0\u00a0 \u00a0else\r\n\u00a0\u00a0 \u00a0{\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0ShowMessageBoxDXError(hr);\r\n\u00a0\u00a0 \u00a0}\r\n\r\n    SAFE_RELEASE(pBlob);\r\n\r\n\u00a0\u00a0 \u00a0return false;\r\n}\r\n\r\nSAFE_RELEASE(pBlob);\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>R\u00e9sum\u00e9 :<\/strong><\/p>\n<p>On a expliqu\u00e9 comment proc\u00e9der pour savoir et afficher o\u00f9 se situe l&rsquo;erreur de compilation d&rsquo;un fichier shader .fx.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Intro : Quand on compile un effet shader .fx, on a besoin de savoir o\u00f9 se situe l&rsquo;erreur de compilation lorsque la compilation a \u00e9chou\u00e9e. Explications : Voici comment proc\u00e9der avec le bout de code suivant : &nbsp; R\u00e9sum\u00e9 : On a expliqu\u00e9 comment proc\u00e9der pour savoir et afficher o\u00f9 se situe l&rsquo;erreur de compilation [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[],"_links":{"self":[{"href":"https:\/\/www.la-porte-des-nebuleuses.net\/blog-informatique\/index.php?rest_route=\/wp\/v2\/posts\/2293"}],"collection":[{"href":"https:\/\/www.la-porte-des-nebuleuses.net\/blog-informatique\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.la-porte-des-nebuleuses.net\/blog-informatique\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.la-porte-des-nebuleuses.net\/blog-informatique\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.la-porte-des-nebuleuses.net\/blog-informatique\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2293"}],"version-history":[{"count":20,"href":"https:\/\/www.la-porte-des-nebuleuses.net\/blog-informatique\/index.php?rest_route=\/wp\/v2\/posts\/2293\/revisions"}],"predecessor-version":[{"id":2295,"href":"https:\/\/www.la-porte-des-nebuleuses.net\/blog-informatique\/index.php?rest_route=\/wp\/v2\/posts\/2293\/revisions\/2295"}],"wp:attachment":[{"href":"https:\/\/www.la-porte-des-nebuleuses.net\/blog-informatique\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.la-porte-des-nebuleuses.net\/blog-informatique\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.la-porte-des-nebuleuses.net\/blog-informatique\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}