标签: directx-9

HLSL无效ps_2_0输入语义POSITION0

我正在尝试在RenderMonkey中为Dx9编写一个phong着色器效果.

我在像素着色器中遇到编译错误

*"无效的ps_2_0输入语义'POSITION0'"*

我不知道如何修复它,虽然我知道它必须与VS_OUTPUT中的POSITION0语义有关.

我尝试将VS_OUTPUT的Pos语义更改为TEXCOORD0,但系统会报告

顶点着色器必须最低限度地写入POSITION的所有四个组件

着色器在下面提供.有什么建议?

这是我的顶点着色器:

struct VS_INPUT 
{
   float4 Pos : POSITION0;
   float3 Normal : NORMAL0;
};

struct VS_OUTPUT 
{
   float4 Pos : POSITION0;
   float3 Normal : TEXCOORD0;
};

VS_OUTPUT vs_main( VS_INPUT Input )
{
   VS_OUTPUT Output;

   Output.Pos     = Input.Pos;
   Output.Normal  = Input.Normal;

   return Output;  
}
Run Code Online (Sandbox Code Playgroud)

和我的像素着色器:

    float4x4 matViewProjection;

// light source
float4 lightPos;
float4 Ambient;
float4 Diffuse;
float4 Specular;

// material reflection properties
float4 Ke;
float4 Ka;
float4 Kd;
float4 Ks;
float  nSpecular;

// eye
float4 …
Run Code Online (Sandbox Code Playgroud)

directx hlsl directx-9 rendermonkey

3
推荐指数
1
解决办法
6461
查看次数

设置Direct3D运行时的调试版本不会出错

当我打开DirectX控制面板并打开Direct3D 9选项卡并设置“使用Direct3D 9的调试版本”并单击“确定”或“应用”时,没有错误。如果再次打开控制面板,它将返回到“使用Direct3D 9的零售版”。尝试调试应用程序时,没有从Direct3D获得任何输出。

几个月前我上一次这样做时,一切正常,并且得到了调试输出。

以管理员身份运行控制面板似乎没有什么不同,这里提到的注册表项http://www.gamedev.net/topic/514529-cant-use-debug-version-of-direct3d/设置为一个。

我还能尝试什么?

debugging directx directx-9

3
推荐指数
1
解决办法
2751
查看次数

C++:存储复制操作不合理或不可能的资源

我想写一个ContentManager为游戏加载和维护不同类型资产的类(与XNA的ContentManager相比).我的头文件如下所示:

class ContentManager
{
public:
  ContentManager(Direct3D& d3d, const std::string& rootDirectory = "Resource");
 ~ContentManager();

  template<typename T>
  const T& Load(const std::string& assetName);

private:
  Direct3D& d3d_;
  std::string rootDirectory_;

  std::map<std::string, Texture> textures_;
};
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我有一个每种资产类型的地图(目前只针对纹理)和一个泛型Load<T>()方法,我会为我想要存储的每种资产类型显式实例化.Load<Texture>()从磁盘读取图像文件(如果它尚未在地图中),创建一个新的Texture,将其插入到地图中并返回它.

我的Texture班级基本上创建和封装了原始IDirect3DTexture9遵循RAII成语(析构函数调用Release()texture_):

class Texture
{
public:
  Texture();
  Texture(Direct3D& d3d, unsigned int width, unsigned int height, 
    const std::vector<unsigned char>& stream);

  ~Texture();

  IDirect3DTexture9* GetD3DTexture() const { return texture_; }

private:
  IDirect3DTexture9* texture_;
}; …
Run Code Online (Sandbox Code Playgroud)

c++ directx move-constructor directx-9

3
推荐指数
1
解决办法
254
查看次数

VS 2017将找不到DirectX包含的文件

我已经安装了DirectX SDK,我想在Visual Studio 2017中的C++项目中使用.我配置了C++ include路径并添加了一个包含DirectX SDK包含文件($(DXSDK_DIR)Include\)的目录,这些文件正确地解析了C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\所有文件所在的位置

但是当#include <d3dx9core.h>当我检查自己时,我尝试将其正确安装在Include目录中,它说它无法找到该文件.

我该如何解决?

c++ directx directx-9 visual-studio-2017

3
推荐指数
1
解决办法
5982
查看次数

如何在Visual Studio中多次编译hlsl着色器?

我已将 HLSL 着色器添加到我的 Visual Studio 项目中,并且作为构建过程的一部分,它们会自动编译为 cso 文件。我面临的问题是,我需要使用不同的着色器模型多次编译它们,因为“/4_0_level_9_3”适用于 DirectX 11,但不适用于 DirectX 9,而“/3_0”仅适用于 DirectX 9,但不适用于在 DirectX 11 上。

向 Visual Studio 项目多次添加相同的文件不起作用,我想避免复制 HLSL 源文件,因为它会增加维护工作量和潜在的错误原因。我也无法在 Visual Studio 中创建单独的目标/配置来实现此目的,因为我需要在可执行文件中支持两个 DirectX 版本(可在运行时切换)。

有没有办法在 Visual Studio 中为单个 HLSL 文件指定多个编译(不同的着色器模型和不同的输出文件)?

hlsl directx-11 directx-9 visual-studio-2017

3
推荐指数
1
解决办法
1690
查看次数

DirectX9 的 HRESULT 0x8876086c D3DERR_INVALIDCALL 几乎遵循文档示例

所以我想在另一个窗口上绘制一个覆盖图,但是我没有得到真正的运行时错误,Visual Studio 调试工具告诉我结果是

HRESULT res = object->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWND, D3DCREATE_HARDWARE_VERTEXPROCESSING, &params, NULL, &device);
Run Code Online (Sandbox Code Playgroud)

是 0x8876086c。因此,这里是我的代码片段,它们很重要,并导致此错误(D3DERR_INVALIDCALL),这导致设备成为空指针,这意味着我无法用它做任何事情。

我真的无法弄清楚是什么导致了这个,因为我几乎遵循了文档

int Paint::init(HWND hWND) {
if (FAILED(Direct3DCreate9Ex(D3D_SDK_VERSION, &object))) {
    exit(1);
}
ZeroMemory(&params, sizeof(params));

params.BackBufferWidth = width;
params.BackBufferHeight = height;
params.Windowed = true;
params.hDeviceWindow = hWND;
params.MultiSampleQuality = D3DMULTISAMPLE_NONE;
params.BackBufferFormat = D3DFMT_A8R8G8B8;
params.EnableAutoDepthStencil = TRUE;
params.AutoDepthStencilFormat = D3DFMT_D16;


HRESULT res = object->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWND, D3DCREATE_HARDWARE_VERTEXPROCESSING, &params, NULL, &device);
Run Code Online (Sandbox Code Playgroud)

并在头文件中:

class Paint {
private:
IDirect3D9Ex* object = NULL;
IDirect3DDevice9Ex* device = NULL;
DWORD behaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;

D3DPRESENT_PARAMETERS …
Run Code Online (Sandbox Code Playgroud)

c++ directx directx-9

3
推荐指数
1
解决办法
4076
查看次数

DirectX9中的简单HLSL发光/模糊效果

我一直在努力寻找任何资源来帮助我使用高级着色器语言和DirectX 9托管库编写简单的辉光/模糊着色器.

我需要做的就是将一系列CustomVertex.TransformedColored顶点绘制成简单的线条,然后通过HLSL效果模糊/发光.

我已经在互联网上搜索了大约三天的一些结果,但我找不到一个非常好的教程或示例.我对HLSL有一个基本的了解,但我不太了解如何编写这个着色器(我已经阅读了3本DirectX书籍中的HLSL章节).

这是一些(删节)代码:

CustomVertex.TransformedColored[] glowVertices = new CustomVertex.TransformedColored[4];
glowVertices[0] = new CustomVertex.TransformedColored(random.Next(this.render.Width), random.Next(this.render.Height), 1, 1, Color.Cyan.ToArgb());
glowVertices[1] = new CustomVertex.TransformedColored(random.Next(this.render.Width), random.Next(this.render.Height), 1, 1, Color.Blue.ToArgb());
glowVertices[2] = new CustomVertex.TransformedColored(random.Next(this.render.Width), random.Next(this.render.Height), 1, 1, Color.Cyan.ToArgb());
glowVertices[3] = new CustomVertex.TransformedColored(random.Next(this.render.Width), random.Next(this.render.Height), 1, 1, Color.Blue.ToArgb());

this.device.BeginScene();
int passes = this.glowEffect.Begin(0);
for (int i = 0; i < passes; i++)
 {
     this.glowEffect.BeginPass(i);
     this.device.DrawUserPrimitives(PrimitiveType.LineStrip, glowVertices.Length - 1, glowVertices);
     this.glowEffect.EndPass();
 }
 this.glowEffect.End();
 this.device.EndScene();
Run Code Online (Sandbox Code Playgroud)

我想我不是在寻找HLSL特定部分的帮助,考虑到我要发布的问题和代码数量,我真的只是寻找一些帮助寻找资源!

c# hlsl glow directx-9 managed-directx

2
推荐指数
1
解决办法
5148
查看次数

注册表版本错误

我想从Registry中读取DirectX版本.

我在HKLM\Software\Microsoft\DirectX下找到值Version的值.

我的问题:提到嘿脚本专家!我的版本"4.09.00.0904"是9.0c,但dxdiag显示DirectX 11.

如何找到合适的版本?或者有没有办法在没有注册表的情况下解决这个问题?

编辑:我使用的是Windows 7 Professional x86

windows registry directx directx-9

2
推荐指数
1
解决办法
634
查看次数

如何解决Direct3DCreate9的LNK2019问题?

在编译期间,我收到以下错误:

RAT_RendererDX9.obj:错误LNK2019:解析外部符号_Direct3DCreate9 @ 4在功能上引用的 "市民:无效__thiscall RAT_ENGINE :: RAT_RendererDX9 ::初始化(类RAT_ENGINE :: RAT_WindowManager*)?"(初始化@ RAT_RendererDX9 @ RAT_ENGINE @@ QAEXPAVRAT_WindowManager @ 2 @ @Z)

我使用的唯一的地方Direct3DCreate9是我Init()其中有下面的代码中渲染的功能:

void RAT_RendererDX9::Init(RAT_WindowManager* argWMan)
{
    wMan = argWMan;

    g_pD3D = (LPDIRECT3D9)Direct3DCreate9( D3D_SDK_VERSION );

    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory( &d3dpp, sizeof( d3dpp ) );
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;

    g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                              D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                              &d3dpp, &g_pd3dDevice );
}
Run Code Online (Sandbox Code Playgroud)

这个错误来自哪里,我该如何解决?
我已经尝试了LNK2019的其他答案,但他们没有解决我的问题.

c++ directx visual-c++ directx-9

2
推荐指数
1
解决办法
7403
查看次数

DirextX9材料不再是用于学习Win32 API编程的材料吗?

我一直在扩展我的图书馆(这些奇怪的事物的物理图书馆,称为“书” ...我知道...我知道),并且我正在阅读Wendy Jones撰写的Beginning DirectX 9.0。正如我过去浏览过一些过时的书一样,它们背后的逻辑实际上是相同的,即使在较早的版本(以我的经验)中,如我所读的C ++书籍中,如果不是更重要的话。我在DirectX 9本书中遇到的问题是10/10练习代码,永远无法使用。甚至这里找到的解决方案和MSDN都不适合我。(相同的问题)。

因此,我希望您能在购买DX11之前告诉我,是否与我的编译器/ vs有关,或者与vs是2015年更新的事实有关,并且该DX9已过时/ DX11标准已介绍。

//Include the Windows header file that's needed for all Windows applications 
#include <Windows.h>


HINSTANCE hInst; // global handle to hold the application instance
HWND wndHandle; // global variable to hold the window handle

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow);

//forward declerations
bool initWindow(HINSTANCE hInstance);
LRESULT CALLBACK WndProc(HWND, UINT WPARAM, LPARAM);

//This is winmain, the main etry point for Windows applications
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, …
Run Code Online (Sandbox Code Playgroud)

winapi compiler-errors obsolete directx-9

1
推荐指数
1
解决办法
63
查看次数