8

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 ...


8

Short answer: yes, that formula is correct. Longer answer: if you think of a texture as being a grid of little squares, one for each texel, the actual color value stored in the texture can be thought of as being located at a point at the center of each texel square. So, in UV coordinates where the texture ranges from (0, 0) to (1, 1), the color samples are ...


7

The fixed function pipeline doesn't involve many changes to shaders (there may even be only a single "fixed function" shader in the driver's fixed-function emulation path; up to the driver how it handles legacy APIs) which are one of the more expensive things to change. The driver also could be doing a bazillion different things to optimize or not depending ...


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 ...


6

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 ...


6

Well, I'm surprised about the stuff you can learn when researching stuff for answering a question. Short answer: you can't. This stuff you probably already know, but I'll cover it in case other people find it useful. At first I thought you can't share handles among Direct3D devices, let alone versions, but it turns out that you can actually do that! In ...


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.


4

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.


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

Your problem is that UVs are designed to be texture coordinates. A coordinate of 0,0 is the top left corner of the top left pixel in the texture, which is not where you normally want to read the texture. For 2D you want to read the texture in the middle of that pixel. If my maths is right what you need to do to work round that is: return float4((texCoord....


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 http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150%28v=vs.85%29.aspx#...


4

I think Sprite.Begin will set it's own shader for drawing sprites and overwrite yours. So change the order. sprite.Begin(); effect.BeginPass(i); note: This is how it works with Xna, and i don't think your shader is ready for what sprite.Draw will do


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

Preventing present waiting for a vsync is basically all you can do if you want to do other things with that thread or D3D9 in general. However what you could do is load your file from disk on another thread (or asynchronously with say overlapped IO) then create your texture from that on the main thread. If your using a compressed image format that will need ...


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?


4

Now when using the discard presentation in a Win32 app it passes the render target to DWM which then blits the target to the screen and when in full screen mode (provided you have resized your back buffer and refresh rate correctly) it will disable DWM and perform flips to render the scene. Now with metro apps there's no such thing as full screen exclusive ...


4

For texture spaces, in Direct3D (0, 0) is top-left, in OpenGL (0, 0) is bottom-left. Therefore the v-coordinate will be upside down in one of these APIs. However, I wouldn't recommend negating the v-coordinate as this will only work if you're using a sampler with wrapping. You can fix the v-coordinate as follows: v = 1.0f - v;


3

Direct3D9 does not support rendering from more than one thread at once. The best you can do is render from a non-GUI thread. However, there are operations which can be done outside D3D9, for example, computing world matrices, or copying into vertex buffers, which can be parallelised. However, anything that involves calling into a D3D9 API cannot ever be ...


3

There is a mesh convert tool in my directory of DXSDK. I can convert .x format from binary to text and text to binary (among other things). C:\Program Files\DXSDK\Utilities\bin\x86>MeshConvert.exe


3

Here is something that may help. Ask your friend to install the DirectX SDK, then launch the DirectX control panel. From there, select the debug runtime. Finally, tell your friend to launch PIX (included in the DirectX SDK, too) and record a whole frame of your program, then save the result and send it to you. You can run PIX locally in order to guide your ...


3

Suppose we want an object to appear that it has constant size, regardless of the camera's position, in a 3D perspective projection. The solution is to scale the object in every frame, to increase/reduce it's size. Suppose we want the object to be 1/4 of the size of the viewport. This can be calculated as follows : const double fov = Math.PI / 4.0; //...


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 GPU is telling you it can't create textures larger than 8192 in either dimension, and you're trying to create one that's 11520 wide. It's not going to work. This is likely to be a limitation of the GPU itself, not something you can work around with some hackery or a different driver. For instance, the GPU's texture units might only have enough bits in ...


3

All right, the question has become much more sophisticated, so I'll upgrade my comment to an answer. There are lots of ways to do what you want to do. The more precise you want your lighting calculations, the more complex the program will be, so I'd advice you focus on keeping it simple, and dedicate more of your time to making the game fun instead of ...


Only top voted, non community-wiki answers of a minimum length are eligible