Hot answers tagged directx9
14
Your dilemma hints at a larger problem that's well-known to the graphics programming community, commonly referred to as "combinatorial shader explosion." As the name implies, it's usually considered in the context of very large numbers of shader permutations, but the basic principle is the same. Solutions geared toward solving the overarching problem are ...
8
In DirectX 10 the cards all have the same capabilities: this means that they guarantee that all features are available and implemented.
However, they are free to do driver-level optimizations. Take, for example, the major difference in the way that they do anisotropic filtering (this article contains sources). Not only is the output of each vendor different ...
6
ID3DXFont can be used to render 2D text, and D3DXCreateText can be used to generate a 3D text mesh you could render as well. In general I would think the 2D approach is preferable, unless you want the text to do something odd like spin in 3D space.
To find the appropriate place to start rendering the text (for the 2D case), you'll want to use the ...
6
The document just describes a particle system. Particle systems are nothing new, the difference with the demo is just that it uses the geometry shader to generate the geometry needed for the single partices. You can do the same on the CPU, the only drawback is that it is slower. Everything else can be done on SM 3.0 in a similar way as described in the ...
5
Ah performance optimisation! The first question is, of course, what are you limited by? Are you pixel-shader limited?
If you are, then obviously you should spend some time on this. If you are not, then simply calculate 10 lights and be done with it.
What I would probably do is implement just two shaders. One that calculates 3 lights (which is fairly ...
5
For each light do one render pass and use Additive blending. It is called forward rendering.
Question is: Why to do it this way and not just send all of the light positions and params in few arrays? Answer is that this is much easier to handle once you start making some more complex effects. And there is one plus more. You can use your current shader.
...
5
OpenGL and freeglut will do what you're looking for. Freeglut can create the spheres, cubes, cylinder, cone, donuts, teapots, etc.
GLUT (and hence freeglut) allows the user to create and manage windows containing OpenGL contexts on a wide range of platforms and also read the mouse, keyboard and joystick functions.
http://freeglut.sourceforge.net/
5
The GDI approach:
Create a bitmap and a device context
Render your 3d graphics into the bitmap using GDI
StretchBlit the bitmap onto the texture
The Pixel approach:
Lock the texture and fill the pixels using e.g. Bresenham's algorithm.
The Render approach:
Use DrawPrimitiveUP with D3DPT_LINELIST or D3DPT_LINESTRIP for drawing lines.
Arcs, circles ...
5
It sounds like the bulk of what you're doing when you say "... A bunch of GetRenderTarget to store the old render target, then SetRenderTarget to set a new surface, and then things like CreateVertexBuffer, SetTexture, etc to draw on the new render target. Then resetting to the old render target." is actually stuff that needs to be done outside of a ...
5
Firstly, I'd suggest using VertexBuffer<T> to improve type safety, but secondly, I think the differences between the two APIs are too much at this level. I personally would fully encapsulate the renderers behind an interface which does not deal with things like vertex declarations or setting shader attributes.
5
You're basically running into the kind of situation that makes NVIDIA Cg such an attractive piece of software (aside from the fact that it doesn't support GL|ES, which you said you're using).
Also note that you really shouldn't use glGetAttribLocation. That function is bad juju from the initial days of GLSL before the folks in charge of GL really started ...
4
A talented programmer (Iq from from rgba) has written good articles:
ssao: http://www.iquilezles.org/www/articles/ssao/ssao.htm
global illumination: http://www.iquilezles.org/www/articles/simplegi/simplegi.htm
ambient illumination: http://www.iquilezles.org/www/articles/ao/ao.htm
4
Check out this simple fragment shader implementation with explanation on why's and how's http://www.coniserver.net/wiki/index.php/Screen_Space_Ambient_Occlusion_Shader Although it is fragment/GL and not D3d9, it's simple as it gets, so you should be able to understand what you need to do.
4
Use the DirectX Error Lookup tool that's found in the SDK.
Passing this value in it returns the following result:
HRESULT: 0x80070057 (2147942487)
Name: E_INVALIDARG
Description: An invalid parameter was passed to the returning function
Severity code: Failed
Facility Code: FACILITY_WIN32 (7)
Error Code: 0x0057 (87)
You have an invalid argument passed ...
4
Yes, it would be more scalable in the long run to write a system could wrap and handle what your shaders need for you.
There are several ways to do this, such as having a "Shader" class like you mentioned that inspects the underlying D3D Effect object for semantic annotations that let your wrapper class determine things like which kinds of vertex or texture ...
4
The name "Draw" is somewhat misleading. It should better be called "AddToBatch".
What it actually does is batch your Draw calls. Only when you call ID3DXSprite::Flush or Id3DXSprite::End it fills the sprites into one big vertex buffer and renders that onto the current render target.
So if you want to switch render targets in between, you will have to do ...
4
But the problem is that the 3D graphics arent working with the Physics correctly...
Pretty much any pair of graphics and physics libraries will work together. If you haven't managed to get OpenGL graphics and Bullet physics working, you probably just have a bug there which can be fixed.
4
You need a DirectX 10 compatible GPU for running HiDef XNA games. Just change your project settings to Reach or get a compatible graphics card.
You can find more info on the differences between HiDef and Reach on this post from Shawn Hargreaves.
4
You should use the latest (non-beta) version of the SDK (which is the June 2010 SDK as of this writing). It will be the most well-supported.
Really, the only reason to use an older release of the SDK is if you are working on maintaining a legacy project that has a dependency on a technology that has been deprecated, such as DirectPlay.
4
Agreed, the latest release of the SDK is generally the best one to use, but there are other considerations.
From sometime in 2004 (IIRC) onwards the D3DX stuff moved from being statically linked to dynamically linked. In order to handle this, the player needs a version of D3D that is up to date. In a fit of ingenuity, MS didn't include these up to date ...
4
When targeting the 9_1, 9_2 and 9_3 feature levels, the shader profiles you should use are:
vs_4_0_level_9_1/ps_4_0_level_9_1 for levels 9_1 and 9_2, and;
vs_4_0_level_9_3/ps_4_0_level_9_3 for the 9_3 level.
This is hidden quite deeply in the MSDN documentation at
...
4
Yes, this behavior changed from DX9 to DX10+, don't know much about the real story behind it, but I suspect that DX9 had to remap registers between VS and PS at runtime anyway (when linking shaders) which is inefficient.
In DX10+, when you compile a VertexShader and a PixelShader, you can see which register will be affected to a particular semantic (see ...
4
How to capture the screen in DirectX 9 to a raw bitmap in memory without using D3DXSaveSurfaceToFile
The way I do this is as follows.
IDirect3DDevice9::GetBackBuffer:
Get access to the IDirect3DSurface9 representing the back buffer, same as you've currently got. Don't forget to Release this surface when done as this call will increment the reference count!
IDirect3DSurface::GetDesc:
Get the description of the back buffer surface, which will give you it's ...
4
You could either adjust your projection matrix appropriately, or else do a render-to-texture and draw that texture as a fullscreen quad with flipped l and r values in an off-center ortho projection. Depends really on what you're trying to achieve with this, i.e. what's your underlying objective here? Is this for a mirrored view? Etc?
3
Specifying the default pool does not instruct Direct3D to put the resource on the GPU. It instructs Direct3D to put the resource in the best pool for the usage you specified for the resource.
The task manager is a very poor way of measuring performance, in general. It's possible the allocation is transient and done by the D3D API in order to transfer some ...
3
I built a generic transition system for a 2d engine for iPhone. I'm going to try to explain it. This is only an approach, the implementation has more things that are not relevant.
Suppose that your engine is hierarchical, if it is not, there are a lot of of reasons why a game engine must be hierarchical. We can have two interfaces IState and ITransition ...
3
If it's so straight forward, why can't you solve it? No need to be rude.
Anyway, the first hit on Google is the spec that tells you exactly how you can perform the conversion: http://msdn.microsoft.com/en-us/library/bb173014%28VS.85%29.aspx
Alternatively, a Google for tools that will do this brings up plenty of hits.
Straight-forward indeed.
3
It is important to note that the DirectX API is independent of the DirectX Hardware. That is to say that a DirectX 11 video card can still be accessed through the DirectX 9 API.
Much legacy code still uses the DirectX 9 API, and as I recall, Direct X is a backwards compatible API, so your code targeting DirectX 9 should run on a machine with DirectX 11 ...
3
You did everything correctly, however you must run in "Debug" mode - ie press regular F5, not CTRL+F5. Do not choose "start without debugging" from Visual Studio.
Edit
I don't actually use #define D3D_DEBUG_INFO, but according to this post you should #define that before including the d3d9 headers.
Also be sure you have set to use the Debug version of ...
3
The answer doesn't have to do with DoubleBuffered, but rather with the default behaviour of System.Windows.Forms.Forms, which paint their own background when they need to paint. The answer is to add an override in the form:
protected override void OnPaintBackground(PaintEventArgs e)
{ }
Which fixes the problem.
Only top voted, non community-wiki answers of a minimum length are eligible