1.DirectX åºç¡
2.DirectX游戏编程基础教程内容简介
3.Renderdoc DirectX ByteCode 转 HLSL 插件 修复说明,DXBC/HLSL 逆向反汇编
DirectX åºç¡
// DemoLight.cpp:
//
#include <windows.h>
#include <d3dx9.h>
#include <mmsystem.h>
//#pragma comment (lib, "d3d9.lib")
//#pragma comment (lib, "d3dx9d.lib")
//#pragma comment (lib, "winmm.lib")
//#pragma comment (lib, "d3dxof.lib")
//#pragma comment (lib, "dxguid.lib")
struct CUSTOMVERTEX {
D3DXVECTOR3 position;
D3DXVECTOR3 normal;
};
#define D3DFVF_CUSTOMVERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL)
LPDIRECT3D9 d3d9;
LPDIRECT3DDEVICE9 d3ddev;
LPDIRECT3DVERTEXBUFFER9 d3dvb;
void InitD3D( HWND hwnd)
{
d3d9 = Direct3DCreate9( D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof( d3dpp));
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.EnableAutoDepthStencil = true;
d3dpp.AutoDepthStencilFormat = D3DFMT_D;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.Windowed = true;
d3d9->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
d3ddev->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE);
d3ddev->SetRenderState( D3DRS_ZENABLE, true);
}
void InitGeometry()
{
CUSTOMVERTEX* pVertices;
d3ddev->CreateVertexBuffer( * 2 * sizeof( CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &d3dvb, NULL);
d3dvb->Lock( 0, 0, ( void**)&pVertices, 0);
for( int i=0; i<; i++) {
float theta = 2 * D3DX_PI * i / ;
pVertices[2 * i].normal = D3DXVECTOR3( sinf( theta), -1.0f, cosf( theta));
pVertices[2 * i].position = D3DXVECTOR3( sinf( theta), 0.0f, cosf( theta));
pVertices[2 * i + 1].normal = D3DXVECTOR3( sinf( theta), 1.0f, cosf( theta));
pVertices[2 * i + 1].position = D3DXVECTOR3( sinf( theta), 0.0f, cosf( theta));
}
d3dvb->Unlock();
}
void SetupMatrix()
{
D3DXMATRIXA matWorld;
D3DXMatrixIdentity( &matWorld);
D3DXMatrixRotationX( &matWorld, timeGetTime() / .0f);
d3ddev->SetTransform( D3DTS_WORLD, &matWorld);
D3DXVECTOR3 vEyePt( 0.0f, 0.0f, -5.0f);
D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f);
D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f);
D3DXMATRIXA matView;
D3DXMatrixIdentity( &matView);
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec);
d3ddev->SetTransform( D3DTS_VIEW, &matView);
D3DXMATRIXA matProj;
D3DXMatrixIdentity( &matProj);
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI / 4, 1.0f, 1.0f, .0f);
d3ddev->SetTransform( D3DTS_PROJECTION, &matProj);
}
void SetupLights()
{
D3DMATERIAL9 mtrl;
ZeroMemory( &mtrl, sizeof( mtrl));
mtrl.Ambient.a = mtrl.Diffuse.a = 1.0f;
mtrl.Ambient.b = mtrl.Diffuse.b = 0.0f;
mtrl.Ambient.g = mtrl.Diffuse.g = 1.0f;
mtrl.Ambient.r = mtrl.Diffuse.r = 1.0f;
d3ddev->SetMaterial( &mtrl);
D3DLIGHT9 light;
ZeroMemory( &light, sizeof( light));
light.Type = D3DLIGHT_DIRECTIONAL;
light.Position = D3DXVECTOR3( -5.0f, 0.5f, -5.0f);
light.Direction = D3DXVECTOR3( 0.0f, 0.0f, 0.0f);
light.Ambient.r = light.Diffuse.r = 1.0f;
light.Ambient.g = light.Diffuse.g = 1.0f;
light.Ambient.b = light.Diffuse.b = 0.0f;
light.Range = .0f;
d3ddev->SetLight( 0, &light);
d3ddev->LightEnable( 0, true);
d3ddev->SetRenderState( D3DRS_AMBIENT, 0x);
}
void Render()
{
d3ddev->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, ), 1.0f, 0);
d3ddev->BeginScene();
SetupMatrix();
SetupLights();
d3ddev->SetStreamSource( 0, d3dvb, 0, sizeof( CUSTOMVERTEX));
d3ddev->SetFVF( D3DFVF_CUSTOMVERTEX);
d3ddev->DrawPrimitive( D3DPT_TRIANGLELIST, 0, );
d3ddev->EndScene();
d3ddev->Present( NULL, NULL, NULL, NULL);
}
void Cleanup()
{
d3dvb->Release();
d3ddev->Release();
d3d9->Release();
}
LRESULT CALLBACK windowProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch( msg) {
case WM_DESTROY:
Cleanup();
PostQuitMessage( 0);
return 0;
}
return DefWindowProc( hwnd, msg, wParam, lParam);
}
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASSEX wce;
wce.cbClsExtra = 0;
wce.cbSize = sizeof( wce);
wce.cbWndExtra = 0;
wce.hbrBackground = ( HBRUSH) GetStockObject( WHITE_BRUSH);
wce.hCursor = LoadCursor( NULL, IDC_ARROW);
wce.hIcon = LoadIcon( NULL, IDI_APPLICATION);
wce.hIconSm = wce.hIcon;
wce.hInstance = hInstance;
wce.lpfnWndProc = &windowProc;
wce.lpszClassName = L"DemoLight";
wce.lpszMenuName = NULL;
wce.style = CS_HREDRAW | CS_VREDRAW;
RegisterClassEx( &wce);
HWND hwnd = CreateWindowEx( 0, wce.lpszClassName, L"Light", WS_OVERLAPPEDWINDOW, , , , , NULL, NULL, hInstance, NULL);
InitD3D( hwnd);
InitGeometry();
ShowWindow( hwnd, SW_SHOWNORMAL);
UpdateWindow( hwnd);
MSG msg;
ZeroMemory( &msg, sizeof( msg));
while( msg.message != WM_QUIT) {
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage( &msg);
DispatchMessage( &msg);
} else
Render();
}
return 0;
}
DirectX游戏编程基础教程内容简介
这本详尽的教程深入讲解了DirectX编程的基础和核心内容。首先,它涵盖了必备的nba英雄源码基础知识,包括与图形技术相关的内容,以及DirectX与Windows系统之间的紧密联系。具体来说,它详细探讨了Direct3D在三维图形和动画开发中的应用,以及DirectX Audio在音频制作中的作用。
此外,对于用户输入的分类信息 app源码处理,DirectInput部分提供了深入的理解和实践指导。教程还特别设计了丰富的示例程序和课后练习,每章都配有源代码,以便读者在实践中巩固所学。作为教材,数据挖掘算法源码它尤其适合高等教育机构,对于希望在DirectX游戏开发领域寻求专业发展的人来说,这是一本极具价值的自学资源。
如果你对新一代Windows操作系统(Windows Vista和Windows 7)的图形引擎,以及WPF(Windows Presentation Foundation)图形界面开发技术的汽车调度系统源码底层原理感兴趣,这本书同样提供了深入的参考。总的来说,无论你是初学者还是专业开发者,都能从这本书中收获丰富且实用的知识。
Renderdoc DirectX ByteCode 转 HLSL 插件 修复说明,社交app完整源码DXBC/HLSL 逆向反汇编
面对问题描述,您可能在尝试使用特定插件进行DirectX ByteCode转HLSL时遇到了错误。解决此问题的关键在于选用正确的插件,推荐使用原版的cmd_HLSLDecompile.exe,该工具的源代码位于github.com/bo3b/3Dmigot...。为了确保问题的解决,您需要执行以下步骤:
1. 将原版的cmd_HLSLDecompile.exe下载到指定路径,例如D:/Work/HLSLDecompiler。
2. 在同一目录下创建一个bat文件,输入上述脚本内容。命名文件为hlsl_decompiler_wrapper.bat。
3. 使用renderdoc时调用此bat文件,并在编辑过程中解决问题。
补充说明:在使用过程中,您可能会遇到针对android平台的half类型与minf4不支持的问题。这是因为当前工具并未考虑到Minimum-precision data types的处理情况。若您是Unity开发者且在编辑器中遇到此问题,请尝试将开发平台设置回Windows。这将有助于解决相关问题并顺利转换DirectX ByteCode至HLSL。