directx

How to apply shader to an Bitmap offline with SharpDX

有些话、适合烂在心里 提交于 2019-12-11 11:43:37
问题 i want to apply a shader to a bitmap (offline processing) with sharpdx. I found a sample on SharpDX homepage to apply an effect to an image with offline processing. Now i want to apply a shader.fx to it but i don't know how to do it. Can anyone help me out? Here are the code snipset: // Effect 1 : BitmapSource - take decoded image data and get a BitmapSource from it var bitmapSourceEffect = new d2.Effects.BitmapSource(d2dContext); bitmapSourceEffect.WicBitmapSource = formatConverter; //

Down Casting ID3D11Texture2D

你。 提交于 2019-12-11 11:37:49
问题 According to the documentation http://msdn.microsoft.com/en-us/library/windows/desktop/ff476635(v=vs.85).aspx ID3D11Texture2D inherits from the ID3D11Resource. I tried the following but it gives a std:non-rtti exception. ID3D11Texture2D *tex2d = dynamic_cast<ID3D11Texture2D*>(resource); 回答1: Since ID3D11Texture2D is a COM interface you should use QueryInterface to get other interfaces the object might support. Something like this: HRESULT hr = resource->QueryInterface(IID_ID3D11Texture2D,

destroy directx device and swap chain

雨燕双飞 提交于 2019-12-11 11:12:55
问题 I am encountering a strange issue I think involves D3D11CreateDeviceAndSwapChain I can create the device and swap chain however when the application exits and ->destroy gets called on the swap chain, device, and device context a thread is still running. Commenting out this line the application terminates as expected. featureLevel = D3D_FEATURE_LEVEL_11_0; result = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, &featureLevel, 1, D3D11_SDK_VERSION, &swapChainDesc, &m

Odd behaviour when trying to create triangle using TriangleStrip Topologu

∥☆過路亽.° 提交于 2019-12-11 11:01:49
问题 I tried to create this 2D triangle in with the Input Assembler set to triangle strip: 1.(0.0f, 0.0f, 0.5f) 2.(-0.5f, 0.0f, 0.5f) 3.(-0.5f, -0.5f, 0.5f) However, no triangle was drawn, in fact nothing was drawn on the render target, not even a single line. I messed around, and then I swapped coordinates 2 and 3 , and it worked. The triangle was drawn just as I intended it to be. What is the reason for this odd behaviour? 回答1: You define your vertex in counter-clockwise order, and Direct3D will

Back face culling for linestrips

邮差的信 提交于 2019-12-11 10:58:20
问题 I have circle in 3D space (red on image) with normals (white) This circle is being drawn as linestrip. Problem is: i need to draw only those pixels whose normals directed into camera (angle between normal and camera vector is < 90) using discard in fragment shader code. Like backface culling but for lines. Red part of circle is what i need to draw and black is what i need to discard in fragment shader. Good example is 3DS Max rotation gizmo, back sides of lines are hidden: So, in fragment

Calling Inherited IUnknown::Release() in a destructor

拥有回忆 提交于 2019-12-11 10:49:06
问题 Why does calling the inherited IUnknown::Release() function on a IWICImagingFactory object in a destructor cause a "CXX0030: Error: expression cannot be evaluated" to be shown each entry in the object's virtual function table (__vfptr)? This is in reference to an earlier question I posted but I've since realized that the problem only occurs in the destructor. The virtual function table appears valid anywhere else I have checked. However, once in the destructor all entries are shown with the

IDXGISwapChain::Present Memory Leak

谁都会走 提交于 2019-12-11 09:29:14
问题 I'm kinda learning Direct3D and have this quite basic code, nothing too fancy. During debugging in Visual Studio I noticed a constantly increasing memory usage, which is kinda weird. From what I observed, IDXGISwapChain::Present allocates new memory blocks with each frame update. Here is a difference between two memory snapshots, about 7 second difference. I have no idea what could be the cause of this, maybe I forgot to call some sort of clearing function? And I don't even have any buffers

What is the fastest way of taking a screenshot in Windows?

我的梦境 提交于 2019-12-11 09:23:15
问题 What is the fastest way to capture a screenshot in Windows? A driver? Using DirectX? 回答1: The fastest way would be to read mapped region of video card memory I think... Just an idea, never tried that. 回答2: A while back I timed the win32 api and the .net wrapper. Here is the complete blog post: http://blog.bobcravens.com/2009/04/fastest-screen-capture-using-c-vista-vs-win7/ The upshot is that the .net wrapper in the latest version of Win7 is as fast as the native win32 api. I have never tried

Rendering to texture - ClearRenderTargetView() works, but none objects are rendered to texture (rendering to screen works fine)

拜拜、爱过 提交于 2019-12-11 09:22:35
问题 I try to render the scene to texture which should be then displayed in corner of the screen. I though that I can do that this way: Render the scene (my Engine::render() method that will set shaders and make draw calls) - works ok . Change render target to the texture. Render the scene again - does not work. The context->ClearRenderTargetView(texture->getRenderTargetView(), { 1.0f, 0.0f, 0.0f, 1.0f } ) does set my texture to red color (for scene in step 1. I use different color), but none

Why is this 128Bit Color Format being converted to 32Bit

我的未来我决定 提交于 2019-12-11 09:18:34
问题 I am trying to write an HLSL pixel shader for a project I am working on. Basically want I want to do is if a texture has a pixel with a float value of 0.52 (on scale of 0-255 is 132.6) I want to output 133 60% of the time and output 132 40% of the time. Write now I am just trying to output the fractional remainder of the RGB value (i.e. the chance to bump the pixel up) however I always get a value of zero) I think this is because the colors are getting quantized to a 0-255 scale before they